Skip to content

Commit

Permalink
Fix some linux build errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
skottmckay committed Dec 23, 2024
1 parent 351d12d commit 41fb824
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/onnxruntime/core/graph/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 12 additions & 6 deletions include/onnxruntime/core/session/onnxruntime_cxx_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ inline std::vector<std::string> ConstSessionImpl<T>::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);
}

Expand All @@ -1022,7 +1022,7 @@ inline std::vector<std::string> ConstSessionImpl<T>::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);
}

Expand All @@ -1039,7 +1039,7 @@ inline std::vector<std::string> ConstSessionImpl<T>::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);
}

Expand Down Expand Up @@ -1159,7 +1159,7 @@ inline void SessionImpl<T>::SetEpDynamicOptions(const char* const* keys, const c
template <typename T>
inline void SessionImpl<T>::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));
}

Expand Down Expand Up @@ -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<OrtValueInfo>::Name() const {
const char* name = nullptr;
ThrowOnError(GetModelBuilderApi().GetValueInfoName(p_, &name));
ThrowOnError(GetModelBuilderApi().GetValueInfoName(this->p_, &name));
return name;
}

template <>
inline ConstTypeInfo ValueInfoImpl<OrtValueInfo>::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<OrtGraph>::SetInputs(std::vector<ValueInfo>& inputs) {
std::vector<OrtValueInfo*> inputs_ptrs;
inputs_ptrs.reserve(inputs.size());
Expand All @@ -2426,6 +2429,7 @@ inline void GraphImpl<OrtGraph>::SetInputs(std::vector<ValueInfo>& inputs) {
std::for_each(inputs.begin(), inputs.end(), [](ValueInfo& vi) { vi.release(); });
}

template <>
inline void GraphImpl<OrtGraph>::SetOutputs(std::vector<ValueInfo>& outputs) {
std::vector<OrtValueInfo*> outputs_ptrs;
outputs_ptrs.reserve(outputs.size());
Expand All @@ -2438,11 +2442,13 @@ inline void GraphImpl<OrtGraph>::SetOutputs(std::vector<ValueInfo>& outputs) {
std::for_each(outputs.begin(), outputs.end(), [](ValueInfo& vi) { vi.release(); });
}

template <>
inline void GraphImpl<OrtGraph>::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<OrtGraph>::AddNode(Node& node) {
// Graph takes ownership of `node`
ThrowOnError(GetModelBuilderApi().AddNodeToGraph(p_, node.release()));
Expand Down

0 comments on commit 41fb824

Please sign in to comment.