Skip to content

Question: How to Implement an InPort That Concatenates Signals from Multiple OutPorts? #907

Answered by kds300
jcrvz asked this question in Q&A
Discussion options

You must be logged in to vote

After some playing around with Python's __new__ method, I created a prototype class for dynamically creating a concatenation process.

The classes AbstractConcatenator and PyAbstractConcatenatorModel are the actual Lava process and model. The classes Concatenator and PyConcatenatorModel use __new__ to dynamically create subclasses of the process and model, then add the required ports before creating the process and model. The prototype only supports concatenating N imports of shape (1,) to a single output of shape (N,). It's only a proof of concept, but I think it should be straightforward to extend it to other inputs.

Here's the code for the prototype:

"""Script demonstrating dynamically …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@jcrvz
Comment options

@kds300
Comment options

@kds300
Comment options

Answer selected by jcrvz
@jcrvz
Comment options

@kds300
Comment options

@kds300
Comment options

@jcrvz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants