From 2bebe6189a0481695219aa8cf47ef6d04510d218 Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Tue, 22 Nov 2022 12:26:52 -0800 Subject: [PATCH] set node schema when apply NHWC transformer (#13660) ### Description set node schema when apply NHWC transformer ### Motivation and Context The implementation in `IExecutionProvider::GetCapability()` checks node schema to determine the capability of the current EP. If NHWC graph transformer created a new channel last `Conv` node to replace the channel first `Conv` node, we need to assign the schema to the replaced node. --- .../transpose_optimizer/optimizer_api_impl.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/onnxruntime/core/optimizer/transpose_optimizer/optimizer_api_impl.cc b/onnxruntime/core/optimizer/transpose_optimizer/optimizer_api_impl.cc index b4bc905801..517fcf63de 100644 --- a/onnxruntime/core/optimizer/transpose_optimizer/optimizer_api_impl.cc +++ b/onnxruntime/core/optimizer/transpose_optimizer/optimizer_api_impl.cc @@ -909,7 +909,18 @@ Status TransformLayoutForEP(Graph& graph, bool& modified, const IExecutionProvid onnx_layout_transformation::WrapTransposesAroundNode(*api_graph, *node, {&input_perm}, {&output_perm}); } - onnx_layout_transformation::SwapNodeOpTypeAndDomain(*api_graph, *node, node->OpType(), kMSInternalNHWCDomain); + [[maybe_unused]] auto new_node_ref = + onnx_layout_transformation::SwapNodeOpTypeAndDomain(*api_graph, *node, node->OpType(), kMSInternalNHWCDomain); + +#if !defined(ORT_MINIMAL_BUILD) + // Set the schema if one is available. This keeps the node equivalent with the state of the original ONNX + // node (if possible - some replacement nodes do not have a schema). + // + Node& new_node = NodeFromApiNode(*new_node_ref); + // add schema if available. + // not guaranteed to be (compiling EP doesn't need schemas, not available in minimal build + graph.SetOpSchemaFromRegistryForNode(new_node); +#endif modified = true; } }