def test_random_network( dimensions, neurons_per_d, neuron_type, n_ensembles, n_connections ): net = benchmarks.random_network( dimensions, neurons_per_d, neuron_type, n_ensembles, n_connections ) _test_random( net, dimensions, neurons_per_d, neuron_type, n_ensembles, n_connections )
), (benchmarks.cconv(128, 64, nengo.LIF()), False, 64, True, 2.3, 2.6), ( benchmarks.integrator(128, 32, nengo.RectifiedLinear()), True, 64, True, 0.6, 0.9, ), (benchmarks.integrator(128, 32, nengo.LIF()), True, 64, True, 0.95, 1.15), ( benchmarks.random_network( 64, 32, nengo.RectifiedLinear(), n_ensembles=20, connections_per_ensemble=5, seed=0, ), False, None, True, 0.5, 0.7, ), (benchmarks.lmu(1000, 1, native_nengo=True), True, 100, True, 1.3, 1.5), (benchmarks.lmu(1000, 1, native_nengo=True), True, 100, False, 1.05, 1.25), ], ) def test_performance(net, train, minibatch_size, eager, min, max): # performance is based on Azure NC6 VM
def compare_simplifications(ctx, dimensions): load = ctx.obj["load"] reps = ctx.obj["reps"] device = ctx.obj["device"] simplifications = [ graph_optimizer.remove_constant_copies, graph_optimizer.remove_unmodified_resets, graph_optimizer.remove_zero_incs, graph_optimizer.remove_identity_muls ] params = list(itertools.product((False, True), repeat=len(simplifications))) if load: with open("compare_simplifications_data.pkl", "rb") as f: results = pickle.load(f) else: results = [ dict([("times", [])] + [(s.__name__, p[i]) for i, s in enumerate(simplifications)]) for j, p in enumerate(params) ] # net = build_spaun(dimensions) net = benchmarks.random_network(dimensions, 32, nengo.RectifiedLinear(), 1000, 100) with net: nengo_dl.configure_settings(inference_only=True) model = nengo.builder.Model(dt=0.001, builder=nengo_dl.builder.NengoBuilder()) model.build(net) if reps > 0: # pre-heat with nengo_dl.Simulator(None, model=model, device=device, progress_bar=False) as sim: sim.run(reps, progress_bar=False) for j, p in enumerate(params): simps = [] for i, s in enumerate(p): if s: simps.append(simplifications[i]) with net: nengo_dl.configure_settings(simplifications=simps) print("%d/%d" % (j + 1, len(params)), [x.__name__ for x in simps]) with nengo_dl.Simulator(None, model=model, unroll_simulation=10, device=device, progress_bar=False) as sim: sim.run(0.1, progress_bar=False) sim_time = 1.0 for _ in range(reps): start = time.time() sim.run(sim_time, progress_bar=False) results[j]["times"].append( (time.time() - start) / sim_time) print(" ", min(results[j]["times"]), max(results[j]["times"]), np.mean(results[j]["times"])) with open("compare_simplifications_data.pkl", "wb") as f: pickle.dump(results, f)