theano.codegen([inputs], [outputs])
I would like an Op to be parametrized by a theano function f, and I would like to implement this Op's C code by calling the C version of f.
For example, how would one go about doing the following sort of thing:
def +init+(self, f): self.f = f
def c_code(self, (x,), (y,), sub):
return '''
for (int i = 0; i < 10; ++i)
{
x = %s(x);
}
''' % theano.codegen(self.f)
x = tensor.fscalar()
sqr_10 = theano_iterate_10(theano.thing_for_codegen([x], [tensor.sqr(x)]))
For example, how would one go about doing the following sort of thing:
- !python
def +init+(self, f): self.f = f
def c_code(self, (x,), (y,), sub):
return '''
for (int i = 0; i < 10; ++i)
{
x = %s(x);
}
''' % theano.codegen(self.f)
x = tensor.fscalar()
sqr_10 = theano_iterate_10(theano.thing_for_codegen([x], [tensor.sqr(x)]))
Leave a comment
The case of loop is handled by the scan op.
You can check the theano/scalar/basic.py:Composite op that do something like that but with the regular interface.
Yes a better interface could be interresting thing, but not a major prio to my understanding (otherwise other people will have commented and asked for it before my comment)
You can check the theano/scalar/basic.py:Composite op that do something like that but with the regular interface.
Yes a better interface could be interresting thing, but not a major prio to my understanding (otherwise other people will have commented and asked for it before my comment)