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: self._get_reverse_copies(self.func_ir.blocks[label].body) 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) self.func_ir.df_cols = self.df_cols #remove_dead(self.func_ir.blocks, self.func_ir.arg_names) dprint_func_ir(self.func_ir, "after hiframes") if numba.config.DEBUG_ARRAY_OPT == 1: print("df_vars: ", self.df_vars) return
def run(self): dprint_func_ir(self.func_ir, "starting IO") topo_order = find_topo_order(self.func_ir.blocks) for label in topo_order: new_body = [] # copies are collected before running the pass since # variables typed in locals are assigned late self._get_reverse_copies(self.func_ir.blocks[label].body) for inst in self.func_ir.blocks[label].body: if isinstance(inst, ir.Assign): inst_list = self._run_assign(inst) new_body.extend(inst_list) elif isinstance(inst, ir.StaticSetItem): inst_list = self._run_static_setitem(inst) new_body.extend(inst_list) else: new_body.append(inst) self.func_ir.blocks[label].body = new_body # iterative remove dead to make sure all extra code (e.g. df vars) is removed while remove_dead(self.func_ir.blocks, self.func_ir.arg_names, self.func_ir): pass self.func_ir._definitions = get_definitions(self.func_ir.blocks) dprint_func_ir(self.func_ir, "after IO") if debug_prints(): print("h5 files: ", self.h5_files) print("h5 dsets: ", self.h5_dsets)
def run(self): """run array shape analysis on the IR and save information in array_shape_classes, class_sizes, and array_size_vars (see __init__ comments). May generate some array shape calls if necessary. """ dprint_func_ir(self.func_ir, "starting array analysis") if config.DEBUG_ARRAY_OPT == 1: print("variable types: ", sorted(self.typemap.items())) print("call types: ", self.calltypes) topo_order = find_topo_order(self.func_ir.blocks) for label in topo_order: self._analyze_block(self.func_ir.blocks[label]) self._merge_equivalent_classes() self._cleanup_analysis_data() if config.DEBUG_ARRAY_OPT == 1: self.dump()
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 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): inner_blocks = add_offset_to_labels(out_nodes, ir_utils._max_label+1) self.func_ir.blocks.update(inner_blocks) ir_utils._max_label = max(self.func_ir.blocks.keys()) scope = self.func_ir.blocks[label].scope loc = self.func_ir.blocks[label].loc inner_topo_order = find_topo_order(inner_blocks) inner_first_label = inner_topo_order[0] inner_last_label = inner_topo_order[-1] remove_none_return_from_block(inner_blocks[inner_last_label]) new_body.append(ir.Jump(inner_first_label, loc)) self.func_ir.blocks[label].body = new_body label = ir_utils.next_label() self.func_ir.blocks[label] = ir.Block(scope, loc) inner_blocks[inner_last_label].body.append(ir.Jump(label, loc)) new_body = [] else: new_body.append(inst) self.func_ir.blocks[label].body = new_body remove_dead(self.func_ir.blocks, self.func_ir.arg_names) dprint_func_ir(self.func_ir, "after hiframes") if config.DEBUG_ARRAY_OPT==1: print("df_vars: ", self.df_vars) return
def run(self): dprint_func_ir(self.func_ir, "starting IO") topo_order = find_topo_order(self.func_ir.blocks) for label in topo_order: new_body = [] # copies are collected before running the pass since # variables typed in locals are assigned late self._get_reverse_copies(self.func_ir.blocks[label].body) for inst in self.func_ir.blocks[label].body: if isinstance(inst, ir.Assign): inst_list = self._run_assign(inst) new_body.extend(inst_list) elif isinstance(inst, ir.StaticSetItem): inst_list = self._run_static_setitem(inst) new_body.extend(inst_list) else: new_body.append(inst) self.func_ir.blocks[label].body = new_body #remove_dead(self.func_ir.blocks, self.func_ir.arg_names) dprint_func_ir(self.func_ir, "after IO") if config.DEBUG_ARRAY_OPT == 1: print("h5 files: ", self.h5_files) print("h5 dsets: ", self.h5_dsets)