From ed349b9d9d6741fb984b12d45dee1979e4fb3bd1 Mon Sep 17 00:00:00 2001 From: Yi-Hong Lyu Date: Tue, 14 May 2024 02:26:15 -0700 Subject: [PATCH] Mark end of version 17 and 18 C API (#20671) Additionally, these versions are safeguarded by the `static_assert`. --- onnxruntime/core/session/onnxruntime_c_api.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index 52798ea573c1f..f0ed97ddabb67 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -2723,10 +2723,14 @@ static constexpr OrtApi ort_api_1_to_18 = { &OrtApis::SetDeterministicCompute, &OrtApis::KernelContext_ParallelFor, &OrtApis::SessionOptionsAppendExecutionProvider_OpenVINO_V2, + // End of Version 17 - DO NOT MODIFY ABOVE (see above text for more information) + &OrtApis::SessionOptionsAppendExecutionProvider_VitisAI, &OrtApis::KernelContext_GetScratchBuffer, &OrtApis::KernelInfoGetAllocator, - &OrtApis::AddExternalInitializersFromFilesInMemory}; + &OrtApis::AddExternalInitializersFromFilesInMemory + // End of Version 18 - DO NOT MODIFY ABOVE (see above text for more information) +}; // OrtApiBase can never change as there is no way to know what version of OrtApiBase is returned by OrtGetApiBase. static_assert(sizeof(OrtApiBase) == sizeof(void*) * 2, "New methods can't be added to OrtApiBase as it is not versioned"); @@ -2755,7 +2759,8 @@ static_assert(offsetof(OrtApi, ReleaseCANNProviderOptions) / sizeof(void*) == 22 static_assert(offsetof(OrtApi, GetSessionConfigEntry) / sizeof(void*) == 238, "Size of version 14 API cannot change"); static_assert(offsetof(OrtApi, GetBuildInfoString) / sizeof(void*) == 254, "Size of version 15 API cannot change"); static_assert(offsetof(OrtApi, KernelContext_GetResource) / sizeof(void*) == 265, "Size of version 16 API cannot change"); -static_assert(offsetof(OrtApi, SetUserLoggingFunction) / sizeof(void*) == 266, "Size of version 17 API cannot change"); +static_assert(offsetof(OrtApi, SessionOptionsAppendExecutionProvider_OpenVINO_V2) / sizeof(void*) == 275, "Size of version 17 API cannot change"); +static_assert(offsetof(OrtApi, AddExternalInitializersFromFilesInMemory) / sizeof(void*) == 279, "Size of version 18 API cannot change"); // So that nobody forgets to finish an API version, this check will serve as a reminder: static_assert(std::string_view(ORT_VERSION) == "1.18.0",