From 9ae7ec091bcc20958d45221886afe6ff65195783 Mon Sep 17 00:00:00 2001 From: adrianlizarraga Date: Mon, 27 Oct 2025 14:57:40 -0700 Subject: [PATCH 1/4] Update ORT_API_VERSION to 24 --- include/onnxruntime/core/session/onnxruntime_c_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index e6bbebdbf3ab8..d5f45343c1a97 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -38,7 +38,7 @@ * * This value is used by some API functions to behave as this version of the header expects. */ -#define ORT_API_VERSION 23 +#define ORT_API_VERSION 24 #ifdef __cplusplus extern "C" { @@ -6584,7 +6584,7 @@ struct OrtApi { * \param[in] info The OrtTensorTypeAndShapeInfo instance. * \return true if the tensor has shape information, false otherwise. * - * \since Version 1.23 + * \since Version 1.24 */ ORT_API_T(bool, TensorTypeAndShape_HasShape, _In_ const OrtTensorTypeAndShapeInfo* info); }; From a92fb9f7312b6e3832f0aa43f5717747e1e2da49 Mon Sep 17 00:00:00 2001 From: adrianlizarraga Date: Mon, 27 Oct 2025 15:16:46 -0700 Subject: [PATCH 2/4] Add static_assert to ensure that APIs added in ORT 1.23.x are not removed or reordered. --- onnxruntime/core/session/onnxruntime_c_api.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index 7603397ea9cad..2456366afccee 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -4264,6 +4264,7 @@ static_assert(offsetof(OrtApi, AddExternalInitializersFromFilesInMemory) / sizeo static_assert(offsetof(OrtApi, SetEpDynamicOptions) / sizeof(void*) == 284, "Size of version 20 API cannot change"); static_assert(offsetof(OrtApi, GetEpApi) / sizeof(void*) == 317, "Size of version 22 API cannot change"); +static_assert(offsetof(OrtApi, CreateExternalInitializerInfo) / sizeof(void*) == 389, "Size of version 23 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.24.0", From 66f3ee3ff72bf0aa8492e473e93505632b539525 Mon Sep 17 00:00:00 2001 From: adrianlizarraga Date: Mon, 27 Oct 2025 15:49:57 -0700 Subject: [PATCH 3/4] Add static asserts for other API structs --- onnxruntime/core/session/model_editor_c_api.cc | 1 + onnxruntime/core/session/onnxruntime_c_api.cc | 2 ++ onnxruntime/core/session/plugin_ep/ep_api.cc | 3 +++ 3 files changed, 6 insertions(+) diff --git a/onnxruntime/core/session/model_editor_c_api.cc b/onnxruntime/core/session/model_editor_c_api.cc index 4f74e258cc943..487d5c818f9bc 100644 --- a/onnxruntime/core/session/model_editor_c_api.cc +++ b/onnxruntime/core/session/model_editor_c_api.cc @@ -393,6 +393,7 @@ static constexpr OrtModelEditorApi ort_model_editor_api = { &OrtModelEditorAPI::SessionGetOpsetForDomain, &OrtModelEditorAPI::ApplyModelToModelEditorSession, &OrtModelEditorAPI::FinalizeModelEditorSession, + // End of Version 22 - DO NOT MODIFY ABOVE }; // checks that we don't violate the rule that the functions must remain in the slots they were originally assigned diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index 2456366afccee..546b11ae580d5 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -4228,6 +4228,8 @@ static constexpr OrtApi ort_api_1_to_24 = { &OrtApis::Graph_GetModelMetadata, &OrtApis::GetModelCompatibilityForEpDevices, &OrtApis::CreateExternalInitializerInfo, + // End of Version 23 - DO NOT MODIFY ABOVE (see above text for more information) + &OrtApis::TensorTypeAndShape_HasShape, }; diff --git a/onnxruntime/core/session/plugin_ep/ep_api.cc b/onnxruntime/core/session/plugin_ep/ep_api.cc index cae0b086af66c..366f96e585918 100644 --- a/onnxruntime/core/session/plugin_ep/ep_api.cc +++ b/onnxruntime/core/session/plugin_ep/ep_api.cc @@ -230,11 +230,14 @@ static constexpr OrtEpApi ort_ep_api = { &OrtExecutionProviderApi::SyncStream_GetImpl, &OrtExecutionProviderApi::SyncStream_GetSyncId, &OrtExecutionProviderApi::GetSyncIdForLastWaitOnSyncStream, + // End of Version 23 - DO NOT MODIFY ABOVE }; // checks that we don't violate the rule that the functions must remain in the slots they were originally assigned static_assert(offsetof(OrtEpApi, ReleaseEpDevice) / sizeof(void*) == 1, "Size of version 22 API cannot change"); // initial version in ORT 1.22 +static_assert(offsetof(OrtEpApi, GetSyncIdForLastWaitOnSyncStream) / sizeof(void*) == 15, + "Size of version 23 API cannot change"); } // namespace OrtExecutionProviderApi From c2ed859d023b911cdc67575b73796e2ebbb41e71 Mon Sep 17 00:00:00 2001 From: adrianlizarraga Date: Mon, 27 Oct 2025 16:07:02 -0700 Subject: [PATCH 4/4] Add static_assert for OrtCompileApi --- onnxruntime/core/session/compile_api.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/onnxruntime/core/session/compile_api.cc b/onnxruntime/core/session/compile_api.cc index b9a54ea7104e1..12127e9708255 100644 --- a/onnxruntime/core/session/compile_api.cc +++ b/onnxruntime/core/session/compile_api.cc @@ -342,11 +342,14 @@ static constexpr OrtCompileApi ort_compile_api = { &OrtCompileAPI::ModelCompilationOptions_SetGraphOptimizationLevel, &OrtCompileAPI::ModelCompilationOptions_SetOutputModelWriteFunc, &OrtCompileAPI::ModelCompilationOptions_SetOutputModelGetInitializerLocationFunc, + // End of Version 23 - DO NOT MODIFY ABOVE }; // checks that we don't violate the rule that the functions must remain in the slots they were originally assigned static_assert(offsetof(OrtCompileApi, CompileModel) / sizeof(void*) == 8, "Size of version 22 Api cannot change"); // initial version in ORT 1.22 +static_assert(offsetof(OrtCompileApi, ModelCompilationOptions_SetOutputModelGetInitializerLocationFunc) / sizeof(void*) == 13, + "Size of version 23 of Api cannot change"); ORT_API(const OrtCompileApi*, OrtCompileAPI::GetCompileApi) { return &ort_compile_api;