From ba7b83ff3c48fa5df931001ffe1b96daf14d1c5d Mon Sep 17 00:00:00 2001 From: Baiju Meswani Date: Wed, 3 May 2023 13:08:35 -0700 Subject: [PATCH] Remove onnxruntime_PYBIND_EXPORT_OPSCHEMA definition from onnxruntime (#15776) --- cmake/onnxruntime_python.cmake | 4 ---- .../core/framework/kernel_def_builder.h | 2 -- .../core/framework/kernel_registry.h | 2 -- .../python/onnxruntime_pybind_schema.cc | 21 ++++++++----------- .../python/onnxruntime_pybind_state.cc | 2 -- .../python/onnxruntime_pybind_state_common.h | 2 -- tools/ci_build/build.py | 7 ------- 7 files changed, 9 insertions(+), 31 deletions(-) diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake index 12a149f044..58178f9546 100644 --- a/cmake/onnxruntime_python.cmake +++ b/cmake/onnxruntime_python.cmake @@ -20,10 +20,6 @@ file(GLOB onnxruntime_pybind_srcs CONFIGURE_DEPENDS ${onnxruntime_pybind_srcs_pattern} ) -if(NOT onnxruntime_PYBIND_EXPORT_OPSCHEMA) - list(REMOVE_ITEM onnxruntime_pybind_srcs ${ONNXRUNTIME_ROOT}/python/onnxruntime_pybind_schema.cc) -endif() - if(onnxruntime_ENABLE_TRAINING) list(REMOVE_ITEM onnxruntime_pybind_srcs ${ONNXRUNTIME_ROOT}/python/onnxruntime_pybind_module.cc) endif() diff --git a/include/onnxruntime/core/framework/kernel_def_builder.h b/include/onnxruntime/core/framework/kernel_def_builder.h index 2892439f17..de5a3a52f5 100644 --- a/include/onnxruntime/core/framework/kernel_def_builder.h +++ b/include/onnxruntime/core/framework/kernel_def_builder.h @@ -43,11 +43,9 @@ class KernelDef { *end = op_since_version_end_; } -#ifdef onnxruntime_PYBIND_EXPORT_OPSCHEMA const std::pair SinceVersion() const { return std::pair(op_since_version_start_, op_since_version_end_); } -#endif onnxruntime::ProviderType Provider() const { return provider_type_; diff --git a/include/onnxruntime/core/framework/kernel_registry.h b/include/onnxruntime/core/framework/kernel_registry.h index ceb2b75795..7b3d04ee66 100644 --- a/include/onnxruntime/core/framework/kernel_registry.h +++ b/include/onnxruntime/core/framework/kernel_registry.h @@ -73,12 +73,10 @@ class KernelRegistry { bool IsEmpty() const { return kernel_creator_fn_map_.empty(); } -#ifdef onnxruntime_PYBIND_EXPORT_OPSCHEMA // This is used by the opkernel doc generator to enlist all registered operators for a given provider's opkernel const KernelCreateMap& GetKernelCreateMap() const { return kernel_creator_fn_map_; } -#endif private: // TryFindKernel implementation. Either kernel_type_str_resolver or type_constraints is provided. diff --git a/onnxruntime/python/onnxruntime_pybind_schema.cc b/onnxruntime/python/onnxruntime_pybind_schema.cc index bfa26ee969..e325d3a2a6 100644 --- a/onnxruntime/python/onnxruntime_pybind_schema.cc +++ b/onnxruntime/python/onnxruntime_pybind_schema.cc @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// This file is excluded from the build if onnxruntime_PYBIND_EXPORT_OPSCHEMA not defined #include "python/onnxruntime_pybind_state_common.h" #include "core/framework/kernel_registry.h" @@ -30,21 +29,19 @@ void addGlobalSchemaFunctions(pybind11::module& m) { }(), #endif #ifdef USE_ROCM - onnxruntime::RocmProviderFactoryCreator::Create( - [&]() { - ROCMExecutionProviderInfo info{}; - info.device_id = cuda_device_id; - info.gpu_mem_limit = gpu_mem_limit; - info.arena_extend_strategy = arena_extend_strategy; - info.external_allocator_info = external_allocator_info; - return info; - }()), + []() { + OrtROCMProviderOptions provider_options; + return onnxruntime::RocmProviderFactoryCreator::Create(&provider_options); + }(), #endif #ifdef USE_DNNL onnxruntime::DnnlProviderFactoryCreator::Create(1), #endif #ifdef USE_OPENVINO - onnxruntime::OpenVINOProviderFactoryCreator::Create(OrtOpenVINOProviderOptions()), + []() { + OrtOpenVINOProviderOptions provider_options; + return onnxruntime::OpenVINOProviderFactoryCreator::Create(&provider_options); + }(), #endif #ifdef USE_TENSORRT onnxruntime::TensorrtProviderFactoryCreator::Create(0), @@ -65,7 +62,7 @@ void addGlobalSchemaFunctions(pybind11::module& m) { onnxruntime::DMLProviderFactoryCreator::Create(0, /*skip_software_device_check*/ true), #endif #ifdef USE_NNAPI - onnxruntime::NnapiProviderFactoryCreator::Create(0), + onnxruntime::NnapiProviderFactoryCreator::Create(0, std::optional()), #endif #ifdef USE_RKNPU onnxruntime::RknpuProviderFactoryCreator::Create(), diff --git a/onnxruntime/python/onnxruntime_pybind_state.cc b/onnxruntime/python/onnxruntime_pybind_state.cc index 4b867bcd6a..6f9e277f6a 100644 --- a/onnxruntime/python/onnxruntime_pybind_state.cc +++ b/onnxruntime/python/onnxruntime_pybind_state.cc @@ -1828,11 +1828,9 @@ void CreateInferencePybindStateModule(py::module& m) { } #endif -#ifdef onnxruntime_PYBIND_EXPORT_OPSCHEMA addGlobalSchemaFunctions(m); addOpSchemaSubmodule(m); addOpKernelSubmodule(m); -#endif } void InitArray() { diff --git a/onnxruntime/python/onnxruntime_pybind_state_common.h b/onnxruntime/python/onnxruntime_pybind_state_common.h index a51cf314f1..1260e9ea71 100644 --- a/onnxruntime/python/onnxruntime_pybind_state_common.h +++ b/onnxruntime/python/onnxruntime_pybind_state_common.h @@ -399,13 +399,11 @@ void addIoBindingMethods(pybind11::module& m); void addSparseTensorMethods(pybind11::module& m); -#ifdef onnxruntime_PYBIND_EXPORT_OPSCHEMA void addGlobalSchemaFunctions(pybind11::module& m); void addOpKernelSubmodule(pybind11::module& m); void addOpSchemaSubmodule(pybind11::module& m); -#endif const char* GetDeviceName(const OrtDevice& device); diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 1065f7397e..16d86a6d2c 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -1294,13 +1294,6 @@ def generate_build_tree( "-Donnxruntime_USE_FULL_PROTOBUF=ON", ] - if args.gen_doc: - if args.enable_training: - raise BuildError("--gen_doc is not supported along with --enable_training") - add_default_definition(cmake_extra_defines, "onnxruntime_PYBIND_EXPORT_OPSCHEMA", "ON") - else: - add_default_definition(cmake_extra_defines, "onnxruntime_PYBIND_EXPORT_OPSCHEMA", "OFF") - if args.enable_lazy_tensor: import torch