Trying to Understand nengo.transforms.Convolution

Hello all. Basically my end goal is to see if I can add a groups parameter to the nengo.transforms.Convolution class in nengo.

I am looking at how this function is used inside the dl_converter here since this is where I will need to insert my modified Convolution class.

After looking through the code, I don’t really see where the actual convolution is done or how it is actually specified in the code. From what I can tell, the nengo.transforms.Convolution class only modifies the kernel shape information and specifies an output size. Can anyone give me any pointers on how I can understand what is going on and how I can modify it?

Hi @mjurado3, and welcome to the Nengo forums. :smiley:

The Nengo code base is sort of divided into two parts: the interface, and the simulator. The code you linked to is part of Nengo’s interface, and it essentially defines the API that users can use to instantiate and configure Nengo objects within their Nengo models. The code that you’ll probably want to modify is the simulation code, and to do that, you’ll want to look at the builder functions. Builder functions take parameters defined by the user (and stored in the interface objects) and create the underlying Nengo objects (signals and operators) that are used by the Nengo simulator code to run the simulation.

The builder function for the convolution transform can be found here, and the convolution logic can be found just a bit further down in the codebase.

The builder function sets up the Nengo signals that will be used by the simulator to store input, output and any intermediate values that is important to the simulation. As an example, the convolution operation requires a signal for the weights, the input value, and the output value. If your modified convolution class requires storing any additional information, you’ll need to modify this function. Otherwise, it can mostly be left the same.

The operator class contains all of the logic that the Nengo simulator runs whenever it encounters the associated object (e.g., the nengo.transforms.Convolution object) in the Nengo model. This is the code you’ll need to modify to change the behaviour of the convolution transform.

As a side note, NengoDL uses the same concept of interface code + builder code, and has it’s own builder code for the convolution transform. However, in the case of NengoDL, the builder code builds the Nengo model into native TensorFlow operators so that the Nengo code can be run in TensorFlow.

Thank you for this help. I submitted a feature request about the groups parameter and managed to add support for a groups parameter in nengo and nengo_dl in my own codebase.

If you have implemented a working implementation of the groups parameter, you can contribute to the Nengo codebase, by forking and then creating a pull request. :smiley:

1 Like

Yes, I will do that I think.

If anybody is impatient and wants to implement this in their own code without waiting see my issue post which has some hints about how to do this:

1 Like