From f21418897d9eb0c95df9db1e8c63ecef5cf748f8 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Tue, 26 Aug 2025 10:57:58 -0700 Subject: [PATCH 1/2] Add default constructor to Ort::Status. During CIs and local builds it gets inherited from the base due to using directives, however, that does not work for packaging pipleines. Having default ctor is important for storing Status in containers if needed. --- include/onnxruntime/core/session/onnxruntime_cxx_api.h | 1 + include/onnxruntime/core/session/onnxruntime_cxx_inline.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_api.h b/include/onnxruntime/core/session/onnxruntime_cxx_api.h index 2f4fd36c8115f..f878f5c61af21 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_api.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_api.h @@ -728,6 +728,7 @@ struct Status : detail::Base { using Base = detail::Base; using Base::Base; + Status() = default; explicit Status(std::nullptr_t) noexcept {} ///< Create an empty object, must be assigned a valid one to be used explicit Status(OrtStatus* status) noexcept; ///< Takes ownership of OrtStatus instance returned from the C API. explicit Status(const Exception&); ///< Creates status instance out of exception diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h index 73200d8852223..d0089726812a3 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h @@ -823,7 +823,7 @@ inline Status Env::CopyTensors(const std::vector& src_tensors, return Status("Source and destination tensor vectors must have the same size", ORT_INVALID_ARGUMENT); } if (src_tensors.empty()) { - return Status(); + return Status(nullptr); } const OrtValue* const* src_tensors_ptr = reinterpret_cast(src_tensors.data()); From dfbc06cbd535b43173dfbee9c598749549f753d1 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Tue, 26 Aug 2025 12:09:06 -0700 Subject: [PATCH 2/2] Add comments, remove using Base; --- include/onnxruntime/core/session/onnxruntime_cxx_api.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_api.h b/include/onnxruntime/core/session/onnxruntime_cxx_api.h index f878f5c61af21..c39e27088e8bc 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_api.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_api.h @@ -725,10 +725,7 @@ using AllocatedStringPtr = std::unique_ptr; * constructors to construct an instance of a Status object from exceptions. */ struct Status : detail::Base { - using Base = detail::Base; - using Base::Base; - - Status() = default; + Status() = default; // Same as with std::nullptr_t. But can be used in re-sizable containers and represent success. explicit Status(std::nullptr_t) noexcept {} ///< Create an empty object, must be assigned a valid one to be used explicit Status(OrtStatus* status) noexcept; ///< Takes ownership of OrtStatus instance returned from the C API. explicit Status(const Exception&); ///< Creates status instance out of exception