def stage_repeat_inline_closure(pipeline): assert pipeline.func_ir inline_pass = InlineClosureCallPass(pipeline.func_ir, pipeline.flags.auto_parallel) inline_pass.run() post_proc = postproc.PostProcessor(pipeline.func_ir) post_proc.run()
def stage_repeat_inline_closure(self): assert self.func_ir inline_pass = InlineClosureCallPass( self.func_ir, self.flags.auto_parallel) inline_pass.run() post_proc = postproc.PostProcessor(self.func_ir) post_proc.run()
def stage_inline_pass(self): """ Inline calls to locally defined closures. """ # Ensure we have an IR and type information. assert self.func_ir inline_pass = InlineClosureCallPass(self.func_ir, self.flags) inline_pass.run() # Remove all Dels, and re-run postproc post_proc = postproc.PostProcessor(self.func_ir) post_proc.run() if config.DEBUG or config.DUMP_IR: name = self.func_ir.func_id.func_qualname print(("IR DUMP: %s" % name).center(80, "-")) self.func_ir.dump()
def stage_inline_pass(self): """ Inline calls to locally defined closures. """ # Ensure we have an IR and type information. assert self.func_ir inline_pass = InlineClosureCallPass(self.func_ir, self.flags.auto_parallel) inline_pass.run() # Remove all Dels, and re-run postproc post_proc = postproc.PostProcessor(self.func_ir) post_proc.run() if config.DEBUG or config.DUMP_IR: name = self.func_ir.func_id.func_qualname print(("IR DUMP: %s" % name).center(80, "-")) self.func_ir.dump()
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 run(self): dprint_func_ir(self.func_ir, "starting hiframes") topo_order = find_topo_order(self.func_ir.blocks) for label in topo_order: new_body = [] for inst in self.func_ir.blocks[label].body: # df['col'] = arr if isinstance( inst, ir.StaticSetItem) and inst.target.name in self.df_vars: df_name = inst.target.name self.df_vars[df_name][inst.index] = inst.value self._update_df_cols() elif isinstance(inst, ir.Assign): out_nodes = self._run_assign(inst) if isinstance(out_nodes, list): new_body.extend(out_nodes) if isinstance(out_nodes, dict): label = include_new_blocks(self.func_ir.blocks, out_nodes, label, new_body) new_body = [] else: new_body.append(inst) self.func_ir.blocks[label].body = new_body self.func_ir._definitions = _get_definitions(self.func_ir.blocks) #remove_dead(self.func_ir.blocks, self.func_ir.arg_names) if config._has_h5py: io_pass = pio.PIO(self.func_ir, self.locals) io_pass.run() remove_dead(self.func_ir.blocks, self.func_ir.arg_names) DummyFlags = namedtuple('DummyFlags', 'auto_parallel') inline_pass = InlineClosureCallPass(self.func_ir, DummyFlags(True)) inline_pass.run() self.typemap, self.return_type, self.calltypes = numba_compiler.type_inference_stage( self.typingctx, self.func_ir, self.args, None) self.fix_series_filter(self.func_ir.blocks) self.func_ir._definitions = _get_definitions(self.func_ir.blocks) dprint_func_ir(self.func_ir, "after hiframes") if numba.config.DEBUG_ARRAY_OPT == 1: print("df_vars: ", self.df_vars) return
def stage_inline_pass(self): """ Inline calls to locally defined closures. """ # Ensure we have an IR and type information. assert self.func_ir # if the return type is a pyobject, there's no type info available and # no ability to resolve certain typed function calls in the array # inlining code, use this variable to indicate typed_pass = not isinstance(self.return_type, types.misc.PyObject) inline_pass = InlineClosureCallPass( self.func_ir, self.flags.auto_parallel, self.parfor_diagnostics.replaced_fns, typed_pass) inline_pass.run() # Remove all Dels, and re-run postproc post_proc = postproc.PostProcessor(self.func_ir) post_proc.run() if config.DEBUG or config.DUMP_IR: name = self.func_ir.func_id.func_qualname print(("IR DUMP: %s" % name).center(80, "-")) self.func_ir.dump()