nengo / nengo-loihi

Run Nengo models on Intel's Loihi chip
https://www.nengo.ai/nengo-loihi/
Other
35 stars 12 forks source link

Splitter fails for sliced connections and probes #205

Closed arvoelke closed 5 years ago

arvoelke commented 5 years ago

The following code has different behaviour for connections from a[0] versus a even though they are the same object (a is one-dimensional).

import nengo
import nengo_loihi

def go(do_bug):
    with nengo.Network() as model:
        nengo_loihi.add_params(model)

        a = nengo.Ensemble(1, 1, label="a")
        b = nengo.Ensemble(1, 1, label="b")
        model.config[b].on_chip = False

        nengo.Connection(a[0] if do_bug else a, b)

    with nengo_loihi.Simulator(model) as sim:
        pass

go(False)
go(True)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-148-00268f888de2> in <module>()
     16 
     17 go(False)
---> 18 go(True)

<ipython-input-148-00268f888de2> in go(do_bug)
     12         nengo.Connection(a[0] if do_bug else a, b)
     13 
---> 14     with nengo_loihi.Simulator(model) as sim:
     15         pass
     16 

~/CTN/nengo-loihi/nengo_loihi/simulator.py in __init__(self, network, dt, seed, model, precompute, target, progress_bar, remove_passthrough)
    364             # We could warn about this, but we want to avoid people having
    365             # to specify `precompute` unless they absolutely have to.
--> 366             self.precompute = True
    367 
    368         # Build the network into the model

~/CTN/nengo-loihi/nengo_loihi/builder/builder.py in build(self, obj, *args, **kwargs)
    152 
    153     def build(self, obj, *args, **kwargs):
--> 154         built = self.builder.build(self, obj, *args, **kwargs)
    155         if self.build_callback is not None:
    156             self.build_callback(obj)

~/CTN/nengo/nengo/builder/builder.py in build(cls, model, obj, *args, **kwargs)
    216                 "Cannot build object of type %r" % type(obj).__name__)
    217 
--> 218         return cls.builders[obj_cls](model, obj, *args, **kwargs)
    219 
    220     @classmethod

~/CTN/nengo/nengo/builder/network.py in build_network(model, network, progress)
     96         logger.debug("Network step 4: Building probes")
     97         for probe in network.probes:
---> 98             model.build(probe)
     99 
    100         if context is model.decoder_cache:

~/CTN/nengo-loihi/nengo_loihi/builder/builder.py in build(self, obj, *args, **kwargs)
    152 
    153     def build(self, obj, *args, **kwargs):
--> 154         built = self.builder.build(self, obj, *args, **kwargs)
    155         if self.build_callback is not None:
    156             self.build_callback(obj)

~/CTN/nengo/nengo/builder/builder.py in build(cls, model, obj, *args, **kwargs)
    216                 "Cannot build object of type %r" % type(obj).__name__)
    217 
--> 218         return cls.builders[obj_cls](model, obj, *args, **kwargs)
    219 
    220     @classmethod

~/CTN/nengo-loihi/nengo_loihi/builder/probe.py in build_probe(model, probe)
    148     key = probeables[probe.attr] if probe.attr in probeables else probe.attr
    149     if key is None:
--> 150         conn_probe(model, probe)
    151     else:
    152         signal_probe(model, key, probe)

~/CTN/nengo-loihi/nengo_loihi/builder/probe.py in conn_probe(model, nengo_probe)
     79     else:
     80         raise NotImplementedError(
---> 81             "Nodes cannot be onchip, connections not yet probeable")
     82 
     83     probe = Probe(key='voltage', weights=weights, synapse=nengo_probe.synapse)

NotImplementedError: Nodes cannot be onchip, connections not yet probeable
arvoelke commented 5 years ago

Here's a simpler test that fails with the same error message:

with nengo.Network() as model:
    a = nengo.Ensemble(1, 1, label="a")
    p = nengo.Probe(a[0])

with nengo_loihi.Simulator(model) as sim:
    pass