From f41396eff0bdcc89c9b2bc496af49cccb1862527 Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Mon, 1 Nov 2021 15:54:21 -0700 Subject: [PATCH] Small addendum to #9624 (#9639) --- onnxruntime/core/framework/session_state.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/onnxruntime/core/framework/session_state.cc b/onnxruntime/core/framework/session_state.cc index aa9ec44f71..fdd54d913e 100644 --- a/onnxruntime/core/framework/session_state.cc +++ b/onnxruntime/core/framework/session_state.cc @@ -688,6 +688,19 @@ void SessionState::ResolveMemoryPatternFlag() { break; } } + + // For subgraphs, the implicit inputs need to meet the same crieria + // as the explicit inputs for memory pattern to be enabled + if (graph_viewer_->IsSubgraph()) { + const auto* parent_node = graph_viewer_->ParentNode(); + + for (auto* implicit_input : parent_node->ImplicitInputDefs()) { + if (!implicit_input->HasTensorOrScalarShape()) { + enable_mem_pattern_ = false; + break; + } + } + } } }