numba: numba.jit fails on sympy.lambdify functions
In the SymPy master, something has broken the ability to do numba.jit on a lambdified function.
>>> import numba
>>> from sympy import *
>>> f = lambdify(x, sin(x), 'numpy')
>>> f(1)
0.8414709848078965
>>> numba.jit(f)(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/dispatcher.py", line 287, in _compile_for_args
return self.compile(tuple(argtypes))
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/dispatcher.py", line 555, in compile
cres = self._compiler.compile(args, return_type)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/dispatcher.py", line 81, in compile
flags=flags, locals=self.locals)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 699, in compile_extra
return pipeline.compile_extra(func)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 352, in compile_extra
return self._compile_bytecode()
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 660, in _compile_bytecode
return self._compile_core()
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 647, in _compile_core
res = pm.run(self.status)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 238, in run
raise patched_exception
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 230, in run
stage()
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 366, in stage_analyze_bytecode
func_ir = translate_stage(self.func_id, self.bc)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/compiler.py", line 762, in translate_stage
return interp.interpret(bytecode)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/interpreter.py", line 97, in interpret
self.dfa.run()
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/dataflow.py", line 27, in run
self.infos[blk.offset] = self.run_on_block(blk)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/dataflow.py", line 71, in run_on_block
self.dispatch(info, inst)
File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/numba/dataflow.py", line 80, in dispatch
fn = getattr(self, fname)
AttributeError: Failed at object (analyzing bytecode)
'DataFlowAnalysis' object has no attribute 'op_LOAD_CLOSURE'
Note that you need to run this from this pull request because of another issue (we weren’t using functools.wraps).
I bisected the change in SymPy, and I think it is due to that wrapper function that we are using.
If this is not easy to fix in Numba if you could suggest a workaround that we could use in SymPy, that would be great.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 28 (25 by maintainers)
We refactored how lambdify works. It now produces a function instead of a lambda, and it no longer wraps it in a decorator. I still get the
CALL_FUNCTION_EX with **kwargs not supportederror with sympy 1.1.1, because the decorator used the standard*args, **kwargspass through semantics (https://github.com/sympy/sympy/blob/sympy-1.1.1/sympy/utilities/lambdify.py#L440).I’m curious if there are any plans, distant or otherwise, to support kwargs in
CALL_FUNCTION_EX?https://github.com/sympy/sympy/issues/20070
It looks like this works now:
Is this supposed to work now? With sympy
1.1.1and numba'0.35.0rc1+15.g24edca2I’m getting aCALL_FUNCTION_EXerror when trying to jit a lambdafied function: