From 41fb824df94a030362d2d997549df1045d78a553 Mon Sep 17 00:00:00 2001 From: Scott McKay Date: Mon, 23 Dec 2024 21:49:37 +1000 Subject: [PATCH] Fix some linux build errors. --- include/onnxruntime/core/graph/graph.h | 1 + .../core/session/onnxruntime_cxx_inline.h | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/onnxruntime/core/graph/graph.h b/include/onnxruntime/core/graph/graph.h index a8d47d5e8b705..2c40b41774d78 100644 --- a/include/onnxruntime/core/graph/graph.h +++ b/include/onnxruntime/core/graph/graph.h @@ -27,6 +27,7 @@ #include "core/common/span_utils.h" #include "core/common/status.h" #include "core/common/logging/logging.h" +#include "core/framework/ort_value.h" #include "core/framework/prepacked_weights_container.h" #include "core/graph/onnx_protobuf.h" #include "core/graph/basic_types.h" diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h index fe60154cb85ce..b1905dab7360d 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h @@ -1005,7 +1005,7 @@ inline std::vector ConstSessionImpl::GetInputNames() const { for (size_t i = 0; i < num_inputs; ++i) { char* name = nullptr; - ThrowOnError(GetApi().SessionGetInputName(p_, i, allocator, &name)); + ThrowOnError(GetApi().SessionGetInputName(this->p_, i, allocator, &name)); input_names.push_back(name); } @@ -1022,7 +1022,7 @@ inline std::vector ConstSessionImpl::GetOutputNames() const { for (size_t i = 0; i < num_inputs; ++i) { char* name = nullptr; - ThrowOnError(GetApi().SessionGetOutputName(p_, i, allocator, &name)); + ThrowOnError(GetApi().SessionGetOutputName(this->p_, i, allocator, &name)); output_names.push_back(name); } @@ -1039,7 +1039,7 @@ inline std::vector ConstSessionImpl::GetOverridableInitializerNa for (size_t i = 0; i < num_initializers; ++i) { char* name = nullptr; - ThrowOnError(GetApi().SessionGetOverridableInitializerName(p_, i, allocator, &name)); + ThrowOnError(GetApi().SessionGetOverridableInitializerName(this->p_, i, allocator, &name)); initializer_names.push_back(name); } @@ -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().ApplyModelToModelBuilderSession(this->p_, model)); + ThrowOnError(GetModelBuilderApi().ApplyModelToSession(this->p_, model)); ThrowOnError(GetModelBuilderApi().FinalizeModelBuilderSession(this->p_, options, prepacked_weights_container)); } @@ -2400,18 +2400,21 @@ inline ValueInfo::ValueInfo(const std::string& name, ConstTypeInfo& type_info) { ThrowOnError(GetModelBuilderApi().CreateValueInfo(name.c_str(), type_info, &p_)); } namespace detail { +template <> inline std::string ValueInfoImpl::Name() const { const char* name = nullptr; - ThrowOnError(GetModelBuilderApi().GetValueInfoName(p_, &name)); + ThrowOnError(GetModelBuilderApi().GetValueInfoName(this->p_, &name)); return name; } +template <> inline ConstTypeInfo ValueInfoImpl::TypeInfo() const { const OrtTypeInfo* type_info = nullptr; - ThrowOnError(GetModelBuilderApi().GetValueInfoTypeInfo(p_, &type_info)); + ThrowOnError(GetModelBuilderApi().GetValueInfoTypeInfo(this->p_, &type_info)); return ConstTypeInfo{type_info}; } +template <> inline void GraphImpl::SetInputs(std::vector& inputs) { std::vector inputs_ptrs; inputs_ptrs.reserve(inputs.size()); @@ -2426,6 +2429,7 @@ inline void GraphImpl::SetInputs(std::vector& inputs) { std::for_each(inputs.begin(), inputs.end(), [](ValueInfo& vi) { vi.release(); }); } +template <> inline void GraphImpl::SetOutputs(std::vector& outputs) { std::vector outputs_ptrs; outputs_ptrs.reserve(outputs.size()); @@ -2438,11 +2442,13 @@ inline void GraphImpl::SetOutputs(std::vector& outputs) { std::for_each(outputs.begin(), outputs.end(), [](ValueInfo& vi) { vi.release(); }); } +template <> inline void GraphImpl::AddInitializer(const std::string& name, Value& initializer, bool data_is_external) { // Graph takes ownership of `initializer` ThrowOnError(GetModelBuilderApi().AddInitializerToGraph(p_, name.c_str(), initializer.release(), data_is_external)); } +template <> inline void GraphImpl::AddNode(Node& node) { // Graph takes ownership of `node` ThrowOnError(GetModelBuilderApi().AddNodeToGraph(p_, node.release()));