def stage_array_analysis(): self.array_analysis = ArrayAnalysis(self.typingctx, self.func_ir, self.type_annotation.typemap, self.type_annotation.calltypes) self.array_analysis.run(self.func_ir.blocks) func_ir_copies.append(self.func_ir.copy()) if test_idempotence and len(func_ir_copies) > 1: test_idempotence(func_ir_copies)
def stage_array_analysis(): self.array_analysis = ArrayAnalysis(self.typingctx, self.func_ir, self.type_annotation.typemap, self.type_annotation.calltypes) self.array_analysis.run(self.func_ir.blocks) func_ir_copies.append(self.func_ir.copy()) if test_idempotence and len(func_ir_copies) > 1: test_idempotence(func_ir_copies)
def test_numba_array_analysis(self): checker = self.check_warning("numba.array_analysis", "numba.parfors.array_analysis") with checker(): import numba.array_analysis for fn in ("ArrayAnalysis", "array_analysis_extensions"): with checker(fn): getattr(numba.array_analysis, fn) # want to check this works, not that it warns with warnings.catch_warnings(): warnings.simplefilter("ignore", NumbaDeprecationWarning) from numba.array_analysis import ArrayAnalysis args = (None, ) * 4 ArrayAnalysis(*args)._analyze_op_static_getitem ArrayAnalysis(*args)._analyze_broadcast
def run_pass(self, state): state.array_analysis = ArrayAnalysis(state.typingctx, state.func_ir, state.type_annotation.typemap, state.type_annotation.calltypes) state.array_analysis.run(state.func_ir.blocks) state.func_ir_copies.append(state.func_ir.copy()) if state.test_idempotence and len(state.func_ir_copies) > 1: state.test_idempotence(state.func_ir_copies) return False
class ArrayAnalysisTester(Pipeline): @classmethod def mk_pipeline(cls, args, return_type=None, flags=None, locals={}, library=None, typing_context=None, target_context=None): if not flags: flags = Flags() flags.nrt = True if typing_context is None: typing_context = registry.cpu_target.typing_context if target_context is None: target_context = registry.cpu_target.target_context return cls(typing_context, target_context, library, args, return_type, flags, locals) def compile_to_ir(self, func, test_idempotence=None): """ Populate and run compiler pipeline """ self.func_id = bytecode.FunctionIdentity.from_function(func) try: bc = self.extract_bytecode(self.func_id) except BaseException as e: raise e self.bc = bc self.lifted = () self.lifted_from = None pm = _PipelineManager() pm.create_pipeline("nopython") if self.func_ir is None: pm.add_stage(self.stage_analyze_bytecode, "analyzing bytecode") pm.add_stage(self.stage_process_ir, "processing IR") if not self.flags.no_rewrites: if self.status.can_fallback: pm.add_stage( self.stage_preserve_ir, "preserve IR for fallback") pm.add_stage(self.stage_generic_rewrites, "nopython rewrites") pm.add_stage( self.stage_inline_pass, "inline calls to locally defined closures") pm.add_stage(self.stage_nopython_frontend, "nopython frontend") pm.add_stage(self.stage_annotate_type, "annotate type") if not self.flags.no_rewrites: pm.add_stage(self.stage_nopython_rewrites, "nopython rewrites") func_ir_copies = [] def stage_array_analysis(): self.array_analysis = ArrayAnalysis(self.typingctx, self.func_ir, self.type_annotation.typemap, self.type_annotation.calltypes) self.array_analysis.run(self.func_ir.blocks) func_ir_copies.append(self.func_ir.copy()) if test_idempotence and len(func_ir_copies) > 1: test_idempotence(func_ir_copies) pm.add_stage(stage_array_analysis, "analyze array equivalences") if test_idempotence: # Do another pass of array analysis to test idempontence pm.add_stage(stage_array_analysis, "analyze array equivalences") pm.finalize() res = pm.run(self.status) return self.array_analysis
class ArrayAnalysisTester(Pipeline): @classmethod def mk_pipeline(cls, args, return_type=None, flags=None, locals={}, library=None, typing_context=None, target_context=None): if not flags: flags = Flags() flags.nrt = True if typing_context is None: typing_context = registry.cpu_target.typing_context if target_context is None: target_context = registry.cpu_target.target_context return cls(typing_context, target_context, library, args, return_type, flags, locals) def compile_to_ir(self, func, test_idempotence=None): """ Populate and run compiler pipeline """ self.func_id = bytecode.FunctionIdentity.from_function(func) try: bc = self.extract_bytecode(self.func_id) except BaseException as e: raise e self.bc = bc self.lifted = () self.lifted_from = None pm = _PipelineManager() pm.create_pipeline("nopython") if self.func_ir is None: pm.add_stage(self.stage_analyze_bytecode, "analyzing bytecode") pm.add_stage(self.stage_process_ir, "processing IR") if not self.flags.no_rewrites: if self.status.can_fallback: pm.add_stage( self.stage_preserve_ir, "preserve IR for fallback") pm.add_stage(self.stage_generic_rewrites, "nopython rewrites") pm.add_stage( self.stage_inline_pass, "inline calls to locally defined closures") pm.add_stage(self.stage_nopython_frontend, "nopython frontend") pm.add_stage(self.stage_annotate_type, "annotate type") if not self.flags.no_rewrites: pm.add_stage(self.stage_nopython_rewrites, "nopython rewrites") func_ir_copies = [] def stage_array_analysis(): self.array_analysis = ArrayAnalysis(self.typingctx, self.func_ir, self.type_annotation.typemap, self.type_annotation.calltypes) self.array_analysis.run(self.func_ir.blocks) func_ir_copies.append(self.func_ir.copy()) if test_idempotence and len(func_ir_copies) > 1: test_idempotence(func_ir_copies) pm.add_stage(stage_array_analysis, "analyze array equivalences") if test_idempotence: # Do another pass of array analysis to test idempotence pm.add_stage(stage_array_analysis, "analyze array equivalences") pm.finalize() res = pm.run(self.status) return self.array_analysis