From e8ee31bcc3584d2f7758ba013659fa273841acc5 Mon Sep 17 00:00:00 2001 From: Ye Wang <52801275+wangyems@users.noreply.github.com> Date: Thu, 22 Jul 2021 13:50:55 -0700 Subject: [PATCH] Update onnx_model_bert_tf.py (#8457) Fix a bug: when layernorm and skiplayernorm are not fused, the program will crash --- onnxruntime/python/tools/transformers/onnx_model_bert_tf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/onnxruntime/python/tools/transformers/onnx_model_bert_tf.py b/onnxruntime/python/tools/transformers/onnx_model_bert_tf.py index e05593cfff..580b106223 100644 --- a/onnxruntime/python/tools/transformers/onnx_model_bert_tf.py +++ b/onnxruntime/python/tools/transformers/onnx_model_bert_tf.py @@ -288,9 +288,8 @@ class BertOnnxModelTF(BertOnnxModel): start_nodes.extend(skip_layer_norm_nodes) start_nodes.extend(layer_norm_nodes) - graph_name = self.get_graph_by_node(start_nodes[0]).name - for normalize_node in start_nodes: + graph_name = self.get_graph_by_node(normalize_node).name # SkipLayerNormalization has two inputs, and one of them is the root input for attention. if normalize_node.op_type == 'LayerNormalization': add_before_layernorm = self.match_parent(normalize_node, 'Add', 0)