def extract_bytecode(self, func_id): """ Extract bytecode from function """ bc = bytecode.ByteCode(func_id) if config.DUMP_BYTECODE: print(bc.dump()) return bc
def extract_bytecode(self, func): """ Extract bytecode from function """ func_attr = get_function_attributes(func) self.func = func self.func_attr = func_attr bc = bytecode.ByteCode(func=self.func) if config.DUMP_BYTECODE: print(bc.dump()) return bc
def run_frontend(func): """ Run the compiler frontend over the given Python function, and return the function's canonical Numba IR. """ # XXX make this a dedicated Pipeline? func_id = bytecode.FunctionIdentity.from_function(func) interp = interpreter.Interpreter(func_id) bc = bytecode.ByteCode(func_id=func_id) func_ir = interp.interpret(bc) post_proc = postproc.PostProcessor(func_ir) post_proc.run() return func_ir
def compile_extra(typingctx, targetctx, func, args, return_type, flags, locals): """ Args ---- - return_type Use ``None`` to indicate """ bc = bytecode.ByteCode(func=func) if config.DEBUG: print(bc.dump()) return compile_bytecode(typingctx, targetctx, bc, args, return_type, flags, locals)
def interpret(func): bc = bytecode.ByteCode(func=func) print(bc.dump()) interp = interpreter.Interpreter(bytecode=bc) interp.interpret() interp.dump() for syn in interp.syntax_info: print(syn) interp.verify() return interp
def compile_internal(typingctx, targetctx, func, args, return_type, locals={}): """Compiler entry point with compiling internal implementation within a nopython function. """ status = _CompileStatus(can_fallback=False, use_python_mode=False) lifted = () bc = bytecode.ByteCode(func=func) if config.DUMP_BYTECODE: print(bc.dump()) func_attr = get_function_attributes(func) flags = DEFAULT_FLAGS.copy() flags.set("no_compile") return _compile_core(typingctx, targetctx, bc, args, return_type, flags, locals, lifted, func_attr, status)
def run_frontend(func, inline_closures=False): """ Run the compiler frontend over the given Python function, and return the function's canonical Numba IR. If inline_closures is Truthy then closure inlining will be run """ # XXX make this a dedicated Pipeline? func_id = bytecode.FunctionIdentity.from_function(func) interp = interpreter.Interpreter(func_id) bc = bytecode.ByteCode(func_id=func_id) func_ir = interp.interpret(bc) if inline_closures: inline_pass = InlineClosureCallPass(func_ir, cpu.ParallelOptions(False), {}, False) inline_pass.run() post_proc = postproc.PostProcessor(func_ir) post_proc.run() return func_ir
def compile_extra(typingctx, targetctx, func, args, return_type, flags, locals): """ Args ---- - return_type Use ``None`` to indicate """ bc = bytecode.ByteCode(func=func) if config.DUMP_BYTECODE: print(bc.dump()) func_attr = get_function_attributes(func) return compile_bytecode(typingctx, targetctx, bc, args, return_type, flags, locals, func_attr=func_attr)
def get_ir(self, pyfunc): bc = bytecode.ByteCode(func=pyfunc) interp = interpreter.Interpreter(bc) interp.interpret() return interp