Skip to content

Commit fb310fb

Browse files
Avoid adding non-existent inputs to new Event nodes (#5915)
During graph resolve non-existent nodes cause shape-inference failures.
1 parent 2d9dcc4 commit fb310fb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

orttraining/orttraining/core/graph/pipeline_transformer.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,12 @@ Node& AppendEventNode(
222222
std::string& new_output_name) { // First output of the created event operator.
223223
// Outputs of "node" should be detached from its consumers.
224224
// Consumers of "node" should consume outputs of the added event operator.
225-
std::vector<NodeArg*> node_args = node->MutableOutputDefs();
225+
// Avoid adding non-existent argumements as new inputs,
226+
// this would trigger a failure in the shape inference phase of graph resolve.
227+
std::vector<NodeArg*> node_args;
228+
std::copy_if(node->MutableOutputDefs().begin(), node->MutableOutputDefs().end(),
229+
std::back_inserter(node_args),
230+
[](NodeArg* arg) { return arg->Exists(); });
226231

227232
// Declare outputs of the added event operator.
228233
std::vector<NodeArg*> new_node_args = CreateMirrorNodeArgs(graph, node_args);

0 commit comments

Comments
 (0)