def __init__(self, device_id=None, comm=None, **kwargs): super(GPUTransformer, self).__init__(**kwargs) GPUTransformer.gpu_transformers.add(self) layout_domain_pass = GenerateLayoutDomains(self) layout_constraints_pass = GenerateLayoutConstraints(self) layout_assign_pass = AssignLayouts(layout_domain_pass, layout_constraints_pass) layout_convert_pass = AddLayoutConversions(layout_assign_pass) self.graph_passes = [ SimplePrune(), PruneContiguousPass(), GPUSubstitution(), layout_domain_pass, layout_constraints_pass, layout_assign_pass, layout_convert_pass ] # , VizPass(show_metadata="layout")] self.buffer_allocators = [] self.kernel_groups = dict() self.tensors = dict() self.argmax_tensors = dict() self.finished_transform = False self.current_buffer = None self.device_id = device_id self.runtime = None self.comm = comm
def __init__(self, **kwargs): super(CPUTransformer, self).__init__(**kwargs) self.current_computation = None self.conv_engine = CPUConvEngine() self.init_code = CPUCodeGenerator(self) self.allocate_storage_code = CPUCodeGenerator(self) self.allocate_code = CPUCodeGenerator(self) self.compute_code = CPUCodeGenerator(self) self.code = CPUCodeGenerator(self) self.globals = self.code.globals self.n_computations = 0 self.use_pinned_mem = False self.rng_seed = None self.initialize_mkldnn() add_layout_conversion = AddLayoutConversions(None) self.graph_passes = [ CPUFusion(), CPUTensorLayout(), SimplePrune(), RequiredTensorShaping(), CPUTensorShaping() ] if self.mkldnn.enabled: self.graph_passes.append(MklCreateOpDescriptors(self.mkldnn)), self.graph_passes.append( MklAddLayoutConversions(self.mkldnn, add_layout_conversion))
def __init__(self, **kwargs): super(CPUTransformer, self).__init__(**kwargs) self.device_computation = None self.conv_engine = CPUConvEngine() self.init_code = CPUCodeGenerator(self) self.allocate_storage_code = CPUCodeGenerator(self) self.allocate_code = CPUCodeGenerator(self) self.code = CPUCodeGenerator(self) self.globals = PyModule(prefix="op") self.initialize_module(self.globals) self.n_computations = 0 self.use_pinned_mem = False self.rng_seed = None self.exop_codegen_pools = CPUCodeGenerator(self) self.exop_codegen_tensor = CPUCodeGenerator(self) self.exop_codegen_tensor_view = CPUCodeGenerator(self) self.exop_codegen = CPUCodeGenerator(self) self.exop_codegen_define_length = 0 self.prefix = '' # from ngraph.transformers.passes.exnviz import ExVizPass # from ngraph.transformers.passes.verify import VerifyPass # from ngraph.transformers.passes.visualizemem import VisualizeMemPass # from ngraph.transformers.passes.dumpgraphpass import DumpGraphPass self.graph_passes = [] if self.mkldnn.enabled: self.graph_passes.append(CPUFusion()) self.graph_passes += [ # ExVizPass(view=True, filename="initial"), CPUTensorLayout(), SimplePrune(), RequiredTensorShaping(), CPUTensorShaping(), DeadCodeEliminationPass(), ] add_layout_conversion = AddLayoutConversions(None) if self.mkldnn.enabled: self.graph_passes.append( MklCreateOpDescriptors(mkldnn=self.mkldnn)), DeadCodeEliminationPass(), self.graph_passes.append( MklAddLayoutConversions(mkldnn=self.mkldnn, layoutpass=add_layout_conversion)), DeadCodeEliminationPass() self.graph_passes += [ SSAConversion(), IndexElision(), # DCE here eliminates return values. Need to figure out why. # DeadCodeEliminationPass(), LivenessPass(), MemOptimizePass(), LivenessPass(), MemLayoutPass() ]
def __init__(self, fusion=None, **kwargs): super(Transformer, self).__init__(**kwargs) self.computations = OrderedSet() self.all_results = OrderedSet() self.finalized = False self.allocated = False self.initialized = False self.opids = dict() self.fusion = fusion self.device_buffers = OrderedSet() self.cpu_initializations = [] self.init_computation = None self.graph_passes = [SimplePrune(), RequiredTensorShaping()]
def __init__(self, **kwargs): super(GPUTransformer, self).__init__(**kwargs) self.graph_passes = [ DerivPass(), SimplePrune(), RequiredTensorShaping(), GPUTensorShaping(), GPUTensorLayout(), GPUContiguousPrune() ] self.buffer_allocators = [] self.kernel_groups = dict() self.tensors = dict() self.argmax_tensors = dict() self.finished_transform = False self.current_buffer = None
def __init__(self, **kwargs): super(CPUTransformer, self).__init__(**kwargs) self.conv_engine = CPUConvEngine() self.init_code = CPUCodeGenerator() self.allocate_storage_code = CPUCodeGenerator() self.allocate_code = CPUCodeGenerator() self.compute_code = CPUCodeGenerator() self.code = CPUCodeGenerator() self.globals = self.code.globals self.n_computations = 0 self.use_pinned_mem = False self.rng_seed = None self.graph_passes = [FusionPass(), CPUTensorLayout(), SimplePrune(), RequiredTensorShaping(), CPUTensorShaping()]
def test_simpleprune_graph_pass(): base_op, simple_graph = get_simple_graph() output_graph = SimplePrune().do_pass([simple_graph]) assert output_graph.pop() is base_op
def test_simpleprune_graph_pass(): base_op, simple_graph = get_simple_graph() SimplePrune().do_pass(ops=[simple_graph]) assert simple_graph.forwarded is base_op
def test_simpleprune_graph_pass(): transformer = StubTransformer() base_op, simple_graph = get_simple_graph() SimplePrune().do_pass([simple_graph], transformer) assert simple_graph.forwarded is base_op