Implementing a custom operator in Nengo OCL


#1

Is there any sort of documentation or example of how to implement a custom operator in Nengo OCL?


#2

I believe all there is at the moment is the FAQ, which isn’t built anywhere yet.


#3

The FAQ is pretty minimal. Apart from what is mentioned there it is also neccessary to derive a new Simulator class from nengo_ocl.Simulator that implements a plan_<custom_op>(self, ops) method.

So far I managed to write my custom kernel and get it to run on the GPU. (It doesn’t give correct results yet and I still have to debug it.) Is there a more efficient way to provide data that is constant across kernel instances and for the whole duration of the simulation other than just passing in the pointer to the kernel like for the other arguments? Also I need to compute some matrix-vector multiplies first and then want to use the result in my actual kernel. Computing the matrix-vectors multiplies in each kernel instance is slower than running the pure Python code (because I’m repeating the same computation way to many times). What is the easiest way to chain two such kernels? The Simulator.plan_<op> methods seem to return a list, but if I just return two plans/kernels there, how is the order ensured? Do I have to split up the Nengo operator into two operators to be able to split up the kernel?


#4

It seems that the plans returned from Simulator.plan_<op> are executed in order?


#5

Yeah, they will be done in order, so you can count on that.