Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep original name during fusion #20097

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion onnxruntime/core/optimizer/gather_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
split_initializer_proto.add_dims(static_cast<int64_t>(split_values.size()));
split_initializer_proto.mutable_int64_data()->Add(split_values.begin(), split_values.end());
NodeArg* split_initializer_arg = &graph_utils::AddInitializer(graph, split_initializer_proto);
Node& split_node = graph.AddNode(graph.GenerateNodeName("Split"), "Split", "Split for Fused Gather nodes",
Node& split_node = graph.AddNode(nodes_to_fuse[0].get().Name() + "/GatherSliceToSplitFusion/", "Split", "Split for Fused Gather nodes",

Check warning on line 276 in onnxruntime/core/optimizer/gather_fusion.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/core/optimizer/gather_fusion.cc:276: Lines should be <= 120 characters long [whitespace/line_length] [2]
{graph.GetNodeArg(node_arg->Name()), split_initializer_arg}, split_outputs);
split_node.AddAttribute("axis", axis);
split_node.SetExecutionProviderType(nodes_to_fuse[0].get().GetExecutionProviderType());
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/optimizer/gemm_transpose_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Status GemmTransposeFusion::Apply(Graph& graph, Node& node, RewriteRuleEffect& m
nodes_to_remove.push_back(output_node);
}

Node& new_gemm_node = graph.AddNode(graph.GenerateNodeName(gemm_node.Name() + "_transformed"),
Node& new_gemm_node = graph.AddNode(graph.GenerateNodeName(gemm_node.Name() + "/GemmTransposeFusion/"),
gemm_node.OpType(),
"Fused Gemm with Transpose",
new_gemm_input_defs,
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/optimizer/layer_norm_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
}

InlinedVector<NodeArg*> layer_norm_input_defs{x_input, scale, bias};
Node& layer_norm_node = graph.AddNode(graph.GenerateNodeName("LayerNormalization"),
Node& layer_norm_node = graph.AddNode(graph.GenerateNodeName(mul_node.Name() + "/LayerNormFusion/"),
"LayerNormalization",
"fused LayerNorm subgraphs ",
layer_norm_input_defs,
Expand Down Expand Up @@ -705,7 +705,7 @@

InlinedVector<NodeArg*> layer_norm_input_defs{x_input, scale};
Node& layer_norm_node =
graph.AddNode(graph.GenerateNodeName("SimplifiedLayerNormalization"), "SimplifiedLayerNormalization",
graph.AddNode(graph.GenerateNodeName(mul_node.Name() + "/SimplifiedLayerNormFusion/"), "SimplifiedLayerNormalization",

Check warning on line 708 in onnxruntime/core/optimizer/layer_norm_fusion.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/core/optimizer/layer_norm_fusion.cc:708: Lines should be <= 120 characters long [whitespace/line_length] [2]
"fused LayerNorm subgraphs ", layer_norm_input_defs, {}, {}, kOnnxDomain);

// Get constant "epsilon" from "Add" node if available. Else, default value will be used.
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/optimizer/matmul_scale_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Status ProcessNode(
}

Node& matmul_scale_node = graph.AddNode(
graph.GenerateNodeName(node.Name() + "_FusedMatMulAndScale"),
graph.GenerateNodeName(node.Name() + "/MatMulScaleFusion/"),
"FusedMatMul",
"Fused MatMul and Scale",
fused_node_inputs,
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/core/optimizer/matmul_transpose_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@
const ONNX_NAMESPACE::TensorProto_DataType element_type =
static_cast<ONNX_NAMESPACE::TensorProto_DataType>(cast_output->TypeAsProto()->tensor_type().elem_type());
new_cast_output_type_proto.mutable_tensor_type()->set_elem_type(element_type);
auto& new_cast_output = graph.GetOrCreateNodeArg(cast_output->Name() + "_transformed", &new_cast_output_type_proto);
auto& new_cast_output = graph.GetOrCreateNodeArg(cast_output->Name() + "/MatmulTransposeFusion/", &new_cast_output_type_proto);

Check warning on line 157 in onnxruntime/core/optimizer/matmul_transpose_fusion.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/core/optimizer/matmul_transpose_fusion.cc:157: Lines should be <= 120 characters long [whitespace/line_length] [2]

const std::array new_cast_input_defs{transpose_input};
const std::array new_cast_output_defs{&new_cast_output};
const std::array new_transpose_input_defs = {&new_cast_output};
const std::array new_transpose_output_defs = {cast_output};

Node& new_cast = graph.AddNode(graph.GenerateNodeName(cast->Name() + "_transformed"),
Node& new_cast = graph.AddNode(graph.GenerateNodeName(cast->Name() + "/MatmulTransposeFusion/"),
cast->OpType(),
"Created a new Cast node to interchange Cast and Transpose nodes",
new_cast_input_defs,
Expand Down Expand Up @@ -385,7 +385,7 @@
const std::array input_defs{left_input, right_input};
const std::array output_defs{node.MutableOutputDefs()[0]};

Node& matmul_node = graph.AddNode(graph.GenerateNodeName("MatMul_With_Transpose"),
Node& matmul_node = graph.AddNode(graph.GenerateNodeName(node.Name() + "/MatmulTransposeFusion/"),
"FusedMatMul",
"fused MatMul and Transpose ",
input_defs,
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/optimizer/quick_gelu_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

NodeArg* quick_gelu_output_arg = mul_node.MutableOutputDefs()[0];
Node& quick_gelu_node =
graph.AddNode(graph.GenerateNodeName("QuickGelu"), "QuickGelu", "QuickGelu", std::array{quick_gelu_input_arg},
graph.AddNode(graph.GenerateNodeName(mul_node.Name() + "/QuickGeluFusion/"), "QuickGelu", "QuickGelu", std::array{quick_gelu_input_arg},

Check warning on line 91 in onnxruntime/core/optimizer/quick_gelu_fusion.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/core/optimizer/quick_gelu_fusion.cc:91: Lines should be <= 120 characters long [whitespace/line_length] [2]
std::array{quick_gelu_output_arg}, {}, kMSDomain);
quick_gelu_node.AddAttribute("alpha", alpha);
quick_gelu_node.SetExecutionProviderType(node.GetExecutionProviderType());
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/test/optimizer/graph_transform_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,7 @@ TEST_F(GraphTransformationTests, GemmTransposeFusion2OutputsFromTranspose) {
auto gemm_node =
std::find_if(
graph.Nodes().cbegin(), graph.Nodes().cend(),
[](const Node& node) { return node.Name() == "Gemm_transformed"; });
[](const Node& node) { return node.Name() == "Gemm/GemmTransposeFusion/"; });

auto& node = *gemm_node;
ASSERT_TRUE(node.OpType() == "Gemm");
Expand Down Expand Up @@ -2760,7 +2760,7 @@ TEST_F(GraphTransformationTests, GemmTransposeFusion2OutputsFromTransposeTo2Gemm
auto gemm1_node =
std::find_if(
graph.Nodes().cbegin(), graph.Nodes().cend(),
[](const Node& node) { return node.Name() == "Gemm1_transformed"; });
[](const Node& node) { return node.Name() == "Gemm1/GemmTransposeFusion/"; });

auto& node1 = *gemm1_node;
ASSERT_TRUE(node1.OpType() == "Gemm");
Expand All @@ -2773,7 +2773,7 @@ TEST_F(GraphTransformationTests, GemmTransposeFusion2OutputsFromTransposeTo2Gemm
auto gemm2_node =
std::find_if(
graph.Nodes().cbegin(), graph.Nodes().cend(),
[](const Node& node) { return node.Name() == "Gemm2_transformed"; });
[](const Node& node) { return node.Name() == "Gemm2/GemmTransposeFusion/"; });

auto& node2 = *gemm2_node;
ASSERT_TRUE(node2.OpType() == "Gemm");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Status ConcatReplacement::Apply(Graph& graph, Node& concat_node, RewriteRuleEffe

concat_outputs.push_back(&ip_shape_op);

Node& concat_training_node = graph.AddNode(graph.GenerateNodeName("ConcatTraining"),
Node& concat_training_node = graph.AddNode(graph.GenerateNodeName(concat_node.Name() + "/ConcatReplacement/"),
"ConcatTraining",
"Concat with extra output",
concat_inputs,
Expand Down
Loading