Skip to content

Commit 5000d36

Browse files
committed
exposed llvm lambdify opt_level in python api
1 parent ef36dc2 commit 5000d36

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

symengine/lib/symengine.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ cdef extern from "<symengine/lambda_double.h>" namespace "SymEngine":
986986
cdef extern from "<symengine/llvm_double.h>" namespace "SymEngine":
987987
cdef cppclass LLVMDoubleVisitor:
988988
LLVMDoubleVisitor() nogil
989-
void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except +
989+
void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) nogil except +
990990
void call(double *r, const double *x) nogil
991991
const string& dumps() nogil
992992
void loads(const string&) nogil

symengine/lib/symengine_wrapper.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cdef class _Lambdify(object):
3737
cdef vector[int] accum_out_sizes
3838
cdef object numpy_dtype
3939

40-
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
40+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse, int opt_level)
4141
cdef _load(self, const string &s)
4242
cpdef unsafe_real(self,
4343
double[::1] inp, double[::1] out,
@@ -50,7 +50,7 @@ cdef class _Lambdify(object):
5050
cdef class LambdaDouble(_Lambdify):
5151
cdef vector[symengine.LambdaRealDoubleVisitor] lambda_double
5252
cdef vector[symengine.LambdaComplexDoubleVisitor] lambda_double_complex
53-
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
53+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse, int opt_level)
5454
cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*)
5555
cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=*, int out_offset=*)
5656
cpdef as_scipy_low_level_callable(self)
@@ -59,7 +59,7 @@ cdef class LambdaDouble(_Lambdify):
5959
IF HAVE_SYMENGINE_LLVM:
6060
cdef class LLVMDouble(_Lambdify):
6161
cdef vector[symengine.LLVMDoubleVisitor] lambda_double
62-
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
62+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse, int opt_level)
6363
cdef _load(self, const string &s)
6464
cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*)
6565
cpdef as_scipy_low_level_callable(self)

symengine/lib/symengine_wrapper.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4469,7 +4469,7 @@ def has_symbol(obj, symbol=None):
44694469

44704470

44714471
cdef class _Lambdify(object):
4472-
def __init__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False):
4472+
def __init__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False, int opt_level):
44734473
cdef:
44744474
Basic e_
44754475
size_t ri, ci, nr, nc
@@ -4516,9 +4516,9 @@ cdef class _Lambdify(object):
45164516
for e in np.ravel(curr_expr, order=self.order):
45174517
e_ = _sympify(e)
45184518
outs_.push_back(e_.thisptr)
4519-
self._init(args_, outs_, cse)
4519+
self._init(args_, outs_, cse, opt_level)
45204520

4521-
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
4521+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse, int opt_level):
45224522
raise ValueError("Not supported")
45234523

45244524
cdef _load(self, const string &s):
@@ -4706,7 +4706,7 @@ def create_low_level_callable(lambdify, *args):
47064706

47074707

47084708
cdef class LambdaDouble(_Lambdify):
4709-
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
4709+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse, int opt_level):
47104710
if self.real:
47114711
self.lambda_double.resize(1)
47124712
self.lambda_double[0].init(args_, outs_, cse)
@@ -4751,9 +4751,9 @@ cdef class LambdaDouble(_Lambdify):
47514751

47524752
IF HAVE_SYMENGINE_LLVM:
47534753
cdef class LLVMDouble(_Lambdify):
4754-
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
4754+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse, int opt_level):
47554755
self.lambda_double.resize(1)
4756-
self.lambda_double[0].init(args_, outs_, cse)
4756+
self.lambda_double[0].init(args_, outs_, cse, opt_level)
47574757

47584758
cdef _load(self, const string &s):
47594759
self.lambda_double.resize(1)
@@ -4801,7 +4801,7 @@ IF HAVE_SYMENGINE_LLVM:
48014801
def llvm_loading_func(*args):
48024802
return LLVMDouble(args, _load=True)
48034803

4804-
def Lambdify(args, *exprs, cppbool real=True, backend=None, order='C', as_scipy=False, cse=False):
4804+
def Lambdify(args, *exprs, cppbool real=True, backend=None, order='C', as_scipy=False, cse=False, opt_level=3):
48054805
"""
48064806
Lambdify instances are callbacks that numerically evaluate their symbolic
48074807
expressions from user provided input (real or complex) into (possibly user
@@ -4851,7 +4851,7 @@ def Lambdify(args, *exprs, cppbool real=True, backend=None, order='C', as_scipy=
48514851
backend = os.getenv('SYMENGINE_LAMBDIFY_BACKEND', "lambda")
48524852
if backend == "llvm":
48534853
IF HAVE_SYMENGINE_LLVM:
4854-
ret = LLVMDouble(args, *exprs, real=real, order=order, cse=cse)
4854+
ret = LLVMDouble(args, *exprs, real=real, order=order, cse=cse, opt_level=opt_level)
48554855
if as_scipy:
48564856
return ret.as_scipy_low_level_callable()
48574857
return ret

0 commit comments

Comments
 (0)