deprecate frontend layernorm postpass (#4372)

This commit is contained in:
Bowen Bao 2020-07-01 13:06:03 -07:00 committed by GitHub
parent 7fea332f93
commit 7ec9a73202
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View file

@ -17,7 +17,6 @@ def run_postprocess(model):
# this post pass is not required for pytorch > 1.6
model = fuse_softmaxNLL_to_softmaxCE(model)
model = layer_norm_transform(model)
model = fix_expand_shape(model)
model = fix_expand_shape_pt_1_5(model)
return model
@ -207,21 +206,23 @@ def add_const(model, name, output, t_value = None, f_value = None):
return const_node
def layer_norm_transform(model):
# DEPRECATED: This pass is no longer needed as the transform is handled at the backend.
# Converting below subgraph
#
# input
# |
# ReduceMean
# __|_____
# | |
# Sub Sub
# | |
# | (optional) Cast
# | |
# |
# Sub Constant
# _||_____ |
# | | |
# | | |
# | (optional) Cast (optional) Cast
# | | |
# | | ____________________|
# | | |
# | Pow
# | |
# | (optional) Cast
# | |
# | ReduceMean
# | |
# | Add

View file

@ -102,7 +102,7 @@ class Test_PostPasses(unittest.TestCase):
count_layer_norm = self.count_nodes(onnx_model, "LayerNormalization")
count_nodes = self.count_all_nodes(onnx_model)
assert count_layer_norm == 1
assert count_layer_norm == 0
assert count_nodes == 3
def test_expand(self):
@ -199,7 +199,7 @@ class Test_PostPasses(unittest.TestCase):
def _bert_helper(self, onnx_model):
# count layer_norm
count_layer_norm = self.count_nodes(onnx_model, "LayerNormalization")
assert count_layer_norm == 12
assert count_layer_norm == 0
# get expand node and check output shape
expand_nodes = self.find_nodes(onnx_model, "Expand")