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; } }