mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-02 23:39:58 +00:00
Fix some unnecessary copies of the Node attributes (#1763)
This commit is contained in:
parent
52fe574fed
commit
e1a12b1760
3 changed files with 9 additions and 8 deletions
|
|
@ -225,7 +225,7 @@ FunctionImpl::FunctionImpl(const onnxruntime::Graph& graph,
|
|||
// Add node and node args into subgraph
|
||||
// The subgraph preserved the input/output tensor names
|
||||
// in the parent graph for later inlining purpose
|
||||
auto attr_map = node_in_parent_graph->GetAttributes();
|
||||
const auto& attr_map = node_in_parent_graph->GetAttributes();
|
||||
for (auto& node : onnx_func_proto_->node()) {
|
||||
std::vector<onnxruntime::NodeArg*> inputs;
|
||||
std::vector<onnxruntime::NodeArg*> outputs;
|
||||
|
|
@ -274,8 +274,9 @@ FunctionImpl::FunctionImpl(const onnxruntime::Graph& graph,
|
|||
onnxruntime::NodeAttributes new_attr_map;
|
||||
for (auto& attr : node.attribute()) {
|
||||
if (attr.has_ref_attr_name()) {
|
||||
if (attr_map.count(attr.ref_attr_name())) {
|
||||
new_attr_map[attr.name()] = attr_map[attr.ref_attr_name()];
|
||||
auto entry = attr_map.find(attr.ref_attr_name());
|
||||
if (entry != attr_map.cend()) {
|
||||
new_attr_map[attr.name()] = entry->second;
|
||||
}
|
||||
} else {
|
||||
new_attr_map[attr.name()] = attr;
|
||||
|
|
|
|||
|
|
@ -1723,7 +1723,7 @@ Status Graph::VerifyNodeAndOpMatch() {
|
|||
// Attribute verification and fill node attribute with
|
||||
// default value defined in operator definition if needed.
|
||||
// Fill node attribute with default value specified in operator definition if any.
|
||||
auto node_attributes = node.GetAttributes();
|
||||
const auto& node_attributes = node.GetAttributes();
|
||||
for (const auto& attr_def : p_op->attributes()) {
|
||||
auto node_attr_iter = node_attributes.find(attr_def.first);
|
||||
if (node_attributes.end() == node_attr_iter) {
|
||||
|
|
|
|||
|
|
@ -820,7 +820,7 @@ static void RegisterCudaKernels(KernelRegistry& kernel_registry) {
|
|||
BuildKernelCreateInfo<ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 1, 9, int32_t, Slice)>,
|
||||
BuildKernelCreateInfo<ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 1, 9, int64_t, Slice)>,
|
||||
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 10, int32_t, Slice)>,
|
||||
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 10, int64_t, Slice)>,
|
||||
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 10, int64_t, Slice)>,
|
||||
BuildKernelCreateInfo<ONNX_OPERATOR_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 9, Compress)>,
|
||||
BuildKernelCreateInfo<ONNX_OPERATOR_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 9, Flatten)>,
|
||||
BuildKernelCreateInfo<ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCudaExecutionProvider, kOnnxDomain, 7, 9, float, Upsample)>,
|
||||
|
|
@ -875,7 +875,7 @@ std::shared_ptr<KernelRegistry> CUDAExecutionProvider::GetKernelRegistry() const
|
|||
static bool RNNNeedFallbackToCPU(const onnxruntime::Node& node,
|
||||
const std::vector<std::string> activations_supported,
|
||||
const std::string& op_type) {
|
||||
auto node_attributes = node.GetAttributes();
|
||||
const auto& node_attributes = node.GetAttributes();
|
||||
// Check attributes
|
||||
for (auto& attr : node_attributes) {
|
||||
auto attr_name = attr.first;
|
||||
|
|
@ -929,7 +929,7 @@ static bool RNNNeedFallbackToCPU(const onnxruntime::Node& node,
|
|||
}
|
||||
|
||||
static bool ConvNeedFallbackToCPU(const onnxruntime::Node& node) {
|
||||
auto node_attributes = node.GetAttributes();
|
||||
const auto& node_attributes = node.GetAttributes();
|
||||
// Check attributes
|
||||
for (auto& attr : node_attributes) {
|
||||
auto attr_name = attr.first;
|
||||
|
|
@ -953,7 +953,7 @@ static bool ConvNeedFallbackToCPU(const onnxruntime::Node& node) {
|
|||
}
|
||||
|
||||
static bool CastNeedFallbackToCPU(const onnxruntime::Node& node) {
|
||||
auto node_attributes = node.GetAttributes();
|
||||
const auto& node_attributes = node.GetAttributes();
|
||||
// Check attributes
|
||||
for (auto& attr : node_attributes) {
|
||||
auto attr_name = attr.first;
|
||||
|
|
|
|||
Loading…
Reference in a new issue