From d419170c7b4f7070ac194ff99d4e9b11a2097673 Mon Sep 17 00:00:00 2001 From: Ryan Hill <38674843+RyanUnderhill@users.noreply.github.com> Date: Thu, 13 Dec 2018 14:42:51 -0800 Subject: [PATCH] =?UTF-8?q?Rename=20ONNXRUNTIME=5FAPI=5FSTATUSCALL=20to=20?= =?UTF-8?q?ONNXRUNTIME=5FAPI=5FCALL=20since=20it's=20=E2=80=A6=20(#165)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rename ONNXRUNTIME_API_STATUSCALL to ONNXRUNTIME_API_CALL since it's just for calling convention, there's no status return value implied. * Missed a function --- .../core/framework/onnx_object_cxx.h | 4 +- .../core/session/onnxruntime_c_api.h | 24 ++++----- .../providers/cpu/cpu_provider_factory.cc | 6 +-- .../providers/cuda/cuda_provider_factory.cc | 6 +-- .../mkldnn/mkldnn_provider_factory.cc | 6 +-- .../session/default_cpu_allocator_c_api.cc | 10 ++-- onnxruntime/test/shared_lib/test_fixture.h | 2 +- .../test/util/include/test_allocator.h | 50 +++++++++---------- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/include/onnxruntime/core/framework/onnx_object_cxx.h b/include/onnxruntime/core/framework/onnx_object_cxx.h index da4622a825..a7699c1785 100644 --- a/include/onnxruntime/core/framework/onnx_object_cxx.h +++ b/include/onnxruntime/core/framework/onnx_object_cxx.h @@ -24,14 +24,14 @@ class ObjectBase { ObjectBase() : cls_(&static_cls), ref_count(1) { } - static uint32_t ONNXRUNTIME_API_STATUSCALL ONNXRuntimeReleaseImpl(void* this_) { + static uint32_t ONNXRUNTIME_API_CALL ONNXRuntimeReleaseImpl(void* this_) { T* this_ptr = reinterpret_cast(this_); if (--this_ptr->ref_count == 0) delete this_ptr; return 0; } - static uint32_t ONNXRUNTIME_API_STATUSCALL ONNXRuntimeAddRefImpl(void* this_) { + static uint32_t ONNXRUNTIME_API_CALL ONNXRuntimeAddRefImpl(void* this_) { T* this_ptr = reinterpret_cast(this_); ++this_ptr->ref_count; return 0; diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index 7117ba4bcd..2a4f525998 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -38,11 +38,11 @@ extern "C" { #else #define ONNX_RUNTIME_EXPORT #endif -#define ONNXRUNTIME_API_STATUSCALL _stdcall +#define ONNXRUNTIME_API_CALL _stdcall #define ONNX_RUNTIME_MUST_USE_RESULT #else #define ONNX_RUNTIME_EXPORT -#define ONNXRUNTIME_API_STATUSCALL +#define ONNXRUNTIME_API_CALL #define ONNX_RUNTIME_MUST_USE_RESULT __attribute__((warn_unused_result)) #endif @@ -79,14 +79,14 @@ typedef void ONNXStatus; // __VA_ARGS__ on Windows and Linux are different #define ONNXRUNTIME_API(RETURN_TYPE, NAME, ...) \ - ONNX_RUNTIME_EXPORT RETURN_TYPE ONNXRUNTIME_API_STATUSCALL NAME(__VA_ARGS__) NO_EXCEPTION + ONNX_RUNTIME_EXPORT RETURN_TYPE ONNXRUNTIME_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION #define ONNXRUNTIME_API_STATUS(NAME, ...) \ - ONNX_RUNTIME_EXPORT ONNXStatus* ONNXRUNTIME_API_STATUSCALL NAME(__VA_ARGS__) NO_EXCEPTION ONNX_RUNTIME_MUST_USE_RESULT + ONNX_RUNTIME_EXPORT ONNXStatus* ONNXRUNTIME_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION ONNX_RUNTIME_MUST_USE_RESULT // Used in *.cc files. Almost as same as ONNXRUNTIME_API_STATUS, except without ONNX_RUNTIME_MUST_USE_RESULT #define ONNXRUNTIME_API_STATUS_IMPL(NAME, ...) \ - ONNX_RUNTIME_EXPORT ONNXStatus* ONNXRUNTIME_API_STATUSCALL NAME(__VA_ARGS__) NO_EXCEPTION + ONNX_RUNTIME_EXPORT ONNXStatus* ONNXRUNTIME_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION #define DEFINE_RUNTIME_CLASS2(NAME, TYPE) \ ONNXRUNTIME_API(void, Release##NAME, _Frees_ptr_opt_ TYPE* input); @@ -237,9 +237,9 @@ DEFINE_RUNTIME_CLASS(ONNXRuntimeProvider); */ typedef struct ONNXObject { ///returns the new reference count. - uint32_t(ONNXRUNTIME_API_STATUSCALL* AddRef)(void* this_); + uint32_t(ONNXRUNTIME_API_CALL* AddRef)(void* this_); ///returns the new reference count. - uint32_t(ONNXRUNTIME_API_STATUSCALL* Release)(void* this_); + uint32_t(ONNXRUNTIME_API_CALL* Release)(void* this_); //TODO: implement QueryInterface? } ONNXObject; @@ -263,7 +263,7 @@ ONNXRUNTIME_API(uint32_t, ONNXRuntimeReleaseObject, _Inout_opt_ void* ptr); //Inherented from ONNXObject typedef struct ONNXRuntimeProviderFactoryInterface { ONNXObject parent; - ONNXStatus*(ONNXRUNTIME_API_STATUSCALL* CreateProvider)(void* this_, ONNXRuntimeProvider** out); + ONNXStatus*(ONNXRUNTIME_API_CALL* CreateProvider)(void* this_, ONNXRuntimeProvider** out); } ONNXRuntimeProviderFactoryInterface; struct ONNXRuntimeSessionOptions; @@ -350,9 +350,9 @@ ONNXRUNTIME_API(ONNXRuntimeAllocatorType, ONNXRuntimeAllocatorInfoGetType, _In_ //inherented from ONNXObject typedef struct ONNXRuntimeAllocatorInteface { struct ONNXObject parent; - void*(ONNXRUNTIME_API_STATUSCALL* Alloc)(void* this_, size_t size); - void(ONNXRUNTIME_API_STATUSCALL* Free)(void* this_, void* p); - const struct ONNXRuntimeAllocatorInfo*(ONNXRUNTIME_API_STATUSCALL* Info)(const void* this_); + void*(ONNXRUNTIME_API_CALL* Alloc)(void* this_, size_t size); + void(ONNXRUNTIME_API_CALL* Free)(void* this_, void* p); + const struct ONNXRuntimeAllocatorInfo*(ONNXRUNTIME_API_CALL* Info)(const void* this_); } ONNXRuntimeAllocatorInteface; typedef ONNXRuntimeAllocatorInteface* ONNXRuntimeAllocator; @@ -372,7 +372,7 @@ typedef enum ONNXRuntimeLoggingLevel { ONNXRUNTIME_LOGGING_LEVEL_kFATAL = 4 } ONNXRuntimeLoggingLevel; -typedef void(ONNXRUNTIME_API_STATUSCALL* ONNXRuntimeLoggingFunction)( +typedef void(ONNXRUNTIME_API_CALL* ONNXRuntimeLoggingFunction)( void* param, ONNXRuntimeLoggingLevel severity, const char* category, const char* logid, const char* code_location, const char* message); /** diff --git a/onnxruntime/core/providers/cpu/cpu_provider_factory.cc b/onnxruntime/core/providers/cpu/cpu_provider_factory.cc index 90ed58c94e..2ce0e5a9b9 100644 --- a/onnxruntime/core/providers/cpu/cpu_provider_factory.cc +++ b/onnxruntime/core/providers/cpu/cpu_provider_factory.cc @@ -15,7 +15,7 @@ struct CpuProviderFactory { CpuProviderFactory(); }; -ONNXStatus* ONNXRUNTIME_API_STATUSCALL CreateCpu(void* this_, ONNXRuntimeProvider** out) { +ONNXStatus* ONNXRUNTIME_API_CALL CreateCpu(void* this_, ONNXRuntimeProvider** out) { CPUExecutionProviderInfo info; CpuProviderFactory* this_ptr = (CpuProviderFactory*)this_; info.create_arena = this_ptr->create_arena; @@ -24,14 +24,14 @@ ONNXStatus* ONNXRUNTIME_API_STATUSCALL CreateCpu(void* this_, ONNXRuntimeProvide return nullptr; } -uint32_t ONNXRUNTIME_API_STATUSCALL ReleaseCpu(void* this_) { +uint32_t ONNXRUNTIME_API_CALL ReleaseCpu(void* this_) { CpuProviderFactory* this_ptr = (CpuProviderFactory*)this_; if (--this_ptr->ref_count == 0) delete this_ptr; return 0; } -uint32_t ONNXRUNTIME_API_STATUSCALL AddRefCpu(void* this_) { +uint32_t ONNXRUNTIME_API_CALL AddRefCpu(void* this_) { CpuProviderFactory* this_ptr = (CpuProviderFactory*)this_; ++this_ptr->ref_count; return 0; diff --git a/onnxruntime/core/providers/cuda/cuda_provider_factory.cc b/onnxruntime/core/providers/cuda/cuda_provider_factory.cc index ece64315ce..e25635b337 100644 --- a/onnxruntime/core/providers/cuda/cuda_provider_factory.cc +++ b/onnxruntime/core/providers/cuda/cuda_provider_factory.cc @@ -15,7 +15,7 @@ struct CUDAProviderFactory { CUDAProviderFactory(); }; -ONNXStatus* ONNXRUNTIME_API_STATUSCALL CreateCuda(void* this_, ONNXRuntimeProvider** out) { +ONNXStatus* ONNXRUNTIME_API_CALL CreateCuda(void* this_, ONNXRuntimeProvider** out) { CUDAExecutionProviderInfo info; CUDAProviderFactory* this_ptr = (CUDAProviderFactory*)this_; info.device_id = this_ptr->device_id; @@ -24,14 +24,14 @@ ONNXStatus* ONNXRUNTIME_API_STATUSCALL CreateCuda(void* this_, ONNXRuntimeProvid return nullptr; } -uint32_t ONNXRUNTIME_API_STATUSCALL ReleaseCuda(void* this_) { +uint32_t ONNXRUNTIME_API_CALL ReleaseCuda(void* this_) { CUDAProviderFactory* this_ptr = (CUDAProviderFactory*)this_; if (--this_ptr->ref_count == 0) delete this_ptr; return 0; } -uint32_t ONNXRUNTIME_API_STATUSCALL AddRefCuda(void* this_) { +uint32_t ONNXRUNTIME_API_CALL AddRefCuda(void* this_) { CUDAProviderFactory* this_ptr = (CUDAProviderFactory*)this_; ++this_ptr->ref_count; return 0; diff --git a/onnxruntime/core/providers/mkldnn/mkldnn_provider_factory.cc b/onnxruntime/core/providers/mkldnn/mkldnn_provider_factory.cc index 36b81407aa..7cb46db6f6 100644 --- a/onnxruntime/core/providers/mkldnn/mkldnn_provider_factory.cc +++ b/onnxruntime/core/providers/mkldnn/mkldnn_provider_factory.cc @@ -15,7 +15,7 @@ struct MkldnnProviderFactory { MkldnnProviderFactory(); }; -ONNXStatus* ONNXRUNTIME_API_STATUSCALL CreateMkldnn(void* this_, ONNXRuntimeProvider** out) { +ONNXStatus* ONNXRUNTIME_API_CALL CreateMkldnn(void* this_, ONNXRuntimeProvider** out) { MKLDNNExecutionProviderInfo info; MkldnnProviderFactory* this_ptr = (MkldnnProviderFactory*)this_; info.create_arena = this_ptr->create_arena; @@ -24,14 +24,14 @@ ONNXStatus* ONNXRUNTIME_API_STATUSCALL CreateMkldnn(void* this_, ONNXRuntimeProv return nullptr; } -uint32_t ONNXRUNTIME_API_STATUSCALL ReleaseMkldnn(void* this_) { +uint32_t ONNXRUNTIME_API_CALL ReleaseMkldnn(void* this_) { MkldnnProviderFactory* this_ptr = (MkldnnProviderFactory*)this_; if (--this_ptr->ref_count == 0) delete this_ptr; return 0; } -uint32_t ONNXRUNTIME_API_STATUSCALL AddRefMkldnn(void* this_) { +uint32_t ONNXRUNTIME_API_CALL AddRefMkldnn(void* this_) { MkldnnProviderFactory* this_ptr = (MkldnnProviderFactory*)this_; ++this_ptr->ref_count; return 0; diff --git a/onnxruntime/core/session/default_cpu_allocator_c_api.cc b/onnxruntime/core/session/default_cpu_allocator_c_api.cc index 80fb77abc4..11b4ac58b1 100644 --- a/onnxruntime/core/session/default_cpu_allocator_c_api.cc +++ b/onnxruntime/core/session/default_cpu_allocator_c_api.cc @@ -10,20 +10,20 @@ private: \ const ONNXRuntimeAllocatorInteface* vtable_ = &table_; \ std::atomic_int ref_count_; \ - static void* ONNXRUNTIME_API_STATUSCALL Alloc_(void* this_ptr, size_t size) { \ + static void* ONNXRUNTIME_API_CALL Alloc_(void* this_ptr, size_t size) { \ return ((CLASS_NAME*)this_ptr)->Alloc(size); \ } \ - static void ONNXRUNTIME_API_STATUSCALL Free_(void* this_ptr, void* p) { \ + static void ONNXRUNTIME_API_CALL Free_(void* this_ptr, void* p) { \ return ((CLASS_NAME*)this_ptr)->Free(p); \ } \ - static const ONNXRuntimeAllocatorInfo* ONNXRUNTIME_API_STATUSCALL Info_(const void* this_ptr) { \ + static const ONNXRuntimeAllocatorInfo* ONNXRUNTIME_API_CALL Info_(const void* this_ptr) { \ return ((const CLASS_NAME*)this_ptr)->Info(); \ } \ - static uint32_t ONNXRUNTIME_API_STATUSCALL AddRef_(void* this_) { \ + static uint32_t ONNXRUNTIME_API_CALL AddRef_(void* this_) { \ CLASS_NAME* this_ptr = (CLASS_NAME*)this_; \ return ++this_ptr->ref_count_; \ } \ - static uint32_t ONNXRUNTIME_API_STATUSCALL Release_(void* this_) { \ + static uint32_t ONNXRUNTIME_API_CALL Release_(void* this_) { \ CLASS_NAME* this_ptr = (CLASS_NAME*)this_; \ uint32_t ret = --this_ptr->ref_count_; \ if (ret == 0) \ diff --git a/onnxruntime/test/shared_lib/test_fixture.h b/onnxruntime/test/shared_lib/test_fixture.h index 20a4a25084..7c5ac1fd8e 100644 --- a/onnxruntime/test/shared_lib/test_fixture.h +++ b/onnxruntime/test/shared_lib/test_fixture.h @@ -13,7 +13,7 @@ typedef const char* PATH_TYPE; #endif //empty -static inline void ONNXRUNTIME_API_STATUSCALL MyLoggingFunction(void*, ONNXRuntimeLoggingLevel, const char*, const char*, const char*, const char*) { +static inline void ONNXRUNTIME_API_CALL MyLoggingFunction(void*, ONNXRuntimeLoggingLevel, const char*, const char*, const char*, const char*) { } template class CApiTestImpl : public ::testing::Test { diff --git a/onnxruntime/test/util/include/test_allocator.h b/onnxruntime/test/util/include/test_allocator.h index b60e215dab..7a0d03088c 100644 --- a/onnxruntime/test/util/include/test_allocator.h +++ b/onnxruntime/test/util/include/test_allocator.h @@ -7,31 +7,31 @@ #include "core/session/onnxruntime_cxx_api.h" #include -#define ONNXRUNTIME_ALLOCATOR_IMPL_BEGIN(CLASS_NAME) \ - class CLASS_NAME { \ - private: \ - const ONNXRuntimeAllocatorInteface* vtable_ = &table_; \ - std::atomic_int ref_count_; \ - static void* ONNXRUNTIME_API_STATUSCALL Alloc_(void* this_ptr, size_t size) { \ - return ((CLASS_NAME*)this_ptr)->Alloc(size); \ - } \ - static void ONNXRUNTIME_API_STATUSCALL Free_(void* this_ptr, void* p) { \ - return ((CLASS_NAME*)this_ptr)->Free(p); \ - } \ - static const ONNXRuntimeAllocatorInfo* ONNXRUNTIME_API_STATUSCALL Info_(const void* this_ptr) { \ - return ((const CLASS_NAME*)this_ptr)->Info(); \ - } \ - static uint32_t ONNXRUNTIME_API_STATUSCALL AddRef_(void* this_) { \ - CLASS_NAME* this_ptr = (CLASS_NAME*)this_; \ - return ++this_ptr->ref_count_; \ - } \ - static uint32_t ONNXRUNTIME_API_STATUSCALL Release_(void* this_) { \ - CLASS_NAME* this_ptr = (CLASS_NAME*)this_; \ - uint32_t ret = --this_ptr->ref_count_; \ - if (ret == 0) \ - delete this_ptr; \ - return 0; \ - } \ +#define ONNXRUNTIME_ALLOCATOR_IMPL_BEGIN(CLASS_NAME) \ + class CLASS_NAME { \ + private: \ + const ONNXRuntimeAllocatorInteface* vtable_ = &table_; \ + std::atomic_int ref_count_; \ + static void* ONNXRUNTIME_API_CALL Alloc_(void* this_ptr, size_t size) { \ + return ((CLASS_NAME*)this_ptr)->Alloc(size); \ + } \ + static void ONNXRUNTIME_API_CALL Free_(void* this_ptr, void* p) { \ + return ((CLASS_NAME*)this_ptr)->Free(p); \ + } \ + static const ONNXRuntimeAllocatorInfo* ONNXRUNTIME_API_CALL Info_(const void* this_ptr) { \ + return ((const CLASS_NAME*)this_ptr)->Info(); \ + } \ + static uint32_t ONNXRUNTIME_API_CALL AddRef_(void* this_) { \ + CLASS_NAME* this_ptr = (CLASS_NAME*)this_; \ + return ++this_ptr->ref_count_; \ + } \ + static uint32_t ONNXRUNTIME_API_CALL Release_(void* this_) { \ + CLASS_NAME* this_ptr = (CLASS_NAME*)this_; \ + uint32_t ret = --this_ptr->ref_count_; \ + if (ret == 0) \ + delete this_ptr; \ + return 0; \ + } \ static ONNXRuntimeAllocatorInteface table_; #define ONNXRUNTIME_ALLOCATOR_IMPL_END \