@Fred, what easy things can we do on the Theano side to support performant
scalar codes?  Your two tricks above were impressive.  How can we make this
behavior default?  Should this happen on the SymPy side or the Theano side
(Theano side seems better if there is a place for it).


On Thu, Aug 8, 2013 at 4:05 PM, Aaron Meurer <asmeu...@gmail.com> wrote:

>
>
> On Thursday, August 8, 2013, Matthew Rocklin wrote:
>
>>
>>  It should be simple to translate SymPy.Piecewise to a recursive
>>>> Theano.switch (after translating SymPy.LT to theano.lt, etc.)  I'll
>>>> get on this soon.  Does this sound reasonable to you Fred?
>>>>
>>>
>>> It sound reasonable and is the first thing I suggest to try.
>>>
>>
>> Working on this now.
>>
>>  > SymPy C Codegen and Theano
>>>>
>>>> @Fred, how hard would it be to leverage SymPy's C codegen in Theano?
>>>>  This might be a lot cleaner than wrapping raw SymPy operations and might
>>>> substantially extend Theano's support of scalar expressions.  Do you have a
>>>> performant Bessel function op?  I'll bet SymPy could be made to do this
>>>> quite well.
>>>>
>>>> @Aaron / @Ondrej, if you're reading this thread could you point us to
>>>> the best place to start looking at C codegen in SymPy?  Alternatively can
>>>> you point to an active community member who would be able to do so?
>>>>
>>>>
>>> @Matt, you already did a new Theano op with C code. I think it is the
>>> only "easy" way to wrap other people c code in Theano. If the person
>>> already know this C code AND a little of Python AND NumPy C-API, it isn't
>>> very hard to a new Theano op with C code. Otherwise, doing the first such
>>> op ask to learn a few think and could ask a few days. You already did this,
>>> so you have a good idea of the work it need.
>>>
>>> Now the questions is how is done the SymPy code gen? Is just just string
>>> template that is filled with dtype and other stuff? If we can just call one
>>> SymPy function with the information of what we want and it return a string
>>> with the C code it could be relatively easy. The only questions is about
>>> how to handle the variable name to pass the information around. At worst,
>>> we wrap the sympy c code in a c function, then make a small wrapper c code
>>> that take the Theano c variable name and call this function. So not very
>>> hard as Theano provide what is needed.
>>>
>>
>> It looks like codegen is the relevant high-level api call
>>
>> In [1]: from sympy.utilities.codegen import
>>
>> In [2]: expr = sin(x)**2
>>
>> In [3]: [(c_name, c_code), (h_name, c_header)] = codegen(("f", expr),
>> 'C', 'test', header=False)
>>
>> In [4]: print c_code
>> #include "test.h"
>> #include <math.h>
>>
>> double f(double x) {
>>
>>    return pow(sin(x), 2);
>>
>> }
>>
>> The work I did rarely dealt with making and using functions.  I'll go
>> over past work and see what I can do.  Expect some calls for help though!
>>
>
> If you figure out how to do something that's under-documented, please
> document it. Our code generation needs a lot more documentation, especially
> high-level narrative documentation.
>
> Aaron Meurer
>
>
>>   --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sympy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sympy@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sympy.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to