From 648bedf91a9e390fadbbabdbbb9d5239f5a9d201 Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Wed, 17 May 2023 23:24:30 -0700 Subject: [PATCH] [CoreML EP] Minor changes to allow CoreML EP to handle more nodes and models. (#15993) ### Description Minor changes to allow CoreML EP to handle more nodes and models. - Remove graph input dynamic shape check from coreml::GetSupportedNodes(). Each node input is still checked. - Add check for optional input in coreml::IsInputSupported(). If an input does not exist it should not be considered unsupported. ### Motivation and Context Some CoreML EP checks seem too strict now. --- onnxruntime/core/providers/coreml/builders/helper.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/onnxruntime/core/providers/coreml/builders/helper.cc b/onnxruntime/core/providers/coreml/builders/helper.cc index f2055aa8e8..d062d59de8 100644 --- a/onnxruntime/core/providers/coreml/builders/helper.cc +++ b/onnxruntime/core/providers/coreml/builders/helper.cc @@ -46,6 +46,11 @@ bool IsNodeSupported(const Node& node, const GraphViewer& graph_viewer, const lo } bool IsInputSupported(const NodeArg& input, const std::string& parent_name, const logging::Logger& logger) { + if (!input.Exists()) { + // optional input that is not provided + return true; + } + const auto& input_name = input.Name(); const auto* shape_proto = input.Shape(); // We do not support input with no shape @@ -86,12 +91,6 @@ std::unordered_set GetSupportedNodes(const GraphViewer& graph_viewe } #endif - const auto& graph_inputs = graph_viewer.GetInputs(); - if (std::any_of(graph_inputs.begin(), graph_inputs.end(), - [&](const NodeArg* input) { return !IsInputSupported(*input, "graph", logger); })) { - return supported_nodes; - } - for (const auto& node : graph_viewer.Nodes()) { const bool supported = IsNodeSupported(node, graph_viewer, logger); LOGS(logger, VERBOSE) << "Operator type: [" << node.OpType()