How to get value of a Variable of type int conserving its type #261
-
I'm trying to access the value of a Here is the relevant snips of my code. The var I want to access is # Minimal process with an InPort
class P2(AbstractProcess):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.inp = InPort(shape=(1,))
self.in_data = Var(shape=(1,), init=0)
# A minimal PyProcModel implementing P2
@implements(proc=P2, protocol=LoihiProtocol)
@requires(CPU)
@tag('floating_pt')
class PyProcModelB(PyLoihiProcessModel):
inp : PyInPort = LavaPyType(PyInPort.VEC_DENSE, int)
in_data: int = LavaPyType(int, int)
def run_spk(self):
self.in_data = self.inp.recv()
dummy = self.in_data[0]
print(f"Received input data in P2: {dummy}")
print(f"Received input type in P2: {type(dummy)}")
# main
sender = P1()
recv = P2()
sender.run(RunSteps(num_steps=1), Loihi1SimCfg())
recv_data = recv.in_data.get()[0] Here you can get the full script: When running it I obtain
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
I think this is a bug, though I'm not 100%. When I look into the var access code in abstract process model, it doesn't seem there is any mechanism to propagate the dtype of a numpy array from the process model to the process, which is what you ultimately access from main. @mgkwill do you have any insight into this one? |
Beta Was this translation helpful? Give feedback.
-
@waltergallegog have your tried the same code replacing |
Beta Was this translation helpful? Give feedback.
-
I created a bug #283 |
Beta Was this translation helpful? Give feedback.
-
@waltergallegog Thanks for pointing this out and for providing a code example! |
Beta Was this translation helpful? Give feedback.
@waltergallegog have your tried the same code replacing
@tag('floating_pt')
with@tag('fixed_pt')
?