Skip to content

Commit 05b3d81

Browse files
authored
Fix OrtApi static_assert violation, add instructions for updating additional API structs. (#27100)
### Description <!-- Describe your changes. --> Fix OrtApi 1.24 API size static_assert violation triggered by addition of new APIs in f481b17. Add version update instructions for updating additional API structs. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Fix build on main. Add info about other API structs to version update instructions.
1 parent f94987d commit 05b3d81

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

onnxruntime/core/session/onnxruntime_c_api.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4839,15 +4839,22 @@ static_assert(offsetof(OrtApi, SetEpDynamicOptions) / sizeof(void*) == 284, "Siz
48394839

48404840
static_assert(offsetof(OrtApi, GetEpApi) / sizeof(void*) == 317, "Size of version 22 API cannot change");
48414841
static_assert(offsetof(OrtApi, CreateExternalInitializerInfo) / sizeof(void*) == 389, "Size of version 23 API cannot change");
4842-
static_assert(offsetof(OrtApi, RunOptionsSetSyncStream) / sizeof(void*) == 411, "Size of version 24 API cannot change");
4842+
static_assert(offsetof(OrtApi, RunOptionsSetSyncStream) / sizeof(void*) == 413, "Size of version 24 API cannot change");
48434843

48444844
// So that nobody forgets to finish an API version, this check will serve as a reminder:
48454845
static_assert(std::string_view(ORT_VERSION) == "1.25.0",
48464846
"ORT_Version change detected, please follow below steps to ensure OrtApi is updated properly");
48474847
// 1. Update the hardcoded version string in above static_assert to silence it
4848+
//
48484849
// 2. If there were any APIs added to ort_api_1_to_25 above:
48494850
// a. Add the 'End of version #' markers (pattern above should be obvious)
48504851
// b. Add a static_assert in the directly above list of version sizes to ensure nobody adds any more functions to the just shipped API version
4852+
//
4853+
// 3. There are additional API structs that may have been updated. Repeat step 2 for these instances:
4854+
// - ort_compile_api in onnxruntime/onnxruntime/core/session/compile_api.cc
4855+
// - ort_ep_api in onnxruntime/onnxruntime/core/session/plugin_ep/ep_api.cc
4856+
// - ort_interop_api in onnxruntime/core/session/interop_api.cc
4857+
// - ort_model_editor_api in onnxruntime/onnxruntime/core/session/model_editor_c_api.cc
48514858

48524859
ORT_API(const OrtApi*, OrtApis::GetApi, uint32_t version) {
48534860
if (version >= 1 && version <= ORT_API_VERSION)

0 commit comments

Comments
 (0)