27f6a6d010343d17b9984dcba9cde649bd8d7b82,src/graph_transpiler/webdnn/graph/operators/elementwise_add.py,ElementwiseAdd,fold_constance,#ElementwiseAdd#Any#,39

Before Change


        y = self.outputs["y"]
        self.remove_all()

        new_y = ConstantVariable(x0.copy().change_order(y.order).data + x1.copy().change_order(y.order).data, y.order)
        OptimizeRule.replace_variable(graph, y, new_y)

After Change


        self.attributes.add(Associative(self, ("x0", "x1")))

    def fold_constance(self, graph: Graph):
        x0 = self.inputs["x0"]  // type: ConstantVariable
        x1 = self.inputs["x1"]  // type: ConstantVariable
        y = self.outputs["y"]
        self.remove_all()

        y_new = ConstantVariable(x0.data, x0.order).change_order(y.order)
        y_new.data = y_new.data + ConstantVariable(x1.data, x1.order).change_order(y.order).data
        OptimizeRule.replace_variable(graph, y, y_new)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 5

Non-data size: 12

Instances


Project Name: mil-tokyo/webdnn
Commit Name: 27f6a6d010343d17b9984dcba9cde649bd8d7b82
Time: 2018-01-25
Author: y.kikura@gmail.com
File Name: src/graph_transpiler/webdnn/graph/operators/elementwise_add.py
Class Name: ElementwiseAdd
Method Name: fold_constance


Project Name: mil-tokyo/webdnn
Commit Name: 27f6a6d010343d17b9984dcba9cde649bd8d7b82
Time: 2018-01-25
Author: y.kikura@gmail.com
File Name: src/graph_transpiler/webdnn/graph/operators/scalar_mul.py
Class Name: ScalarMul
Method Name: fold_constance


Project Name: mil-tokyo/webdnn
Commit Name: 27f6a6d010343d17b9984dcba9cde649bd8d7b82
Time: 2018-01-25
Author: y.kikura@gmail.com
File Name: src/graph_transpiler/webdnn/graph/operators/scalar_add.py
Class Name: ScalarAdd
Method Name: fold_constance


Project Name: mil-tokyo/webdnn
Commit Name: 27f6a6d010343d17b9984dcba9cde649bd8d7b82
Time: 2018-01-25
Author: y.kikura@gmail.com
File Name: src/graph_transpiler/webdnn/graph/operators/elementwise_mul.py
Class Name: ElementwiseMul
Method Name: fold_constance


Project Name: mil-tokyo/webdnn
Commit Name: 27f6a6d010343d17b9984dcba9cde649bd8d7b82
Time: 2018-01-25
Author: y.kikura@gmail.com
File Name: src/graph_transpiler/webdnn/graph/operators/elementwise_add.py
Class Name: ElementwiseAdd
Method Name: fold_constance


Project Name: mil-tokyo/webdnn
Commit Name: 27f6a6d010343d17b9984dcba9cde649bd8d7b82
Time: 2018-01-25
Author: y.kikura@gmail.com
File Name: src/graph_transpiler/webdnn/graph/operators/elementwise_div.py
Class Name: ElementwiseDiv
Method Name: fold_constance