Ejemplo n.º 1
0
    def __init__(self):
        sub_rules = [
            OptimizeRuleGroup([
                InsertTranspose(),
                ReplaceConvolutionByIm2Col(),
                ReplaceDeconvolutionByCol2Im(),
                ReplaceLinearByTensordot(),
                DecomposeSoftmax(),
                FixTensordotTextureShape(),
                MergeTensordotAndElementwiseMul(),
                ConstantFolding(),
                RemoveRedundantOperator(),
                RemoveNoEffectOperator(),
                SplitTexture(),
                UnrollConcat(),
            ]),
            OptimizeRuleGroup([
                InsertTranspose(),
                InsertChannelModeConversion(),
                SimplifyChannelModeConversion(),
                ConstantFolding(),
                RemoveRedundantOperator(),
                RemoveNoEffectOperator(),
            ]),
        ]  # type: List[OptimizeRule]

        if flags.DEBUG:
            sub_rules.append(
                DumpGraph(f"cg_{config.WEBGL_MAX_TEXTURE_SIZE}_{{count}}.dot"))

        super(WebGLOptimizeRule, self).__init__(sub_rules, repeat=False)
Ejemplo n.º 2
0
    def __init__(self):
        sub_rules = [
            OptimizeRuleGroup([
                InsertTranspose(),
                ReplaceConvolutionByIm2Col(),
                ReplaceDeconvolutionByCol2Im(),
                DecomposeSoftmax(),
                ReplaceLinearBySgemm(),
                MergeSgemmAndElementwiseMul(),
                FixSGEMMTextureShape(optimize_channel_mode=False),
                ConstantFolding(),
                SplitTexture(),
            ]),
            OptimizeRuleGroup([
                InsertChannelModeConversion(),
                SimplifyElementwise(),
                RemoveRedundantOperator(),
                SimplifyChannelModeConversion(),
                FixSGEMMTextureShape(optimize_channel_mode=True),
            ]),
            AttachConcatWorkspace(),
        ]

        if flags.DEBUG:
            sub_rules.append(DumpGraph("cg{count}.dot"))

        super(WebGLOptimizeRule, self).__init__(sub_rules, repeat=False)
Ejemplo n.º 3
0
    def __init__(self):
        sub_rules = [
            OptimizeRuleGroup([
                InsertTranspose(),
                ReplaceConvolutionByIm2Col(),
                MergeSgemmAndElementwiseMul(),
                ConstantFolding(),
                ReplaceDeconvolutionByCol2Im(),
                MergeSgemmAndElementwiseMul(),
                ConstantFolding(),
                ReplaceLinearBySgemm(),
                MergeSgemmAndElementwiseMul(),
                ConstantFolding(),
                ConcatLSTMInputAndHidden(),
                RemoveRedundantOperator(),
                RemoveNoEffectOperator(),
                UpdateInplaceAttribute()
            ]),
            ElementwiseKernelFusion()
        ]

        if flags.DEBUG:
            sub_rules.append(DumpGraph("cg{count}.dot"))

        super(WebGPUOptimizeRule, self).__init__(sub_rules)
Ejemplo n.º 4
0
    def __init__(self):
        super(GeneralOptimizeRule, self).__init__()

        self.register(RemoveRedundantOperator())
        self.register(RemoveNoEffectOperator())
        self.register(ReplaceScalarAffine())
        self.register(SimplifyElementwise())
        self.register(ConcatZeroPadding())
Ejemplo n.º 5
0
    def __init__(self):
        super(WebGPUOptimizeRule, self).__init__()

        self.register(OptimizeTranspose())
        self.register(OptimizeConvolution2D())
        self.register(OptimizeDeconvolution2D())
        self.register(OptimizeLinear())
        self.register(OptimizeLSTM())
        self.register(RemoveRedundantOperator())
        self.register(MergeElementwise())
Ejemplo n.º 6
0
 def __init__(self):
     super(GeneralOptimizeRule, self).__init__([
         RemoveRedundantOperator(),
         RemoveNoEffectOperator(),
         SimplifyElementwise(),
         ConcatZeroPadding(),
         ConstantFolding(),
         Convolution2DSvdCompression(),
         ConvFilterPruning(),
         UpgradeOperatorType()
     ])
Ejemplo n.º 7
0
 def __init__(self):
     super(WebGPUOptimizeRule, self).__init__([
         OptimizeRuleGroup([
             InsertTranspose(),
             ReplaceConvolutionByIm2Col(),
             MergeSgemmAndElementwiseMul(),
             ConstantFolding(),
             ReplaceDeconvolutionByCol2Im(),
             MergeSgemmAndElementwiseMul(),
             ConstantFolding(),
             ReplaceLinearBySgemm(),
             MergeSgemmAndElementwiseMul(),
             ConstantFolding(),
             ConcatLSTMInputAndHidden(),
             RemoveRedundantOperator(),
             RemoveNoEffectOperator(),
             UpdateInplaceAttribute()
         ]),
         ElementwiseKernelFusion()
     ])