From 55fd283d20a91189659953ed268c142f8dbff570 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Tue, 31 Mar 2020 15:54:47 -0700 Subject: [PATCH] Fix a bug in FunctionImpl::FunctionImpl (#3376) 1. Fix a bug in FunctionImpl::FunctionImpl. It set wrong name for the new attribute. 2. Set error code to NOT_IMPLEMENTED if a function contains a not implemented op. --- onnxruntime/core/framework/kernel_registry_manager.cc | 4 ++-- onnxruntime/core/graph/function.cc | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/onnxruntime/core/framework/kernel_registry_manager.cc b/onnxruntime/core/framework/kernel_registry_manager.cc index 203bc7c21e..3bca51ee84 100644 --- a/onnxruntime/core/framework/kernel_registry_manager.cc +++ b/onnxruntime/core/framework/kernel_registry_manager.cc @@ -51,7 +51,7 @@ Status KernelRegistryManager::CreateKernel(const onnxruntime::Node& node, } } - return Status(ONNXRUNTIME, FAIL, create_error_message("Failed to find kernel for ")); + return Status(ONNXRUNTIME, NOT_IMPLEMENTED, create_error_message("Failed to find kernel for ")); } Status KernelRegistryManager::RegisterKernels(const ExecutionProviders& execution_providers) { @@ -119,7 +119,7 @@ Status KernelRegistryManager::SearchKernelRegistry(const onnxruntime::Node& node errormsg << "Failed to find kernel for " << node.OpType(); if (node.Op() != nullptr) errormsg << "(" << node.Op()->since_version() << ")"; if (!node.Name().empty()) errormsg << " (node " << node.Name() << ")"; - return Status(ONNXRUNTIME, FAIL, errormsg.str()); + return Status(ONNXRUNTIME, NOT_IMPLEMENTED, errormsg.str()); } } // namespace onnxruntime diff --git a/onnxruntime/core/graph/function.cc b/onnxruntime/core/graph/function.cc index 4e240be30b..4789103016 100644 --- a/onnxruntime/core/graph/function.cc +++ b/onnxruntime/core/graph/function.cc @@ -366,7 +366,9 @@ FunctionImpl::FunctionImpl(const onnxruntime::Graph& graph, if (!(*node_attr).ref_attr_name().empty()) { auto entry = attr_map.find((*node_attr).ref_attr_name()); if (entry != attr_map.cend()) { - new_attr_map[(*node_attr).name()] = entry->second; + onnx::AttributeProto attr_copy = entry->second; + attr_copy.set_name(node_attr->name()); + new_attr_map[(*node_attr).name()] = attr_copy; } } else { new_attr_map[(*node_attr).name()] = *node_attr;