Remove previously deprecated API (#12935)

Remove previously deprecated API
Format JS code, address review comments
NPM Formatting
This commit is contained in:
Dmitri Smirnov 2022-09-14 10:58:03 -07:00 committed by GitHub
parent 1ef1029163
commit bc2df1bf95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 63 additions and 186 deletions

View file

@ -403,13 +403,6 @@ struct ModelMetadata : Base<OrtModelMetadata> {
explicit ModelMetadata(std::nullptr_t) {} ///< Create an empty ModelMetadata object, must be assigned a valid one to be used
explicit ModelMetadata(OrtModelMetadata* p) : Base<OrtModelMetadata>{p} {} ///< Used for interop with the C API
/** \deprecated use GetProducerNameAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetProducerName(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetProducerName
/** \brief Returns a copy of the producer name.
*
* \param allocator to allocate memory for the copy of the name returned
@ -418,13 +411,6 @@ struct ModelMetadata : Base<OrtModelMetadata> {
*/
AllocatedStringPtr GetProducerNameAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetProducerName
/** \deprecated use GetGraphNameAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetGraphName(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetGraphName
/** \brief Returns a copy of the graph name.
*
* \param allocator to allocate memory for the copy of the name returned
@ -433,13 +419,6 @@ struct ModelMetadata : Base<OrtModelMetadata> {
*/
AllocatedStringPtr GetGraphNameAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetGraphName
/** \deprecated use GetDomainAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetDomain(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetDomain
/** \brief Returns a copy of the domain name.
*
* \param allocator to allocate memory for the copy of the name returned
@ -448,13 +427,6 @@ struct ModelMetadata : Base<OrtModelMetadata> {
*/
AllocatedStringPtr GetDomainAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetDomain
/** \deprecated use GetDescriptionAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetDescription(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetDescription
/** \brief Returns a copy of the description.
*
* \param allocator to allocate memory for the copy of the string returned
@ -463,13 +435,6 @@ struct ModelMetadata : Base<OrtModelMetadata> {
*/
AllocatedStringPtr GetDescriptionAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetDescription
/** \deprecated use GetGraphDescriptionAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetGraphDescription(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetGraphDescription
/** \brief Returns a copy of the graph description.
*
* \param allocator to allocate memory for the copy of the string returned
@ -478,22 +443,14 @@ struct ModelMetadata : Base<OrtModelMetadata> {
*/
AllocatedStringPtr GetGraphDescriptionAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetGraphDescription
/** \deprecated use GetCustomMetadataMapKeysAllocated()
* [[deprecated]]
* This interface produces multiple pointers that must be released
* by the specified allocator and is often leaked. Not exception safe.
/** \brief Returns a vector of copies of the custom metadata keys.
*
* \param allocator to allocate memory for the copy of the string returned
* \return a instance std::vector of smart pointers that would deallocate the buffers when out of scope.
* The OrtAllocator instance must be valid at the point of memory release.
*/
char** GetCustomMetadataMapKeys(OrtAllocator* allocator, _Out_ int64_t& num_keys) const; ///< Wraps OrtApi::ModelMetadataGetCustomMetadataMapKeys
std::vector<AllocatedStringPtr> GetCustomMetadataMapKeysAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetCustomMetadataMapKeys
/** \deprecated use LookupCustomMetadataMapAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* LookupCustomMetadataMap(const char* key, OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataLookupCustomMetadataMap
/** \brief Looks up a value by a key in the Custom Metadata map
*
* \param key zero terminated string key to lookup
@ -551,13 +508,6 @@ struct Session : Base<OrtSession> {
size_t GetOutputCount() const; ///< Returns the number of model outputs
size_t GetOverridableInitializerCount() const; ///< Returns the number of inputs that have defaults that can be overridden
/** \deprecated use GetInputNameAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetInputName(size_t index, OrtAllocator* allocator) const; ///< Wraps OrtApi::SessionGetInputName
/** \brief Returns a copy of input name at the specified index.
*
* \param index must less than the value returned by GetInputCount()
@ -567,13 +517,6 @@ struct Session : Base<OrtSession> {
*/
AllocatedStringPtr GetInputNameAllocated(size_t index, OrtAllocator* allocator) const;
/** \deprecated use GetOutputNameAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetOutputName(size_t index, OrtAllocator* allocator) const; ///< Wraps OrtApi::SessionGetOutputName
/** \brief Returns a copy of output name at then specified index.
*
* \param index must less than the value returned by GetOutputCount()
@ -583,13 +526,6 @@ struct Session : Base<OrtSession> {
*/
AllocatedStringPtr GetOutputNameAllocated(size_t index, OrtAllocator* allocator) const;
/** \deprecated use GetOverridableInitializerNameAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* GetOverridableInitializerName(size_t index, OrtAllocator* allocator) const; ///< Wraps OrtApi::SessionGetOverridableInitializerName
/** \brief Returns a copy of the overridable initializer name at then specified index.
*
* \param index must less than the value returned by GetOverridableInitializerCount()
@ -599,13 +535,6 @@ struct Session : Base<OrtSession> {
*/
AllocatedStringPtr GetOverridableInitializerNameAllocated(size_t index, OrtAllocator* allocator) const; ///< Wraps OrtApi::SessionGetOverridableInitializerName
/** \deprecated use EndProfilingAllocated()
* [[deprecated]]
* This interface produces a pointer that must be released
* by the specified allocator and is often leaked. Not exception safe.
*/
char* EndProfiling(OrtAllocator* allocator) const; ///< Wraps OrtApi::SessionEndProfiling
/** \brief Returns a copy of the profiling file name.
*
* \param allocator to allocate memory for the copy of the string returned

View file

@ -650,18 +650,6 @@ inline size_t Session::GetOverridableInitializerCount() const {
return out;
}
inline char* Session::GetInputName(size_t index, OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().SessionGetInputName(p_, index, allocator, &out));
return out;
}
inline char* Session::GetOutputName(size_t index, OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().SessionGetOutputName(p_, index, allocator, &out));
return out;
}
inline AllocatedStringPtr Session::GetInputNameAllocated(size_t index, OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().SessionGetInputName(p_, index, allocator, &out));
@ -674,24 +662,12 @@ inline AllocatedStringPtr Session::GetOutputNameAllocated(size_t index, OrtAlloc
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char* Session::GetOverridableInitializerName(size_t index, OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().SessionGetOverridableInitializerName(p_, index, allocator, &out));
return out;
}
inline AllocatedStringPtr Session::GetOverridableInitializerNameAllocated(size_t index, OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().SessionGetOverridableInitializerName(p_, index, allocator, &out));
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char* Session::EndProfiling(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().SessionEndProfiling(p_, allocator, &out));
return out;
}
inline AllocatedStringPtr Session::EndProfilingAllocated(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().SessionEndProfiling(p_, allocator, &out));
@ -710,84 +686,42 @@ inline ModelMetadata Session::GetModelMetadata() const {
return ModelMetadata{out};
}
inline char* ModelMetadata::GetProducerName(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetProducerName(p_, allocator, &out));
return out;
}
inline AllocatedStringPtr ModelMetadata::GetProducerNameAllocated(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetProducerName(p_, allocator, &out));
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char* ModelMetadata::GetGraphName(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetGraphName(p_, allocator, &out));
return out;
}
inline AllocatedStringPtr ModelMetadata::GetGraphNameAllocated(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetGraphName(p_, allocator, &out));
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char* ModelMetadata::GetDomain(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetDomain(p_, allocator, &out));
return out;
}
inline AllocatedStringPtr ModelMetadata::GetDomainAllocated(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetDomain(p_, allocator, &out));
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char* ModelMetadata::GetDescription(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetDescription(p_, allocator, &out));
return out;
}
inline AllocatedStringPtr Ort::ModelMetadata::GetDescriptionAllocated(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetDescription(p_, allocator, &out));
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char* ModelMetadata::GetGraphDescription(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetGraphDescription(p_, allocator, &out));
return out;
}
inline AllocatedStringPtr ModelMetadata::GetGraphDescriptionAllocated(OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataGetGraphDescription(p_, allocator, &out));
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char* ModelMetadata::LookupCustomMetadataMap(const char* key, OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataLookupCustomMetadataMap(p_, allocator, key, &out));
return out;
}
inline AllocatedStringPtr ModelMetadata::LookupCustomMetadataMapAllocated(const char* key, OrtAllocator* allocator) const {
char* out;
ThrowOnError(GetApi().ModelMetadataLookupCustomMetadataMap(p_, allocator, key, &out));
return AllocatedStringPtr(out, detail::AllocatedFree(allocator));
}
inline char** ModelMetadata::GetCustomMetadataMapKeys(OrtAllocator* allocator, _Out_ int64_t& num_keys) const {
char** out;
ThrowOnError(GetApi().ModelMetadataGetCustomMetadataMapKeys(p_, allocator, &out, &num_keys));
return out;
}
inline std::vector<AllocatedStringPtr> ModelMetadata::GetCustomMetadataMapKeysAllocated(OrtAllocator* allocator) const {
auto deletor = detail::AllocatedFree(allocator);
std::vector<AllocatedStringPtr> result;

View file

@ -83,7 +83,8 @@ Napi::Value InferenceSessionWrap::LoadModel(const Napi::CallbackInfo &info) {
size_t count = session_->GetInputCount();
inputNames_.reserve(count);
for (size_t i = 0; i < count; i++) {
inputNames_.emplace_back(session_->GetInputName(i, allocator));
auto inp_name = session_->GetInputNameAllocated(i, allocator);
inputNames_.emplace_back(inp_name.get());
auto typeInfo = session_->GetInputTypeInfo(i);
auto onnxType = typeInfo.GetONNXType();
inputTypes_.emplace_back(onnxType);
@ -95,7 +96,8 @@ Napi::Value InferenceSessionWrap::LoadModel(const Napi::CallbackInfo &info) {
count = session_->GetOutputCount();
outputNames_.reserve(count);
for (size_t i = 0; i < count; i++) {
outputNames_.emplace_back(session_->GetOutputName(i, allocator));
auto out_name = session_->GetOutputNameAllocated(i, allocator);
outputNames_.emplace_back(out_name.get());
auto typeInfo = session_->GetOutputTypeInfo(i);
auto onnxType = typeInfo.GetONNXType();
outputTypes_.emplace_back(onnxType);

View file

@ -12,9 +12,10 @@
struct SessionInfo {
std::unique_ptr<Ort::Session> session;
std::vector<Ort::MemoryAllocation> allocations;
std::vector<const char *> inputNames;
std::vector<Ort::AllocatedStringPtr> inputNames_ptrs;
std::vector<const char *> outputNames;
std::vector<Ort::AllocatedStringPtr> outputNames_ptrs;
};
static Ort::Env *ortEnv = new Ort::Env(ORT_LOGGING_LEVEL_INFO, "Default");
@ -90,16 +91,16 @@ RCT_EXPORT_METHOD(run
sessionInfo->inputNames.reserve(sessionInfo->session->GetInputCount());
for (size_t i = 0; i < sessionInfo->session->GetInputCount(); ++i) {
auto inputName = sessionInfo->session->GetInputName(i, ortAllocator);
sessionInfo->allocations.emplace_back(ortAllocator, inputName, strlen(inputName) + 1);
sessionInfo->inputNames.emplace_back(inputName);
auto inputName = sessionInfo->session->GetInputNameAllocated(i, ortAllocator);
sessionInfo->inputNames.emplace_back(inputName.get());
sessionInfo->inputNames_ptrs.emplace_back(std::move(inputName));
}
sessionInfo->outputNames.reserve(sessionInfo->session->GetOutputCount());
for (size_t i = 0; i < sessionInfo->session->GetOutputCount(); ++i) {
auto outputName = sessionInfo->session->GetOutputName(i, ortAllocator);
sessionInfo->allocations.emplace_back(ortAllocator, outputName, strlen(outputName) + 1);
sessionInfo->outputNames.emplace_back(outputName);
auto outputName = sessionInfo->session->GetOutputNameAllocated(i, ortAllocator);
sessionInfo->outputNames.emplace_back(outputName.get());
sessionInfo->outputNames_ptrs.emplace_back(std::move(outputName));
}
value = [NSValue valueWithPointer:(void *)sessionInfo];

View file

@ -5,6 +5,7 @@
#import <XCTest/XCTest.h>
#import <onnxruntime/onnxruntime_cxx_api.h>
#include <vector>
@interface TensorHelperTest : XCTestCase
@ -142,27 +143,29 @@ static void testCreateOutputTensorT(const std::array<T, 5> &outValues, std::func
NSBundle *bundle = [NSBundle bundleForClass:[TensorHelperTest class]];
NSString *dataPath = [bundle pathForResource:testDataFileName ofType:testDataFileExtension];
std::unique_ptr<Ort::Env> ortEnv{new Ort::Env(ORT_LOGGING_LEVEL_INFO, "Default")};
Ort::Env ortEnv{ORT_LOGGING_LEVEL_INFO, "Default"};
Ort::SessionOptions sessionOptions;
std::unique_ptr<Ort::Session> session{new Ort::Session(*ortEnv, [dataPath UTF8String], sessionOptions)};
Ort::Session session{ortEnv, [dataPath UTF8String], sessionOptions};
Ort::AllocatorWithDefaultOptions ortAllocator;
std::vector<Ort::MemoryAllocation> allocations;
std::vector<Ort::AllocatedStringPtr> names;
names.reserve(session.GetInputCount() + session.GetOutputCount());
std::vector<const char *> inputNames;
inputNames.reserve(session->GetInputCount());
for (size_t i = 0; i < session->GetInputCount(); ++i) {
auto inputName = session->GetInputName(i, ortAllocator);
allocations.emplace_back(ortAllocator, inputName, strlen(inputName) + 1);
inputNames.emplace_back(inputName);
inputNames.reserve(session.GetInputCount());
for (size_t i = 0; i < session.GetInputCount(); ++i) {
auto inputName = session.GetInputNameAllocated(i, ortAllocator);
inputNames.emplace_back(inputName.get());
names.emplace_back(std::move(inputName));
}
std::vector<const char *> outputNames;
outputNames.reserve(session->GetOutputCount());
for (size_t i = 0; i < session->GetOutputCount(); ++i) {
auto outputName = session->GetOutputName(i, ortAllocator);
allocations.emplace_back(ortAllocator, outputName, strlen(outputName) + 1);
outputNames.emplace_back(outputName);
outputNames.reserve(session.GetOutputCount());
for (size_t i = 0; i < session.GetOutputCount(); ++i) {
auto outputName = session.GetOutputNameAllocated(i, ortAllocator);
outputNames.emplace_back(outputName.get());
names.emplace_back(std::move(outputName));
}
NSMutableDictionary *inputTensorMap = [NSMutableDictionary dictionary];
@ -185,7 +188,7 @@ static void testCreateOutputTensorT(const std::array<T, 5> &outValues, std::func
NSString *dataEncoded = [byteBufferRef base64EncodedStringWithOptions:0];
inputTensorMap[@"data"] = dataEncoded;
std::vector<Ort::MemoryAllocation> allocations;
Ort::Value inputTensor = [TensorHelper createInputTensor:inputTensorMap
ortAllocator:ortAllocator
allocations:allocations];
@ -194,8 +197,8 @@ static void testCreateOutputTensorT(const std::array<T, 5> &outValues, std::func
feeds.emplace_back(std::move(inputTensor));
Ort::RunOptions runOptions;
auto output = session->Run(runOptions, inputNames.data(), feeds.data(), inputNames.size(), outputNames.data(),
outputNames.size());
auto output = session.Run(runOptions, inputNames.data(), feeds.data(), inputNames.size(), outputNames.data(),
outputNames.size());
NSDictionary *resultMap = [TensorHelper createOutputTensor:outputNames values:output];

View file

@ -168,25 +168,21 @@ NS_ASSUME_NONNULL_BEGIN
auto getName = [&session = *_session, namedValueType](size_t i, OrtAllocator* allocator) {
if (namedValueType == NamedValueType::Input) {
return session.GetInputName(i, allocator);
return session.GetInputNameAllocated(i, allocator);
} else if (namedValueType == NamedValueType::OverridableInitializer) {
return session.GetOverridableInitializerName(i, allocator);
return session.GetOverridableInitializerNameAllocated(i, allocator);
} else {
return session.GetOutputName(i, allocator);
return session.GetOutputNameAllocated(i, allocator);
}
};
const size_t nameCount = getCount();
Ort::AllocatorWithDefaultOptions allocator;
auto deleter = [ortAllocator = static_cast<OrtAllocator*>(allocator)](void* p) {
ortAllocator->Free(ortAllocator, p);
};
NSMutableArray<NSString*>* result = [NSMutableArray arrayWithCapacity:nameCount];
for (size_t i = 0; i < nameCount; ++i) {
auto name = std::unique_ptr<char[], decltype(deleter)>{getName(i, allocator), deleter};
auto name = getName(i, allocator);
NSString* nameNsstr = [NSString stringWithUTF8String:name.get()];
NSAssert(nameNsstr != nil, @"nameNsstr must not be nil");
[result addObject:nameNsstr];

View file

@ -67,6 +67,7 @@ void run_ort_trt2() {
// print number of model input nodes
size_t num_input_nodes = session.GetInputCount();
std::vector<Ort::AllocatedStringPtr> input_node_names_ptr;
std::vector<const char*> input_node_names(num_input_nodes);
std::vector<int64_t> input_node_dims; // simplify... this model has only 1 input node {1, 3, 224, 224}.
// Otherwise need vector<vector<>>
@ -76,9 +77,10 @@ void run_ort_trt2() {
// iterate over all input nodes
for (int i = 0; i < num_input_nodes; i++) {
// print input node names
char* input_name = session.GetInputName(i, allocator);
printf("Input %d : name=%s\n", i, input_name);
input_node_names[i] = input_name;
auto input_name = session.GetInputNameAllocated(i, allocator);
printf("Input %d : name=%s\n", i, input_name.get());
input_node_names[i] = input_name.get();
input_node_names_ptr.push_back(std::move(input_name));
// print input node types
Ort::TypeInfo type_info = session.GetInputTypeInfo(i);
@ -192,6 +194,7 @@ void ort_trt_run_with_default_options() {
// print number of model input nodes
size_t num_input_nodes = session.GetInputCount();
std::vector<Ort::AllocatedStringPtr> input_node_names_ptr;
std::vector<const char*> input_node_names(num_input_nodes);
std::vector<int64_t> input_node_dims; // simplify... this model has only 1 input node {1, 3, 224, 224}.
// Otherwise need vector<vector<>>
@ -201,9 +204,10 @@ void ort_trt_run_with_default_options() {
// iterate over all input nodes
for (int i = 0; i < num_input_nodes; i++) {
// print input node names
char* input_name = session.GetInputName(i, allocator);
printf("Input %d : name=%s\n", i, input_name);
input_node_names[i] = input_name;
auto input_name = session.GetInputNameAllocated(i, allocator);
printf("Input %d : name=%s\n", i, input_name.get());
input_node_names[i] = input_name.get();
input_node_names_ptr.push_back(std::move(input_name));
// print input node types
Ort::TypeInfo type_info = session.GetInputTypeInfo(i);
@ -308,6 +312,7 @@ void run_ort_trt() {
// print number of model input nodes
size_t num_input_nodes = session.GetInputCount();
std::vector<Ort::AllocatedStringPtr> input_node_names_ptr;
std::vector<const char*> input_node_names(num_input_nodes);
std::vector<int64_t> input_node_dims; // simplify... this model has only 1 input node {1, 3, 224, 224}.
// Otherwise need vector<vector<>>
@ -317,9 +322,10 @@ void run_ort_trt() {
// iterate over all input nodes
for (int i = 0; i < num_input_nodes; i++) {
// print input node names
char* input_name = session.GetInputName(i, allocator);
printf("Input %d : name=%s\n", i, input_name);
input_node_names[i] = input_name;
auto input_name = session.GetInputNameAllocated(i, allocator);
printf("Input %d : name=%s\n", i, input_name.get());
input_node_names[i] = input_name.get();
input_node_names_ptr.push_back(std::move(input_name));
// print input node types
Ort::TypeInfo type_info = session.GetInputTypeInfo(i);

View file

@ -155,10 +155,14 @@ class OnnxPrediction {
//
std::vector<char*> input_names;
std::vector<Ort::AllocatedStringPtr> input_names_ptrs;
// Stores the output names
//
std::vector<char*> output_names;
std::vector<Ort::AllocatedStringPtr> output_names_ptrs;
// Create a list of output values
//
std::vector<Ort::Value> output_values{};

View file

@ -145,7 +145,8 @@ void OnnxPrediction::init() {
//
for (int i = 0; i < ptr_session->GetInputCount(); i++) {
// TODO Use push_back on input_names instead of assignment
input_names[i] = ptr_session->GetInputName(i, alloc);
input_names_ptrs.push_back(ptr_session->GetInputNameAllocated(i, alloc));
input_names[i] = input_names_ptrs.back().get();
input_values.emplace_back(nullptr);
}
@ -153,7 +154,8 @@ void OnnxPrediction::init() {
//
for (int i = 0; i < ptr_session->GetOutputCount(); i++) {
// TODO Use push_back on output_names instead of assignment
output_names[i] = ptr_session->GetOutputName(i, alloc);
output_names_ptrs.push_back(ptr_session->GetOutputNameAllocated(i, alloc));
output_names[i] = output_names_ptrs.back().get();
output_values.emplace_back(nullptr);
}
}