Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
    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()
        ]
Exemplo n.º 3
0
 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()]