From 351d12df9e992a7a7de6c6c2fd15ee2f6843cb21 Mon Sep 17 00:00:00 2001 From: Scott McKay Date: Mon, 23 Dec 2024 19:31:21 +1000 Subject: [PATCH] Improve consistency. Update some comments. --- include/onnxruntime/core/session/onnxruntime_c_api.h | 2 +- .../onnxruntime/core/session/onnxruntime_cxx_inline.h | 2 +- onnxruntime/core/session/model_builder_api.h | 2 +- onnxruntime/core/session/model_builder_c_api.cc | 9 +++++---- onnxruntime/test/shared_lib/test_model_builder_api.cc | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index 2b72b780b4ca2..e1fa9132c8e50 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -5304,7 +5304,7 @@ struct OrtModelBuilderApi { * * \since Version 1.21. */ - ORT_API2_STATUS(ApplyModelToSession, _In_ OrtSession* session, _In_ OrtModel* model); + ORT_API2_STATUS(ApplyModelToModelBuilderSession, _In_ OrtSession* session, _In_ OrtModel* model); /** \brief Finalize the Model Builder session. * diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h index 09c8a71a464ae..fe60154cb85ce 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h @@ -1159,7 +1159,7 @@ inline void SessionImpl::SetEpDynamicOptions(const char* const* keys, const c template inline void SessionImpl::FinalizeModelBuilderSession(const ModelBuilderAPI::Model& model, const SessionOptions& options, OrtPrepackedWeightsContainer* prepacked_weights_container) { - ThrowOnError(GetModelBuilderApi().ApplyModelToSession(this->p_, model)); + ThrowOnError(GetModelBuilderApi().ApplyModelToModelBuilderSession(this->p_, model)); ThrowOnError(GetModelBuilderApi().FinalizeModelBuilderSession(this->p_, options, prepacked_weights_container)); } diff --git a/onnxruntime/core/session/model_builder_api.h b/onnxruntime/core/session/model_builder_api.h index 7c03c7f05e887..b27888fe418ba 100644 --- a/onnxruntime/core/session/model_builder_api.h +++ b/onnxruntime/core/session/model_builder_api.h @@ -51,7 +51,7 @@ ORT_API_STATUS_IMPL(CreateModelBuilderSessionFromArray, _In_ const OrtEnv* env, _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out); -ORT_API_STATUS_IMPL(ApplyModelToSession, _In_ OrtSession* session, _In_ OrtModel* model); +ORT_API_STATUS_IMPL(ApplyModelToModelBuilderSession, _In_ OrtSession* session, _In_ OrtModel* model); ORT_API_STATUS_IMPL(FinalizeModelBuilderSession, _In_ OrtSession* session, _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container); diff --git a/onnxruntime/core/session/model_builder_c_api.cc b/onnxruntime/core/session/model_builder_c_api.cc index 7fd5b897367cb..25e2409805c74 100644 --- a/onnxruntime/core/session/model_builder_c_api.cc +++ b/onnxruntime/core/session/model_builder_c_api.cc @@ -243,8 +243,8 @@ ORT_API_STATUS_IMPL(OrtModelBuilderAPI::CreateSessionFromModel, _In_ const OrtEn API_IMPL_END } -ORT_API_STATUS_IMPL(OrtModelBuilderAPI::CreateModelBuilderSession, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path, - _In_ const OrtSessionOptions* options, +ORT_API_STATUS_IMPL(OrtModelBuilderAPI::CreateModelBuilderSession, + _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path, _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out) { API_IMPL_BEGIN std::unique_ptr session; @@ -288,7 +288,8 @@ ORT_API_STATUS_IMPL(OrtModelBuilderAPI::CreateModelBuilderSessionFromArray, _In_ API_IMPL_END } -ORT_API_STATUS_IMPL(OrtModelBuilderAPI::ApplyModelToSession, _In_ OrtSession* session, _In_ OrtModel* model) { +ORT_API_STATUS_IMPL(OrtModelBuilderAPI::ApplyModelToModelBuilderSession, + _In_ OrtSession* session, _In_ OrtModel* model) { API_IMPL_BEGIN auto sess = reinterpret_cast(session); ORT_API_RETURN_IF_STATUS_NOT_OK(sess->ApplyUpdates(*model)); @@ -332,7 +333,7 @@ static constexpr OrtModelBuilderApi ort_graph_api = { &OrtModelBuilderAPI::CreateModelBuilderSession, &OrtModelBuilderAPI::CreateModelBuilderSessionFromArray, - &OrtModelBuilderAPI::ApplyModelToSession, + &OrtModelBuilderAPI::ApplyModelToModelBuilderSession, &OrtModelBuilderAPI::FinalizeModelBuilderSession, }; diff --git a/onnxruntime/test/shared_lib/test_model_builder_api.cc b/onnxruntime/test/shared_lib/test_model_builder_api.cc index b6f8eb04e303f..5f498f64b6809 100644 --- a/onnxruntime/test/shared_lib/test_model_builder_api.cc +++ b/onnxruntime/test/shared_lib/test_model_builder_api.cc @@ -341,7 +341,7 @@ TEST(ModelBuilderAPITest, BasicModelEdit_CxxApi) { SessionOptions so; // Set this to save the model if you want to debug. - so.SetOptimizedModelFilePath(ORT_TSTR("model_builder_output.onnx")); + // so.SetOptimizedModelFilePath(ORT_TSTR("model_builder_edited.onnx")); Session session = Session::CreateModelBuilderSession(*ort_env, TSTR("testdata/mnist.onnx"), so); @@ -351,7 +351,7 @@ TEST(ModelBuilderAPITest, BasicModelEdit_CxxApi) { // the original graph is unchanged. nodes can be added before/after it. initializers can be added. // new nodes must conform to the original domain:opset of the model. // additional operator domain:opset pairs can be added. - std::vector opsets; + std::vector opsets; // no additional opsets required ModelBuilderAPI::Model model(opsets); std::vector input_names = session.GetInputNames();