Skip to content

Commit

Permalink
Pass no decoder cache to sub-models
Browse files Browse the repository at this point in the history
The decoder cache does not work for host models due to having
no context manager, which is normally constructed by the
top-level network builder.

This commit fixes #207 as it does not globally disable the
decoder cache. We also add some asserts to existing tests
for ensure that #207 is fixed.
  • Loading branch information
arvoelke authored and tbekolay committed Apr 15, 2019
1 parent 4f996cd commit f823f0d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions nengo_loihi/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ def __init__(self, dt=0.001, label=None, builder=None):

# Host models filled in by the build process
def create_host_model(label, dt):
# We don't use a decoder cache because it requires a context
# manager that differs depending on which sub-model is being built
return NengoModel(
dt=float(dt),
label="%s, dt=%f" % (label, dt),
decoder_cache=NoDecoderCache(),
)

# TODO: these models may not look/behave exactly the same as
Expand Down
1 change: 0 additions & 1 deletion nengo_loihi/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ def __init__( # noqa: C901
raise ValidationError("network parameter must not be None",
attr="network")

nengo.rc.set("decoder_cache", "enabled", "False")
config.add_params(network)

# ensure seeds are identical to nengo
Expand Down
5 changes: 5 additions & 0 deletions nengo_loihi/tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ def test_model_validate_notempty(Simulator):
a = nengo.Ensemble(10, 1)
model.config[a].on_chip = False

assert nengo.rc.get("decoder_cache", "enabled")

with pytest.raises(BuildError, match="No neurons marked"):
with Simulator(model):
pass

# Ensure cache config not changed
assert nengo.rc.get("decoder_cache", "enabled")


@pytest.mark.parametrize("precompute", [True, False])
def test_probedict_fallbacks(precompute, Simulator):
Expand Down

0 comments on commit f823f0d

Please sign in to comment.