-
Notifications
You must be signed in to change notification settings - Fork 67
Use LLVMDoubleVisitor #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise I think that looks good.
def Lambdify(args, exprs, bool real=True, bool llvm=False): | ||
IF HAVE_SYMENGINE_LLVM: | ||
if llvm: | ||
return LLVMDouble(args, exprs, real) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this raise an exception if llvm==True
but HAVE_SYMENGINE_LLVM
is False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, at least a warning?
We could also leave it None
and allow the user to choose default by setting an environment variable, e.g. SYMENGINE_LAMBDIFY_BACKEND
or something along those lines? (we could then run the tests suite with
that variable set to llvm
and lambda
respectively)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good idea, but llvm backend doesn't have all the features of lambda including complex support. Let's add that when llvm backend is on par with the lambda backend.
@@ -50,6 +50,15 @@ def test_Lambdify(): | |||
assert allclose(l(range(n, n+len(args))), | |||
[3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)]) | |||
|
|||
def test_Lambdify_LLVM(): | |||
if not se.have_llvm: | |||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here we can test that exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, is it a good time for me to start working on a version supporting outputs with heterogeneous shapes once this is in?
else: | ||
self.lambda_double_complex[0].call(&out[0], &inp[0]) | ||
cdef void _eval_complex(self, double complex[::1] inp, double complex[::1] out): | ||
raise ValueError("Not supported") | ||
|
||
# the two cpdef:ed methods below may use void return type | ||
# once Cython 0.23 (from 2015) is acceptable as requirement. | ||
cpdef unsafe_real(self, double[::1] inp, double[::1] out): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you now do size checking maybe the unsafe_
prefix doesn't really apply any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checking was already there in _eval
which was called previously by unsafe_real
. We can rename this to eval_real
and this would call _eval_real
(which should changed into a cpdef method)
def Lambdify(args, exprs, bool real=True, bool llvm=False): | ||
IF HAVE_SYMENGINE_LLVM: | ||
if llvm: | ||
return LLVMDouble(args, exprs, real) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, at least a warning?
We could also leave it None
and allow the user to choose default by setting an environment variable, e.g. SYMENGINE_LAMBDIFY_BACKEND
or something along those lines? (we could then run the tests suite with
that variable set to llvm
and lambda
respectively)
5a1a347
to
b492f0b
Compare
Made changes. Ready for review again |
Thanks. Once this is merged, you can start on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great! 👍
Thanks for the reviews |
+1 |
cc @bjodah