From 0c5f4924937a6d9556e99a3fb59b33f9cc7b35a6 Mon Sep 17 00:00:00 2001 From: cao lei Date: Wed, 28 Jun 2023 15:43:19 -0700 Subject: [PATCH] remove AllocatorMgr class (#16509) ### Description Remove AllocatorManager class ### Motivation and Context After the refactor PR #15833 is in, AllocatorManager class is not referenced anymore. --- cmake/onnxruntime_common.cmake | 4 +- .../core/framework/execution_provider.h | 2 +- onnxruntime/core/framework/allocator.cc | 1 - .../{allocatormgr.cc => allocator_utils.cc} | 41 +------------------ .../{allocatormgr.h => allocator_utils.h} | 19 --------- .../framework/prepacked_weights_container.cc | 2 +- onnxruntime/core/framework/tensor.cc | 1 - .../providers/acl/acl_execution_provider.h | 1 - .../armnn/armnn_execution_provider.h | 1 - .../core/providers/cann/cann_allocator.cc | 1 - .../providers/cann/cann_execution_provider.h | 1 - .../coreml/coreml_execution_provider.cc | 1 - .../providers/cpu/cpu_execution_provider.h | 1 - .../core/providers/cuda/cuda_allocator.cc | 1 - .../providers/cuda/cuda_execution_provider.h | 1 - .../src/GraphTransformer.h | 1 - .../core/providers/js/js_execution_provider.h | 1 - .../core/providers/migraphx/hip_allocator.cc | 1 - .../migraphx/migraphx_execution_provider.h | 1 - .../migraphx_execution_provider_utils.h | 1 - .../nnapi_builtin/nnapi_execution_provider.cc | 1 - .../rknpu/rknpu_execution_provider.cc | 1 - .../core/providers/rocm/rocm_allocator.cc | 1 - .../providers/rocm/rocm_execution_provider.h | 1 - .../providers/shared_library/provider_api.h | 1 - .../provider_bridge_provider.cc | 8 ---- .../shared_library/provider_interfaces.h | 5 --- .../core/providers/tvm/tvm_allocator.cc | 1 - .../webnn/webnn_execution_provider.cc | 1 - .../xnnpack/xnnpack_execution_provider.h | 1 - .../core/providers/xnnpack/xnnpack_init.cc | 1 - onnxruntime/core/session/environment.cc | 2 +- onnxruntime/core/session/inference_session.cc | 1 - .../core/session/provider_bridge_ort.cc | 8 +--- .../python/onnxruntime_pybind_mlvalue.h | 1 - .../test/framework/TestAllocatorManager.cc | 1 - onnxruntime/test/framework/allocator_test.cc | 1 - onnxruntime/test/framework/bfc_arena_test.cc | 2 +- .../framework/insert_cast_transformer_test.cc | 1 - onnxruntime/test/framework/tensor_test.cc | 1 - onnxruntime/test/framework/test_utils.h | 1 - .../cuda/test_cases/allocator_cuda_test.cc | 2 +- .../internal_testing_execution_provider.cc | 2 +- .../providers/tensorrt/tensorrt_basic_test.cc | 7 ---- .../test/quantization/quantization_test.cc | 1 - winml/lib/Common/inc/onnx.h | 4 +- winml/test/common/protobufHelpers.cpp | 2 +- 47 files changed, 13 insertions(+), 129 deletions(-) rename onnxruntime/core/framework/{allocatormgr.cc => allocator_utils.cc} (67%) rename onnxruntime/core/framework/{allocatormgr.h => allocator_utils.h} (64%) diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake index 73126be0d2..313b0d5820 100644 --- a/cmake/onnxruntime_common.cmake +++ b/cmake/onnxruntime_common.cmake @@ -22,8 +22,8 @@ set(onnxruntime_common_src_patterns "${ONNXRUNTIME_ROOT}/core/platform/telemetry.cc" "${ONNXRUNTIME_ROOT}/core/platform/logging/make_platform_default_log_sink.h" "${ONNXRUNTIME_ROOT}/core/platform/logging/make_platform_default_log_sink.cc" - "$(ONNXRUNTIME_ROOT}/core/quantization/*.h" - "$(ONNXRUNTIME_ROOT}/core/quantization/*.cc" + "${ONNXRUNTIME_ROOT}/core/quantization/*.h" + "${ONNXRUNTIME_ROOT}/core/quantization/*.cc" ) if(WIN32) diff --git a/include/onnxruntime/core/framework/execution_provider.h b/include/onnxruntime/core/framework/execution_provider.h index b2769df718..ea4f52f996 100644 --- a/include/onnxruntime/core/framework/execution_provider.h +++ b/include/onnxruntime/core/framework/execution_provider.h @@ -26,7 +26,7 @@ class Node; #include "core/common/basic_types.h" #include "core/common/profiler_common.h" -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "core/framework/func_api.h" #include "core/framework/provider_options.h" #include "core/framework/framework_provider_common.h" diff --git a/onnxruntime/core/framework/allocator.cc b/onnxruntime/core/framework/allocator.cc index af812bb8c9..ceb3b3bbd7 100644 --- a/onnxruntime/core/framework/allocator.cc +++ b/onnxruntime/core/framework/allocator.cc @@ -3,7 +3,6 @@ #include "core/common/safeint.h" #include "core/framework/allocator.h" -#include "core/framework/allocatormgr.h" #include "core/mlas/inc/mlas.h" #include "core/framework/utils.h" #include "core/session/ort_apis.h" diff --git a/onnxruntime/core/framework/allocatormgr.cc b/onnxruntime/core/framework/allocator_utils.cc similarity index 67% rename from onnxruntime/core/framework/allocatormgr.cc rename to onnxruntime/core/framework/allocator_utils.cc index 44e0e9c4e8..7493ac7d0a 100644 --- a/onnxruntime/core/framework/allocatormgr.cc +++ b/onnxruntime/core/framework/allocator_utils.cc @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include #include @@ -15,19 +15,6 @@ namespace onnxruntime { using namespace common; -namespace { -int32_t MakeKey(OrtMemType mem_type, OrtDevice device) { - // shorten device id so we can fit everything - uint8_t short_device = narrow(device.Id()); - // and convert mem_type. OrtMemType weirdly uses -2 as the first value so we offset by that before narrowing - uint8_t ort_mem_type = narrow(mem_type + 2); - - // NOTE: OrtMemType is the type of memory for a kernel's input/output - // OrtDevice.MemType is the device memory type. - return int32_t(device.Type()) << 24 | int32_t(device.MemType()) << 16 | short_device << 8 | ort_mem_type; -} -} // namespace - AllocatorPtr CreateAllocator(const AllocatorCreationInfo& info) { auto device_allocator = info.device_alloc_factory(info.device_id); @@ -88,30 +75,4 @@ AllocatorPtr CreateAllocator(const AllocatorCreationInfo& info) { } } -// Update allocator in the provider if already present; ignore if not. -void AllocatorManager::ReplaceAllocator(AllocatorPtr allocator) { - const auto& info = allocator->Info(); - auto iter = allocators_.find(MakeKey(info.mem_type, info.device)); - if (iter != allocators_.end()) { - iter->second = allocator; - } -} - -void AllocatorManager::InsertAllocator(AllocatorPtr allocator) { - const OrtMemoryInfo& info = allocator->Info(); - int32_t key = MakeKey(info.mem_type, info.device); - auto iter = allocators_.find(key); - if (iter != allocators_.end()) { - ORT_THROW("Duplicate allocator for OrtMemType:", info.mem_type, " device:", info.device.ToString(), - " Existing allocator: ", iter->second->Info().name, - " New allocator: ", allocator->Info().name); - } - - allocators_[key] = allocator; -} - -AllocatorPtr AllocatorManager::GetAllocator(OrtMemType mem_type, OrtDevice device) const { - auto iter = allocators_.find(MakeKey(mem_type, device)); - return iter != allocators_.end() ? iter->second : nullptr; -} } // namespace onnxruntime diff --git a/onnxruntime/core/framework/allocatormgr.h b/onnxruntime/core/framework/allocator_utils.h similarity index 64% rename from onnxruntime/core/framework/allocatormgr.h rename to onnxruntime/core/framework/allocator_utils.h index 56ea4e443f..7dda1d1a6f 100644 --- a/onnxruntime/core/framework/allocatormgr.h +++ b/onnxruntime/core/framework/allocator_utils.h @@ -42,23 +42,4 @@ struct AllocatorCreationInfo { // Valid values can be found in onnxruntime_c_api.h. AllocatorPtr CreateAllocator(const AllocatorCreationInfo& info); -// Used for sharing allocators across EPs. e.g. CUDA with TensorRT, CPU with XNNPACK -// NOTE: This isn't managing the lifetime of the allocators (they're all in shared_ptr instances anyway). -// It really just provides a way to collect and pass around allocators between the calls to -// IExecutionProvider::RegisterAllocator for each registered EP. Once those calls complete it is no longer needed. -class AllocatorManager { - // - public: - AllocatorManager() = default; - void InsertAllocator(AllocatorPtr allocator); - void ReplaceAllocator(AllocatorPtr allocator); - // Get an allocator for the device. Return nullptr if it doesn't exist - AllocatorPtr GetAllocator(OrtMemType mem_type, OrtDevice device) const; - - private: - // key from OrtMemType+OrtDevice mapped to AllocatorPtr - using AllocatorMap = std::unordered_map; - AllocatorMap allocators_; -}; - } // namespace onnxruntime diff --git a/onnxruntime/core/framework/prepacked_weights_container.cc b/onnxruntime/core/framework/prepacked_weights_container.cc index 8b6f146dff..b6d44dd248 100644 --- a/onnxruntime/core/framework/prepacked_weights_container.cc +++ b/onnxruntime/core/framework/prepacked_weights_container.cc @@ -2,7 +2,7 @@ // Licensed under the MIT License. #include "core/framework/prepacked_weights_container.h" -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" namespace onnxruntime { diff --git a/onnxruntime/core/framework/tensor.cc b/onnxruntime/core/framework/tensor.cc index af3bad3085..a9e5038e19 100644 --- a/onnxruntime/core/framework/tensor.cc +++ b/onnxruntime/core/framework/tensor.cc @@ -5,7 +5,6 @@ #include #include "core/common/safeint.h" -#include "core/framework/allocatormgr.h" #include "core/framework/data_types.h" #include "core/framework/ort_value.h" #include "core/framework/utils.h" diff --git a/onnxruntime/core/providers/acl/acl_execution_provider.h b/onnxruntime/core/providers/acl/acl_execution_provider.h index 587d28e47c..126656e095 100755 --- a/onnxruntime/core/providers/acl/acl_execution_provider.h +++ b/onnxruntime/core/providers/acl/acl_execution_provider.h @@ -4,7 +4,6 @@ #pragma once -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" #include "core/graph/constants.h" diff --git a/onnxruntime/core/providers/armnn/armnn_execution_provider.h b/onnxruntime/core/providers/armnn/armnn_execution_provider.h index 5728ec906a..16b770ecfa 100755 --- a/onnxruntime/core/providers/armnn/armnn_execution_provider.h +++ b/onnxruntime/core/providers/armnn/armnn_execution_provider.h @@ -4,7 +4,6 @@ #pragma once -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" #include "core/graph/constants.h" diff --git a/onnxruntime/core/providers/cann/cann_allocator.cc b/onnxruntime/core/providers/cann/cann_allocator.cc index 7f9f9e2ffd..060afeb067 100644 --- a/onnxruntime/core/providers/cann/cann_allocator.cc +++ b/onnxruntime/core/providers/cann/cann_allocator.cc @@ -6,7 +6,6 @@ #include "core/providers/shared_library/provider_api.h" #include "core/providers/cann/cann_call.h" #include "core/providers/cann/cann_allocator.h" -#include "core/framework/allocatormgr.h" #include "core/providers/cann/npu_data_transfer.h" namespace onnxruntime { diff --git a/onnxruntime/core/providers/cann/cann_execution_provider.h b/onnxruntime/core/providers/cann/cann_execution_provider.h index 418c576965..10b6a78068 100644 --- a/onnxruntime/core/providers/cann/cann_execution_provider.h +++ b/onnxruntime/core/providers/cann/cann_execution_provider.h @@ -10,7 +10,6 @@ #include #include "core/providers/shared_library/provider_api.h" -#include "core/framework/allocatormgr.h" #include "core/framework/arena_extend_strategy.h" #include "core/framework/execution_provider.h" #include "core/platform/ort_mutex.h" diff --git a/onnxruntime/core/providers/coreml/coreml_execution_provider.cc b/onnxruntime/core/providers/coreml/coreml_execution_provider.cc index 1003c26577..37c578624c 100644 --- a/onnxruntime/core/providers/coreml/coreml_execution_provider.cc +++ b/onnxruntime/core/providers/coreml/coreml_execution_provider.cc @@ -3,7 +3,6 @@ #include "core/providers/coreml/coreml_execution_provider.h" -#include "core/framework/allocatormgr.h" #include "core/framework/compute_capability.h" #include "core/graph/graph_viewer.h" #include "core/providers/partitioning_utils.h" diff --git a/onnxruntime/core/providers/cpu/cpu_execution_provider.h b/onnxruntime/core/providers/cpu/cpu_execution_provider.h index 1cba27db42..89d2deb903 100644 --- a/onnxruntime/core/providers/cpu/cpu_execution_provider.h +++ b/onnxruntime/core/providers/cpu/cpu_execution_provider.h @@ -3,7 +3,6 @@ #pragma once -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" #include "core/graph/constants.h" diff --git a/onnxruntime/core/providers/cuda/cuda_allocator.cc b/onnxruntime/core/providers/cuda/cuda_allocator.cc index ea628fa8c8..314aa1062f 100644 --- a/onnxruntime/core/providers/cuda/cuda_allocator.cc +++ b/onnxruntime/core/providers/cuda/cuda_allocator.cc @@ -3,7 +3,6 @@ #include "cuda_allocator.h" #include "cuda_common.h" -#include "core/framework/allocatormgr.h" #include "gpu_data_transfer.h" namespace onnxruntime { diff --git a/onnxruntime/core/providers/cuda/cuda_execution_provider.h b/onnxruntime/core/providers/cuda/cuda_execution_provider.h index eabd586b09..c9e510b7f4 100644 --- a/onnxruntime/core/providers/cuda/cuda_execution_provider.h +++ b/onnxruntime/core/providers/cuda/cuda_execution_provider.h @@ -6,7 +6,6 @@ #include #include -#include "core/framework/allocatormgr.h" #include "core/framework/arena_extend_strategy.h" #include "core/framework/execution_provider.h" #include "core/platform/ort_mutex.h" diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/GraphTransformer.h b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/GraphTransformer.h index dfcb3bd835..a7f8186fb3 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/GraphTransformer.h +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/GraphTransformer.h @@ -4,7 +4,6 @@ #pragma once // Lotus framework headers for onnxruntime::IExecutionProvider (not part of the operator ABI). #include "core/common/logging/logging.h" -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" #include "core/framework/op_kernel.h" #include "core/optimizer/graph_transformer.h" diff --git a/onnxruntime/core/providers/js/js_execution_provider.h b/onnxruntime/core/providers/js/js_execution_provider.h index b06cfa0a74..091aa29046 100644 --- a/onnxruntime/core/providers/js/js_execution_provider.h +++ b/onnxruntime/core/providers/js/js_execution_provider.h @@ -4,7 +4,6 @@ #pragma once -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" #include "core/graph/constants.h" #include "core/providers/providers.h" diff --git a/onnxruntime/core/providers/migraphx/hip_allocator.cc b/onnxruntime/core/providers/migraphx/hip_allocator.cc index a7737c4b15..53f10e318e 100644 --- a/onnxruntime/core/providers/migraphx/hip_allocator.cc +++ b/onnxruntime/core/providers/migraphx/hip_allocator.cc @@ -7,7 +7,6 @@ #include "core/common/status.h" #include "core/framework/float16.h" #include "core/common/status.h" -#include "core/framework/allocatormgr.h" #include "gpu_data_transfer.h" namespace onnxruntime { diff --git a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.h b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.h index 17ac284dfb..1f591f9a1c 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.h +++ b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.h @@ -3,7 +3,6 @@ #pragma once -#include "core/framework/allocatormgr.h" #include "core/framework/arena_extend_strategy.h" #include "core/framework/execution_provider.h" #include "core/platform/ort_mutex.h" diff --git a/onnxruntime/core/providers/migraphx/migraphx_execution_provider_utils.h b/onnxruntime/core/providers/migraphx/migraphx_execution_provider_utils.h index 16d5331539..fb0be15986 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_execution_provider_utils.h +++ b/onnxruntime/core/providers/migraphx/migraphx_execution_provider_utils.h @@ -3,7 +3,6 @@ #pragma once #include "core/session/onnxruntime_cxx_api.h" -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" namespace onnxruntime { diff --git a/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc b/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc index 9551483998..57a8c86660 100644 --- a/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc +++ b/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc @@ -6,7 +6,6 @@ #include "core/common/common.h" #include "core/common/logging/logging.h" #include "core/common/string_utils.h" -#include "core/framework/allocatormgr.h" #include "core/framework/compute_capability.h" #include "core/graph/graph_viewer.h" #include "core/platform/env.h" diff --git a/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc b/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc index 28a8110041..64d8f23584 100644 --- a/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc +++ b/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc @@ -9,7 +9,6 @@ #include #include "rknpu_execution_provider.h" #include "core/common/logging/logging.h" -#include "core/framework/allocatormgr.h" #include "core/framework/compute_capability.h" #include "core/session/onnxruntime_cxx_api.h" #include "core/session/inference_session.h" diff --git a/onnxruntime/core/providers/rocm/rocm_allocator.cc b/onnxruntime/core/providers/rocm/rocm_allocator.cc index 14171f9d85..84337b66b9 100644 --- a/onnxruntime/core/providers/rocm/rocm_allocator.cc +++ b/onnxruntime/core/providers/rocm/rocm_allocator.cc @@ -3,7 +3,6 @@ #include "rocm_allocator.h" #include "rocm_common.h" -#include "core/framework/allocatormgr.h" #include "gpu_data_transfer.h" namespace onnxruntime { diff --git a/onnxruntime/core/providers/rocm/rocm_execution_provider.h b/onnxruntime/core/providers/rocm/rocm_execution_provider.h index 3942d9c3a1..3e86afb7d6 100644 --- a/onnxruntime/core/providers/rocm/rocm_execution_provider.h +++ b/onnxruntime/core/providers/rocm/rocm_execution_provider.h @@ -6,7 +6,6 @@ #include #include -#include "core/framework/allocatormgr.h" #include "core/framework/arena_extend_strategy.h" #include "core/framework/execution_provider.h" #include "core/platform/ort_mutex.h" diff --git a/onnxruntime/core/providers/shared_library/provider_api.h b/onnxruntime/core/providers/shared_library/provider_api.h index ad58bfef11..384c9308d6 100644 --- a/onnxruntime/core/providers/shared_library/provider_api.h +++ b/onnxruntime/core/providers/shared_library/provider_api.h @@ -22,7 +22,6 @@ #include "core/common/type_list.h" #include "core/common/logging/severity.h" #include "core/framework/allocator.h" -#include "core/framework/allocatormgr.h" #include "core/framework/float8.h" #include "core/framework/float16.h" #include "core/framework/tensor_shape.h" diff --git a/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc b/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc index 87561218fa..e4f84bcb20 100644 --- a/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc +++ b/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc @@ -116,14 +116,6 @@ AllocatorPtr CreateAllocator(const AllocatorCreationInfo& info) { return g_host->CreateAllocator(info); } -void AllocatorManager::InsertAllocator(AllocatorPtr allocator) { - return g_host->AllocatorManager__InsertAllocator(this, allocator); -} - -AllocatorPtr AllocatorManager::GetAllocator(OrtMemType mem_type, OrtDevice device) const { - return g_host->AllocatorManager__GetAllocator(this, mem_type, device); -} - template <> MLDataType DataTypeImpl::GetType() { return Provider_GetHost()->DataTypeImpl__GetType_Tensor(); } #if !defined(DISABLE_SPARSE_TENSORS) diff --git a/onnxruntime/core/providers/shared_library/provider_interfaces.h b/onnxruntime/core/providers/shared_library/provider_interfaces.h index 759fa22843..966394e34f 100644 --- a/onnxruntime/core/providers/shared_library/provider_interfaces.h +++ b/onnxruntime/core/providers/shared_library/provider_interfaces.h @@ -914,11 +914,6 @@ struct ProviderHost { virtual void TensorSeq__Add(TensorSeq* p, Tensor&& tensor) = 0; virtual void TensorSeq__Reserve(TensorSeq* p, size_t capacity) = 0; - // AllocatorManager - virtual void AllocatorManager__InsertAllocator(AllocatorManager* p, AllocatorPtr allocator) = 0; - virtual AllocatorPtr AllocatorManager__GetAllocator(const AllocatorManager* p, - OrtMemType mem_type, OrtDevice device) = 0; - #if defined(ENABLE_TRAINING) && defined(ORT_USE_NCCL) virtual training::DistributedRunContext& GetDistributedRunContextInstance() = 0; #endif diff --git a/onnxruntime/core/providers/tvm/tvm_allocator.cc b/onnxruntime/core/providers/tvm/tvm_allocator.cc index 746ba7818d..4b68f6432e 100644 --- a/onnxruntime/core/providers/tvm/tvm_allocator.cc +++ b/onnxruntime/core/providers/tvm/tvm_allocator.cc @@ -4,7 +4,6 @@ #include #include "tvm_allocator.h" -#include "core/framework/allocatormgr.h" #include "core/framework/session_state.h" #include "xpu_data_transfer.h" diff --git a/onnxruntime/core/providers/webnn/webnn_execution_provider.cc b/onnxruntime/core/providers/webnn/webnn_execution_provider.cc index fe8dd92200..26c739e9a1 100644 --- a/onnxruntime/core/providers/webnn/webnn_execution_provider.cc +++ b/onnxruntime/core/providers/webnn/webnn_execution_provider.cc @@ -4,7 +4,6 @@ #include "webnn_execution_provider.h" -#include "core/framework/allocatormgr.h" #include "core/framework/compute_capability.h" #include "core/framework/memcpy.h" #include "core/framework/kernel_registry.h" diff --git a/onnxruntime/core/providers/xnnpack/xnnpack_execution_provider.h b/onnxruntime/core/providers/xnnpack/xnnpack_execution_provider.h index 8aac4ecc6f..395dc2f900 100644 --- a/onnxruntime/core/providers/xnnpack/xnnpack_execution_provider.h +++ b/onnxruntime/core/providers/xnnpack/xnnpack_execution_provider.h @@ -4,7 +4,6 @@ #pragma once -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" #include "core/graph/constants.h" #include "core/providers/providers.h" diff --git a/onnxruntime/core/providers/xnnpack/xnnpack_init.cc b/onnxruntime/core/providers/xnnpack/xnnpack_init.cc index 92b82510dd..27634a8b70 100644 --- a/onnxruntime/core/providers/xnnpack/xnnpack_init.cc +++ b/onnxruntime/core/providers/xnnpack/xnnpack_init.cc @@ -1,7 +1,6 @@ #include "xnnpack_init.h" -#include "core/framework/allocatormgr.h" #include "core/graph/constants.h" #include "xnnpack.h" diff --git a/onnxruntime/core/session/environment.cc b/onnxruntime/core/session/environment.cc index 8ab308bc27..9732816d82 100644 --- a/onnxruntime/core/session/environment.cc +++ b/onnxruntime/core/session/environment.cc @@ -3,7 +3,7 @@ #include "core/session/environment.h" #include "core/session/allocator_adapters.h" -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "core/graph/constants.h" #include "core/graph/op.h" diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index 248d433728..7c240efbb3 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -17,7 +17,6 @@ #include "core/common/path_string.h" #include "core/flatbuffers/flatbuffers_utils.h" #include "core/flatbuffers/ort_format_version.h" -#include "core/framework/allocatormgr.h" #include "core/framework/bfc_arena.h" #include "core/framework/error_code_helper.h" #include "core/framework/execution_frame.h" diff --git a/onnxruntime/core/session/provider_bridge_ort.cc b/onnxruntime/core/session/provider_bridge_ort.cc index ded2d61d07..b8da4b020b 100644 --- a/onnxruntime/core/session/provider_bridge_ort.cc +++ b/onnxruntime/core/session/provider_bridge_ort.cc @@ -5,7 +5,7 @@ // It implements onnxruntime::ProviderHost #include "core/common/inlined_containers.h" -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "core/framework/compute_capability.h" #include "core/framework/data_types.h" #include "core/framework/data_transfer_manager.h" @@ -1057,12 +1057,6 @@ struct ProviderHostImpl : ProviderHost { void TensorSeq__Add(TensorSeq* p, Tensor&& tensor) override { p->Add(std::move(tensor)); } void TensorSeq__Reserve(TensorSeq* p, size_t capacity) override { p->Reserve(capacity); } - // AllocatorManager (direct) - void AllocatorManager__InsertAllocator(AllocatorManager* p, AllocatorPtr allocator) override { p->AllocatorManager::InsertAllocator(allocator); } - AllocatorPtr AllocatorManager__GetAllocator(const AllocatorManager* p, OrtMemType mem_type, OrtDevice device) override { - return p->AllocatorManager::GetAllocator(mem_type, device); - }; - #if defined(ENABLE_TRAINING) && defined(ORT_USE_NCCL) training::DistributedRunContext& GetDistributedRunContextInstance() override { return training::DistributedRunContext::GetInstance(); } #endif diff --git a/onnxruntime/python/onnxruntime_pybind_mlvalue.h b/onnxruntime/python/onnxruntime_pybind_mlvalue.h index e1eb9aff86..3c29a33f70 100644 --- a/onnxruntime/python/onnxruntime_pybind_mlvalue.h +++ b/onnxruntime/python/onnxruntime_pybind_mlvalue.h @@ -12,7 +12,6 @@ #include "core/common/logging/logging.h" #include "core/common/logging/sinks/clog_sink.h" #include "core/common/logging/sinks/cerr_sink.h" -#include "core/framework/allocatormgr.h" #include "core/session/environment.h" #include "core/framework/ort_value.h" #include "core/session/inference_session.h" diff --git a/onnxruntime/test/framework/TestAllocatorManager.cc b/onnxruntime/test/framework/TestAllocatorManager.cc index 42c4680f18..6431faf9ca 100644 --- a/onnxruntime/test/framework/TestAllocatorManager.cc +++ b/onnxruntime/test/framework/TestAllocatorManager.cc @@ -2,7 +2,6 @@ // Licensed under the MIT License. #include "test/framework/TestAllocatorManager.h" -#include "core/framework/allocatormgr.h" namespace onnxruntime { namespace test { diff --git a/onnxruntime/test/framework/allocator_test.cc b/onnxruntime/test/framework/allocator_test.cc index 958791205b..2c1cd48d3d 100644 --- a/onnxruntime/test/framework/allocator_test.cc +++ b/onnxruntime/test/framework/allocator_test.cc @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -#include "core/framework/allocatormgr.h" #include "core/framework/allocator.h" #include "test_utils.h" diff --git a/onnxruntime/test/framework/bfc_arena_test.cc b/onnxruntime/test/framework/bfc_arena_test.cc index a6034f2ea0..2d3c1521f9 100644 --- a/onnxruntime/test/framework/bfc_arena_test.cc +++ b/onnxruntime/test/framework/bfc_arena_test.cc @@ -2,7 +2,7 @@ // Licensed under the MIT License. #include "core/framework/bfc_arena.h" -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "gtest/gtest.h" #include "gmock/gmock.h" #include diff --git a/onnxruntime/test/framework/insert_cast_transformer_test.cc b/onnxruntime/test/framework/insert_cast_transformer_test.cc index 0196e3385f..c38baee392 100644 --- a/onnxruntime/test/framework/insert_cast_transformer_test.cc +++ b/onnxruntime/test/framework/insert_cast_transformer_test.cc @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -#include "core/framework/allocatormgr.h" #include "core/framework/allocator.h" #include "core/optimizer/insert_cast_transformer.h" #include "core/graph/model.h" diff --git a/onnxruntime/test/framework/tensor_test.cc b/onnxruntime/test/framework/tensor_test.cc index b084fc6300..f24064a403 100644 --- a/onnxruntime/test/framework/tensor_test.cc +++ b/onnxruntime/test/framework/tensor_test.cc @@ -2,7 +2,6 @@ // Licensed under the MIT License. #include "core/framework/tensor.h" -#include "core/framework/allocatormgr.h" #include "test_utils.h" #include "gmock/gmock.h" diff --git a/onnxruntime/test/framework/test_utils.h b/onnxruntime/test/framework/test_utils.h index 05ba3d9455..0a99b4bc80 100644 --- a/onnxruntime/test/framework/test_utils.h +++ b/onnxruntime/test/framework/test_utils.h @@ -5,7 +5,6 @@ #include #include -#include "core/framework/allocatormgr.h" #include "core/framework/execution_provider.h" #include "core/providers/cpu/cpu_execution_provider.h" #include "core/framework/ort_value.h" diff --git a/onnxruntime/test/providers/cuda/test_cases/allocator_cuda_test.cc b/onnxruntime/test/providers/cuda/test_cases/allocator_cuda_test.cc index 4a92de220e..27a0696acb 100644 --- a/onnxruntime/test/providers/cuda/test_cases/allocator_cuda_test.cc +++ b/onnxruntime/test/providers/cuda/test_cases/allocator_cuda_test.cc @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "gtest/gtest.h" #include "cuda_runtime.h" #include "core/framework/allocator.h" diff --git a/onnxruntime/test/providers/internal_testing/internal_testing_execution_provider.cc b/onnxruntime/test/providers/internal_testing/internal_testing_execution_provider.cc index 99410439c5..b9071c10cc 100644 --- a/onnxruntime/test/providers/internal_testing/internal_testing_execution_provider.cc +++ b/onnxruntime/test/providers/internal_testing/internal_testing_execution_provider.cc @@ -3,7 +3,7 @@ #include "internal_testing_execution_provider.h" -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "core/framework/compute_capability.h" #include "core/framework/feeds_fetches_manager.h" #include "core/framework/op_kernel_context_internal.h" diff --git a/onnxruntime/test/providers/tensorrt/tensorrt_basic_test.cc b/onnxruntime/test/providers/tensorrt/tensorrt_basic_test.cc index 1601eeff64..f84ab3c89b 100644 --- a/onnxruntime/test/providers/tensorrt/tensorrt_basic_test.cc +++ b/onnxruntime/test/providers/tensorrt/tensorrt_basic_test.cc @@ -108,7 +108,6 @@ void RunWithOneSessionSingleThreadInference(std::string model_name, std::string RunOptions run_options; run_options.run_tag = so.session_logid; InferenceSession session_object{so, GetEnvironment()}; - onnxruntime::AllocatorManager allocator_manager; auto cuda_provider = DefaultCudaExecutionProvider(); auto cpu_allocator = cuda_provider->CreatePreferredAllocators()[1]; std::vector dims_mul_x = {1, 3, 2}; @@ -191,7 +190,6 @@ void RunWithOneSessionMultiThreadsInference(std::string model_name, std::string RunOptions run_options; run_options.run_tag = so.session_logid; InferenceSession session_object{so, GetEnvironment()}; - onnxruntime::AllocatorManager allocator_manager; auto cuda_provider = DefaultCudaExecutionProvider(); auto cpu_allocator = cuda_provider->CreatePreferredAllocators()[1]; std::vector dims_mul_x = {1, 3, 2}; @@ -348,7 +346,6 @@ TEST(TensorrtExecutionProviderTest, TRTPluginsCustomOpTest) { RunOptions run_options; run_options.run_tag = so.session_logid; InferenceSession session_object{so, GetEnvironment()}; - onnxruntime::AllocatorManager allocator_manager; auto cuda_provider = DefaultCudaExecutionProvider(); auto cpu_allocator = cuda_provider->CreatePreferredAllocators()[1]; std::vector dims_op_x = {12, 256, 256}; @@ -439,7 +436,6 @@ TEST_P(TensorrtExecutionProviderCacheTest, Run) { RunOptions run_options; run_options.run_tag = so.session_logid; InferenceSession session_object{so, GetEnvironment()}; - onnxruntime::AllocatorManager allocator_manager; auto cuda_provider = DefaultCudaExecutionProvider(); auto cpu_allocator = cuda_provider->CreatePreferredAllocators()[1]; std::vector dims_mul_x = {1, 3, 2}; @@ -782,7 +778,6 @@ TEST(TensorrtExecutionProviderTest, FunctionTest) { run_options.run_tag = so.session_logid; InferenceSession session_object{so, GetEnvironment()}; - onnxruntime::AllocatorManager allocator_manager; auto cuda_provider = DefaultCudaExecutionProvider(); auto cpu_allocator = cuda_provider->CreatePreferredAllocators()[1]; @@ -885,7 +880,6 @@ TEST(TensorrtExecutionProviderTest, DISABLED_NodeIndexMappingTest) { // [W:onn run_options.run_tag = so.session_logid; InferenceSession session_object{so, GetEnvironment()}; - onnxruntime::AllocatorManager allocator_manager; auto cuda_provider = DefaultCudaExecutionProvider(); auto cpu_allocator = cuda_provider->CreatePreferredAllocators()[1]; @@ -1005,7 +999,6 @@ TEST(TensorrtExecutionProviderTest, RemoveCycleTest) { run_options.run_tag = so.session_logid; InferenceSession session_object{so, GetEnvironment()}; - onnxruntime::AllocatorManager allocator_manager; auto cuda_provider = DefaultCudaExecutionProvider(); auto cpu_allocator = cuda_provider->CreatePreferredAllocators()[1]; diff --git a/onnxruntime/test/quantization/quantization_test.cc b/onnxruntime/test/quantization/quantization_test.cc index e937d3e4a6..bdfac77b33 100644 --- a/onnxruntime/test/quantization/quantization_test.cc +++ b/onnxruntime/test/quantization/quantization_test.cc @@ -4,7 +4,6 @@ #include "gtest/gtest.h" #include "core/framework/tensor.h" -#include "core/framework/allocatormgr.h" #include "core/quantization/quantization.h" #include "test/framework/test_utils.h" diff --git a/winml/lib/Common/inc/onnx.h b/winml/lib/Common/inc/onnx.h index 1519bc2948..b337ce31c6 100644 --- a/winml/lib/Common/inc/onnx.h +++ b/winml/lib/Common/inc/onnx.h @@ -27,8 +27,8 @@ #endif USE_DML #include "core/framework/customregistry.h" -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "core/session/environment.h" #include "core/session/IOBinding.h" #include "core/common/logging/logging.h" -#include "core/common/logging/sinks/clog_sink.h" \ No newline at end of file +#include "core/common/logging/sinks/clog_sink.h" diff --git a/winml/test/common/protobufHelpers.cpp b/winml/test/common/protobufHelpers.cpp index 9a15da4df8..9f1153f94c 100644 --- a/winml/test/common/protobufHelpers.cpp +++ b/winml/test/common/protobufHelpers.cpp @@ -6,7 +6,7 @@ #endif // LotusRT -#include "core/framework/allocatormgr.h" +#include "core/framework/allocator_utils.h" #include "core/common/logging/logging.h" #include "core/common/logging/sinks/clog_sink.h" #include "protobufHelpers.h"