From 275f762b3d461460b83959db34423971ad711e9b Mon Sep 17 00:00:00 2001 From: Scott McKay Date: Tue, 24 Dec 2024 08:43:30 +1000 Subject: [PATCH] Last linux build error fixes. --- include/onnxruntime/core/session/onnxruntime_cxx_api.h | 2 +- include/onnxruntime/core/session/onnxruntime_cxx_inline.h | 3 ++- onnxruntime/test/shared_lib/test_model_builder_api.cc | 6 +++--- onnxruntime/test/shared_lib/utils.h | 2 ++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_api.h b/include/onnxruntime/core/session/onnxruntime_cxx_api.h index f099e415faefe..6e0f0acd12bfb 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_api.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_api.h @@ -2571,7 +2571,7 @@ struct ValueInfo : detail::ValueInfoImpl { explicit ValueInfo(OrtValueInfo* p) : ValueInfoImpl{p} {} // Create ValueInfo for a tensor - explicit ValueInfo(const std::string& name, ConstTypeInfo& type_info); + explicit ValueInfo(const std::string& name, const ConstTypeInfo& type_info); ConstValueInfo GetConst() const { return ConstValueInfo{this->p_}; } }; diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h index 6a3c8b869dd2c..1de5db266961d 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h @@ -2396,7 +2396,7 @@ inline Model::Model(const std::vector& opsets) { ThrowOnError(GetModelBuilderApi().CreateModel(domains.data(), versions.data(), opsets.size(), &p_)); } -inline ValueInfo::ValueInfo(const std::string& name, ConstTypeInfo& type_info) { +inline ValueInfo::ValueInfo(const std::string& name, const ConstTypeInfo& type_info) { ThrowOnError(GetModelBuilderApi().CreateValueInfo(name.c_str(), type_info, &p_)); } namespace detail { @@ -2454,6 +2454,7 @@ inline void GraphImpl::AddNode(Node& node) { ThrowOnError(GetModelBuilderApi().AddNodeToGraph(p_, node.release())); } +template <> inline void ModelImpl::AddGraph(Graph& graph) { // Model takes ownership of `graph` ThrowOnError(GetModelBuilderApi().AddGraphToModel(p_, graph.release())); diff --git a/onnxruntime/test/shared_lib/test_model_builder_api.cc b/onnxruntime/test/shared_lib/test_model_builder_api.cc index 5f498f64b6809..306dab14fd470 100644 --- a/onnxruntime/test/shared_lib/test_model_builder_api.cc +++ b/onnxruntime/test/shared_lib/test_model_builder_api.cc @@ -91,18 +91,18 @@ struct TestAllocator : public OrtAllocator { auto it = std::find_if(test_allocator->weights.begin(), test_allocator->weights.end(), [p](const std::unique_ptr>& v) { return v->data() == p; }); if (it == test_allocator->weights.end()) { - throw std::exception("Free called with unknown pointer"); + throw std::runtime_error("Free called with unknown pointer"); } test_allocator->weights.erase(it); }; Alloc = [](struct OrtAllocator* /*this*/, size_t /*size*/) -> void* { - throw std::exception("This should not be used"); + throw std::runtime_error("This should not be used"); }; Reserve = [](struct OrtAllocator* /*this*/, size_t /*size*/) -> void* { - throw std::exception("This should not be used"); + throw std::runtime_error("This should not be used"); }; } diff --git a/onnxruntime/test/shared_lib/utils.h b/onnxruntime/test/shared_lib/utils.h index b95f13548a888..5d15582b86cb9 100644 --- a/onnxruntime/test/shared_lib/utils.h +++ b/onnxruntime/test/shared_lib/utils.h @@ -5,6 +5,8 @@ #include "core/session/onnxruntime_cxx_api.h" +#include "gtest/gtest.h" + OrtCUDAProviderOptions CreateDefaultOrtCudaProviderOptionsWithCustomStream(void* cuda_compute_stream = nullptr); template