Created
May 21, 2013 13:53
-
-
Save stsievert/5619936 to your computer and use it in GitHub Desktop.
A bug with @autojit... or perhaps I'm defining my function incorrectly?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let's define it regularly | |
def findNewNumber(n): | |
newNumber = 0 | |
for i in arange(len(str(n))): | |
newNumber += int(str(n)[i])**2 | |
return newNumber | |
In [7]: run euler.py | |
In [8]: findNewNumber(44) | |
Out[8]: 32 | |
# okay, that works... | |
In [9]: # now, let's define it using @autojit | |
@autojit | |
def findNewNumber(n): | |
newNumber = 0 | |
for i in arange(len(str(n))): | |
newNumber += int(str(n)[i])**2 | |
return newNumber | |
In [6]: run euler.py | |
In [7]: findNewNumber(44) | |
/Users/scott/anaconda/lib/python2.7/site-packages/llvm/core.py:1927: UserWarning: BasicBlock can only have one terminator | |
warnings.warn("BasicBlock can only have one terminator") | |
--------------------------------------------------------------------------- | |
LLVMException Traceback (most recent call last) | |
<ipython-input-7-fe3e8f4d7408> in <module>() | |
----> 1 findNewNumber(44) | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/numbawrapper.so in numba.numbawrapper._NumbaSpecializingWrapper.__call__ (numba/numbawrapper.c:3719)() | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/wrapping/compiler.pyc in compile_from_args(self, args, kwargs) | |
67 def compile_from_args(self, args, kwargs): | |
68 signature = self.resolve_argtypes(args, kwargs) | |
---> 69 return self.compile(signature) | |
70 | |
71 def compile(self, signature): | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/wrapping/compiler.pyc in compile(self, signature) | |
82 env=self.env, **self.flags) | |
83 | |
---> 84 compiled_function = dec(self.py_func) | |
85 return compiled_function | |
86 | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in _jit_decorator(func) | |
213 assert kwargs.get('llvm_ee') is None, "Engine should never be provided" | |
214 sig, lfunc, wrapper = compile_function(env, func, argtys, restype=restype, | |
--> 215 nopython=nopython, **kwargs) | |
216 return numbawrapper.create_numba_wrapper(func, wrapper, sig, lfunc) | |
217 | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in compile_function(env, func, argtypes, restype, **kwds) | |
132 assert kwds.get('llvm_module') is None, kwds.get('llvm_module') | |
133 | |
--> 134 func_env = pipeline.compile2(env, func, restype, argtypes, **kwds) | |
135 | |
136 function_cache.register_specialization(func_env) | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/pipeline.pyc in compile2(env, func, restype, argtypes, ctypes, compile_only, **kwds) | |
134 pipeline = env.get_pipeline(kwds.get('pipeline_name', None)) | |
135 func_ast.pipeline = pipeline | |
--> 136 post_ast = pipeline(func_ast, env) | |
137 func_signature = func_env.func_signature | |
138 symtab = func_env.symtab | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/pipeline.pyc in __call__(self, ast, env) | |
181 | |
182 if self.is_composed: | |
--> 183 ast = self.transform(ast, env) | |
184 else: | |
185 try: | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/pipeline.pyc in transform(self, ast, env) | |
594 stage_tuple = (stage, utils.ast2tree(ast)) | |
595 logger.debug(pprint.pformat(stage_tuple)) | |
--> 596 ast = stage(ast, env) | |
597 return ast | |
598 | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/pipeline.pyc in _stage(ast, env) | |
579 def _stage(ast, env): | |
580 stage_obj = getattr(env.pipeline_stages, name) | |
--> 581 return _check_stage_object(stage_obj)(ast, env) | |
582 _stage.__name__ = name | |
583 stage = _stage | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/pipeline.pyc in __call__(self, ast, env) | |
184 else: | |
185 try: | |
--> 186 ast = self.transform(ast, env) | |
187 except error.NumbaError as e: | |
188 func_env = env.translation.crnt | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/pipeline.pyc in transform(self, ast, env) | |
502 **func_env.kwargs) | |
503 | |
--> 504 func_env.translator.translate() | |
505 func_env.lfunc = func_env.translator.lfunc | |
506 return ast | |
/Users/scott/anaconda/lib/python2.7/site-packages/numba/codegen/translate.pyc in translate(self) | |
329 | |
330 # Verify code generation | |
--> 331 self.llvm_module.verify() # only Module level verification checks everything. | |
332 | |
333 # Reove reference to self.llvm_module | |
/Users/scott/anaconda/lib/python2.7/site-packages/llvm/core.pyc in verify(self) | |
521 broken = api.llvm.verifyModule(self._ptr, action, errio) | |
522 if broken: | |
--> 523 raise llvm.LLVMException(errio.getvalue()) | |
524 | |
525 def to_bitcode(self, fileobj=None): | |
LLVMException: Terminator found in the middle of a basic block! | |
label %empty | |
Terminator found in the middle of a basic block! | |
label %empty11 | |
Instruction does not dominate all uses! | |
%__Numba_PyInt_AsSignedLongLong_result34 = call i64 inttoptr (i64 4336882966 to i64 ({ i64, i32* }*)*)({ i64, i32* }* %95) | |
%PyLong_FromLong_result36 = call { i64, i32* }* @PyLong_FromLong(i64 %__Numba_PyInt_AsSignedLongLong_result34) | |
Terminator found in the middle of a basic block! | |
label %empty12 | |
Instruction does not dominate all uses! | |
%newNumber_2 = phi i32 [ 0, %"no_error_643:017" ], [ %145, %"for_increment_645:4" ] | |
%145 = add i32 %newNumber_2, %144 | |
Broken module found, compilation terminated. | |
Broken module found, compilation terminated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment