From 20ea008dcdc7d88340f75b120537432dcf939353 Mon Sep 17 00:00:00 2001 From: chuxing Date: Wed, 6 Jan 2021 15:52:10 +0800 Subject: [PATCH] Prevent dead wait --- ge/hybrid/model/node_item.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ge/hybrid/model/node_item.cc b/ge/hybrid/model/node_item.cc index eb00f509..dd6f1bba 100644 --- a/ge/hybrid/model/node_item.cc +++ b/ge/hybrid/model/node_item.cc @@ -163,6 +163,23 @@ Status NodeItem::ResolveDynamicState() { Status NodeItem::ResolveStaticInputsAndOutputs() { for (int i = 0; i < num_inputs; ++i) { + int origin_index = i; + if (has_optional_inputs) { + origin_index = input_desc_indices_[i]; + } + auto in_data_anchor = node->GetInDataAnchor(origin_index); + GE_CHECK_NOTNULL(in_data_anchor); + + // If no node was connected to the current input anchor + // increase num_static_input_shapes in case dead wait in ShapeInferenceState::AwaitShapesReady + if (in_data_anchor->GetPeerOutAnchor() == nullptr || + in_data_anchor->GetPeerOutAnchor()->GetOwnerNode() == nullptr) { + num_static_input_shapes++; + is_input_shape_static_.push_back(true); + GELOGD("[%s] Peer node of input[%d] is empty", NodeName().c_str(), i); + continue; + } + const auto &input_desc = MutableInputDesc(i); GE_CHECK_NOTNULL(input_desc); if (input_desc->MutableShape().IsUnknownShape()) {