always set OpSchema in CreateNodeHelper() (#14356)

### Description
as a more generic solution to #13660, always set OpSchema in
CreateNodeHelper() so that added nodes by transformers will have
OpSchema set

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
This commit is contained in:
Yulong Wang 2023-01-27 16:56:14 -08:00 committed by GitHub
parent b5b70eaa8c
commit d9219685ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -646,6 +646,12 @@ static Node& CreateNodeHelper(onnxruntime::Graph& graph, std::string_view op_typ
graph.UpdateProducerNode(arg->Name(), node.Index());
}
#if !defined(ORT_MINIMAL_BUILD)
// add schema to make it equivalent with the other nodes in the graph created by Graph::Resolve()
// EPs may do kernel lookup during GetCapability which requires the schema
graph.SetOpSchemaFromRegistryForNode(node);
#endif
return node;
}
@ -909,18 +915,7 @@ Status TransformLayoutForEP(Graph& graph, bool& modified, const IExecutionProvid
onnx_layout_transformation::WrapTransposesAroundNode(*api_graph, *node, {&input_perm}, {&output_perm});
}
[[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
onnx_layout_transformation::SwapNodeOpTypeAndDomain(*api_graph, *node, node->OpType(), kMSInternalNHWCDomain);
modified = true;
}
}