From fb310fba0c837310af40d87fc47c78586e362124 Mon Sep 17 00:00:00 2001 From: Alberto Magni <49027342+alberto-magni@users.noreply.github.com> Date: Tue, 1 Dec 2020 16:21:05 +0000 Subject: [PATCH] Avoid adding non-existent inputs to new Event nodes (#5915) During graph resolve non-existent nodes cause shape-inference failures. --- orttraining/orttraining/core/graph/pipeline_transformer.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/orttraining/orttraining/core/graph/pipeline_transformer.cc b/orttraining/orttraining/core/graph/pipeline_transformer.cc index c28e8375f9..0ce88c7629 100644 --- a/orttraining/orttraining/core/graph/pipeline_transformer.cc +++ b/orttraining/orttraining/core/graph/pipeline_transformer.cc @@ -222,7 +222,12 @@ Node& AppendEventNode( std::string& new_output_name) { // First output of the created event operator. // Outputs of "node" should be detached from its consumers. // Consumers of "node" should consume outputs of the added event operator. - std::vector node_args = node->MutableOutputDefs(); + // Avoid adding non-existent argumements as new inputs, + // this would trigger a failure in the shape inference phase of graph resolve. + std::vector node_args; + std::copy_if(node->MutableOutputDefs().begin(), node->MutableOutputDefs().end(), + std::back_inserter(node_args), + [](NodeArg* arg) { return arg->Exists(); }); // Declare outputs of the added event operator. std::vector new_node_args = CreateMirrorNodeArgs(graph, node_args);