def test_run_profile(network, train, pytestconfig, monkeypatch, tmpdir): monkeypatch.chdir(tmpdir) if network == "integrator": net = benchmarks.integrator(3, 2, nengo.SpikingRectifiedLinear()) elif network == "cconv": net = benchmarks.cconv(3, 10, nengo.LIF()) elif network == "test": with nengo.Network() as net: ens = nengo.Ensemble(10, 1) net.p = nengo.Probe(ens) benchmarks.run_profile( net, train=train, n_steps=10, do_profile=True, device=pytestconfig.getoption("--device"), unroll_simulation=pytestconfig.getoption("--unroll-simulation"), dtype=pytestconfig.getoption("dtype"), ) assert net.config[net].inference_only == (not train)
with Simulator(net) as sim: n_trainable = sum( np.prod(w.shape.as_list()) for w in sim.keras_model.trainable_weights) assert n_trainable == 102017 assert net.inp.size_out == 1 if native_nengo else n_steps assert net.p.size_in == 10 @pytest.mark.performance @pytest.mark.parametrize( "net, train, minibatch_size, min, max", [ (benchmarks.cconv(128, 64, nengo.RectifiedLinear()), False, 64, 0.95, 1.1), (benchmarks.cconv(128, 64, nengo.LIF()), False, 64, 2.2, 2.5), (benchmarks.integrator(128, 32, nengo.RectifiedLinear()), True, 64, 0.6, 0.9), (benchmarks.integrator(128, 32, nengo.LIF()), True, 64, 1.25, 1.45), ( benchmarks.random_network( 64, 32, nengo.RectifiedLinear(), n_ensembles=20, connections_per_ensemble=5, seed=0, ), False, None,
with Simulator(net) as sim: n_trainable = sum( np.prod(w.shape.as_list()) for w in sim.keras_model.trainable_weights ) assert n_trainable == 102017 assert net.inp.size_out == 1 if native_nengo else n_steps assert net.p.size_in == 10 @pytest.mark.performance @pytest.mark.parametrize( "net, train, minibatch_size, eager, min, max", [ ( benchmarks.cconv(128, 64, nengo.RectifiedLinear()), False, 64, True, 1.05, 1.2, ), (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, ),
with Simulator(net) as sim: n_trainable = sum( np.prod(w.shape.as_list()) for w in sim.keras_model.trainable_weights) assert n_trainable == 102017 assert net.inp.size_out == 1 if native_nengo else n_steps assert net.p.size_in == 10 @pytest.mark.performance @pytest.mark.parametrize( "net, train, minibatch_size, min, max", [ (benchmarks.cconv(128, 64, nengo.RectifiedLinear()), False, 64, 0.6, 0.75), (benchmarks.cconv(128, 64, nengo.LIF()), False, 64, 1.4, 1.6), (benchmarks.integrator(128, 32, nengo.RectifiedLinear()), True, 64, 0.55, 0.9), (benchmarks.integrator(128, 32, nengo.LIF()), True, 64, 0.95, 1.25), ( benchmarks.random_network( 64, 32, nengo.RectifiedLinear(), n_ensembles=20, connections_per_ensemble=5, seed=0, ), False, None,