More C API changes. (#1519)

* Mention OrtCreateSessionFromArray in C API doc

* Cleanup a few inconsistencies in the C API.

* updates

* More updates
This commit is contained in:
Pranav Sharma 2019-07-29 18:35:28 -07:00 committed by GitHub
parent cf73f63cb9
commit 44ab301586
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 74 additions and 65 deletions

View file

@ -303,7 +303,7 @@ namespace Microsoft.ML.OnnxRuntime
OnnxValueType valueType;
unsafe
{
NativeApiStatus.VerifySuccess(NativeMethods.OrtOnnxTypeFromTypeInfo(typeInfo, new IntPtr(&valueType)));
NativeApiStatus.VerifySuccess(NativeMethods.OrtGetOnnxTypeFromTypeInfo(typeInfo, new IntPtr(&valueType)));
}
if (valueType != OnnxValueType.ONNX_TYPE_TENSOR && valueType != OnnxValueType.ONNX_TYPE_SPARSETENSOR)
{

View file

@ -87,7 +87,7 @@ namespace Microsoft.ML.OnnxRuntime
[DllImport(nativeLib, CharSet = charSet)]
public static extern IntPtr /*(OrtStatus*)*/OrtSessionGetOutputName(
IntPtr /*(OrtSession*)*/ session,
UIntPtr index,
UIntPtr index,
IntPtr /*(OrtAllocator*)*/ allocator,
out IntPtr /*(char**)*/name);
@ -253,7 +253,7 @@ namespace Microsoft.ML.OnnxRuntime
public static extern IntPtr /*(OrtStatus*)*/ OrtGetValueType(IntPtr /*(OrtValue*)*/ value, IntPtr /*(OnnxValueType*)*/ onnxtype);
[DllImport(nativeLib, CharSet = charSet)]
public static extern IntPtr /*(OrtStatus*)*/ OrtOnnxTypeFromTypeInfo(IntPtr /*(OrtTypeInfo*)*/ typeinfo, IntPtr /*(OnnxValueType*)*/ onnxtype);
public static extern IntPtr /*(OrtStatus*)*/ OrtGetOnnxTypeFromTypeInfo(IntPtr /*(OrtTypeInfo*)*/ typeinfo, IntPtr /*(OnnxValueType*)*/ onnxtype);
[DllImport(nativeLib, CharSet = charSet)]
public static extern IntPtr /*(OrtStatus*)*/ OrtGetValueCount(IntPtr /*(OrtValue*)*/ value, out IntPtr /*(size_t*)*/ count);

View file

@ -186,10 +186,10 @@ ORT_API_STATUS(OrtCreateEnvWithCustomLogger, OrtLoggingFunction logging_function
// execution of OrtCreateSession, or does the OrtSession retain a handle to the file/directory
// and continue to access throughout the OrtSession lifetime?
// What sort of access is needed to model_path : read or read/write?
ORT_API_STATUS(OrtCreateSession, _In_ OrtEnv* env, _In_ const ORTCHAR_T* model_path,
ORT_API_STATUS(OrtCreateSession, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path,
_In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out);
ORT_API_STATUS(OrtCreateSessionFromArray, _In_ OrtEnv* env, _In_ const void* model_data, size_t model_data_length,
ORT_API_STATUS(OrtCreateSessionFromArray, _In_ const OrtEnv* env, _In_ const void* model_data, size_t model_data_length,
_In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out);
ORT_API_STATUS(OrtRun, _Inout_ OrtSession* sess,
@ -203,43 +203,43 @@ ORT_API_STATUS(OrtRun, _Inout_ OrtSession* sess,
ORT_API_STATUS(OrtCreateSessionOptions, _Outptr_ OrtSessionOptions** options);
// create a copy of an existing OrtSessionOptions
ORT_API_STATUS(OrtCloneSessionOptions, _In_ OrtSessionOptions* in_options, _Outptr_ OrtSessionOptions** out_options);
ORT_API_STATUS(OrtEnableSequentialExecution, _In_ OrtSessionOptions* options);
ORT_API_STATUS(OrtDisableSequentialExecution, _In_ OrtSessionOptions* options);
ORT_API_STATUS(OrtCloneSessionOptions, _In_ const OrtSessionOptions* in_options, _Outptr_ OrtSessionOptions** out_options);
ORT_API_STATUS(OrtEnableSequentialExecution, _Inout_ OrtSessionOptions* options);
ORT_API_STATUS(OrtDisableSequentialExecution, _Inout_ OrtSessionOptions* options);
// Enable profiling for this session.
ORT_API_STATUS(OrtEnableProfiling, _In_ OrtSessionOptions* options, _In_ const ORTCHAR_T* profile_file_prefix);
ORT_API_STATUS(OrtDisableProfiling, _In_ OrtSessionOptions* options);
ORT_API_STATUS(OrtEnableProfiling, _Inout_ OrtSessionOptions* options, _In_ const ORTCHAR_T* profile_file_prefix);
ORT_API_STATUS(OrtDisableProfiling, _Inout_ OrtSessionOptions* options);
// Enable the memory pattern optimization.
// The idea is if the input shapes are the same, we could trace the internal memory allocation
// and generate a memory pattern for future request. So next time we could just do one allocation
// with a big chunk for all the internal memory allocation.
// Note: memory pattern optimization is only available when SequentialExecution enabled.
ORT_API_STATUS(OrtEnableMemPattern, _In_ OrtSessionOptions* options);
ORT_API_STATUS(OrtDisableMemPattern, _In_ OrtSessionOptions* options);
ORT_API_STATUS(OrtEnableMemPattern, _Inout_ OrtSessionOptions* options);
ORT_API_STATUS(OrtDisableMemPattern, _Inout_ OrtSessionOptions* options);
// Enable the memory arena on CPU
// Arena may pre-allocate memory for future usage.
// set this option to false if you don't want it.
ORT_API_STATUS(OrtEnableCpuMemArena, _In_ OrtSessionOptions* options);
ORT_API_STATUS(OrtDisableCpuMemArena, _In_ OrtSessionOptions* options);
ORT_API_STATUS(OrtEnableCpuMemArena, _Inout_ OrtSessionOptions* options);
ORT_API_STATUS(OrtDisableCpuMemArena, _Inout_ OrtSessionOptions* options);
// < logger id to use for session output
ORT_API_STATUS(OrtSetSessionLogId, _In_ OrtSessionOptions* options, const char* logid);
ORT_API_STATUS(OrtSetSessionLogId, _Inout_ OrtSessionOptions* options, const char* logid);
// < applies to session load, initialization, etc
ORT_API_STATUS(OrtSetSessionLogVerbosityLevel, _In_ OrtSessionOptions* options, int session_log_verbosity_level);
ORT_API_STATUS(OrtSetSessionLogVerbosityLevel, _Inout_ OrtSessionOptions* options, int session_log_verbosity_level);
// Set Graph optimization level.
// Available options are : 0, 1, 2.
// 0 -> Disable all optimizations
// 1 -> Enable basic optimizations
// 2 -> Enable all optimizations
ORT_API_STATUS(OrtSetSessionGraphOptimizationLevel, _In_ OrtSessionOptions* options, int graph_optimization_level);
ORT_API_STATUS(OrtSetSessionGraphOptimizationLevel, _Inout_ OrtSessionOptions* options, int graph_optimization_level);
// How many threads in the session thread pool.
ORT_API_STATUS(OrtSetSessionThreadPoolSize, _In_ OrtSessionOptions* options, int session_thread_pool_size);
ORT_API_STATUS(OrtSetSessionThreadPoolSize, _Inout_ OrtSessionOptions* options, int session_thread_pool_size);
/**
* To use additional providers, you must build ORT with the extra providers enabled. Then call one of these
@ -278,7 +278,7 @@ ORT_API_STATUS(OrtSessionGetOutputName, _In_ const OrtSession* sess, size_t inde
*/
ORT_API_STATUS(OrtCreateRunOptions, _Outptr_ OrtRunOptions** out);
ORT_API_STATUS(OrtRunOptionsSetRunLogVerbosityLevel, _In_ OrtRunOptions* options, int value);
ORT_API_STATUS(OrtRunOptionsSetRunLogVerbosityLevel, _Inout_ OrtRunOptions* options, int value);
ORT_API_STATUS(OrtRunOptionsSetRunTag, _In_ OrtRunOptions*, _In_ const char* run_tag);
ORT_API_STATUS(OrtRunOptionsGetRunLogVerbosityLevel, _In_ const OrtRunOptions* options, _Out_ int* out);
@ -286,8 +286,8 @@ ORT_API_STATUS(OrtRunOptionsGetRunTag, _In_ const OrtRunOptions*, _Out_ const ch
// Set a flag so that any running OrtRun* calls that are using this instance of OrtRunOptions
// will exit as soon as possible if the flag is true.
// flag can be either 1 (true) or 0 (false)
ORT_API_STATUS(OrtRunOptionsSetTerminate, _In_ OrtRunOptions* options, _In_ int flag);
ORT_API_STATUS(OrtRunOptionsEnableTerminate, _Inout_ OrtRunOptions* options);
ORT_API_STATUS(OrtRunOptionsDisableTerminate, _Inout_ OrtRunOptions* options);
/**
* Create a tensor from an allocator. OrtReleaseValue will also release the buffer inside the output value
@ -321,7 +321,7 @@ ORT_API_STATUS(OrtIsTensor, _In_ const OrtValue* value, _Out_ int* out);
* \param s each A string array. Each string in this array must be null terminated.
* \param s_len length of s
*/
ORT_API_STATUS(OrtFillStringTensor, _In_ OrtValue* value, _In_ const char* const* s, size_t s_len);
ORT_API_STATUS(OrtFillStringTensor, _Inout_ OrtValue* value, _In_ const char* const* s, size_t s_len);
/**
* \param value A tensor created from OrtCreateTensor... function.
* \param len total data length, not including the trailing '\0' chars.
@ -368,19 +368,19 @@ ORT_API_STATUS(OrtGetTensorMemSizeInBytesFromTensorProto, _In_ const void* input
/**
* Don't free the 'out' value
*/
ORT_API_STATUS(OrtCastTypeInfoToTensorInfo, _In_ OrtTypeInfo*, _Out_ const OrtTensorTypeAndShapeInfo** out);
ORT_API_STATUS(OrtCastTypeInfoToTensorInfo, _In_ const OrtTypeInfo*, _Out_ const OrtTensorTypeAndShapeInfo** out);
/**
* Return OnnxType from OrtTypeInfo
*/
ORT_API_STATUS(OrtOnnxTypeFromTypeInfo, _In_ const OrtTypeInfo*, _Out_ enum ONNXType* out);
ORT_API_STATUS(OrtGetOnnxTypeFromTypeInfo, _In_ const OrtTypeInfo*, _Out_ enum ONNXType* out);
/**
* The 'out' value should be released by calling OrtReleaseTensorTypeAndShapeInfo
*/
ORT_API_STATUS(OrtCreateTensorTypeAndShapeInfo, _Outptr_ OrtTensorTypeAndShapeInfo** out);
ORT_API_STATUS(OrtSetTensorElementType, _In_ OrtTensorTypeAndShapeInfo*, enum ONNXTensorElementDataType type);
ORT_API_STATUS(OrtSetTensorElementType, _Inout_ OrtTensorTypeAndShapeInfo*, enum ONNXTensorElementDataType type);
/**
* \param info Created from OrtCreateTensorTypeAndShapeInfo() function
@ -525,7 +525,7 @@ ORT_API_STATUS(OrtGetValueCount, _In_ const OrtValue* value, _Out_ size_t* out);
* sequence. 'in' should be an arrary of N OrtValues.
* \value_type should be either map or sequence.
*/
ORT_API_STATUS(OrtCreateValue, _In_ OrtValue** in, size_t num_values, enum ONNXType value_type,
ORT_API_STATUS(OrtCreateValue, _In_ const OrtValue* const* in, size_t num_values, enum ONNXType value_type,
_Outptr_ OrtValue** out);
/*
@ -561,12 +561,12 @@ struct OrtCustomOpApi {
OrtStatus*(ORT_API_CALL* SetDimensions)(OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count);
OrtStatus*(ORT_API_CALL* GetTensorMutableData)(_Inout_ OrtValue* value, _Outptr_ void** data);
void(ORT_API_CALL* ReleaseTensorTypeAndShapeInfo)(OrtTensorTypeAndShapeInfo* input);
void(ORT_API_CALL* ReleaseTensorTypeAndShapeInfo)(_In_ OrtTensorTypeAndShapeInfo* input);
OrtStatus*(ORT_API_CALL* KernelContext_GetInputCount)(const OrtKernelContext* context, _Out_ size_t* out);
OrtStatus*(ORT_API_CALL* KernelContext_GetInput)(const OrtKernelContext* context, _In_ size_t index, _Out_ const OrtValue** out);
OrtStatus*(ORT_API_CALL* KernelContext_GetOutputCount)(const OrtKernelContext* context, _Out_ size_t* out);
OrtStatus*(ORT_API_CALL* KernelContext_GetOutput)(OrtKernelContext* context, _In_ size_t index, _In_ const int64_t* dim_values, size_t dim_count, _Outptr_ OrtValue** out);
OrtStatus*(ORT_API_CALL* KernelContext_GetInputCount)(_In_ const OrtKernelContext* context, _Out_ size_t* out);
OrtStatus*(ORT_API_CALL* KernelContext_GetInput)(_In_ const OrtKernelContext* context, _In_ size_t index, _Out_ const OrtValue** out);
OrtStatus*(ORT_API_CALL* KernelContext_GetOutputCount)(_In_ const OrtKernelContext* context, _Out_ size_t* out);
OrtStatus*(ORT_API_CALL* KernelContext_GetOutput)(_Inout_ OrtKernelContext* context, _In_ size_t index, _In_ const int64_t* dim_values, size_t dim_count, _Outptr_ OrtValue** out);
};
typedef struct OrtCustomOpApi OrtCustomOpApi;
@ -607,13 +607,13 @@ ORT_API_STATUS(OrtCreateCustomOpDomain, _In_ const char* domain, _Outptr_ OrtCus
* Add custom ops to the OrtCustomOpDomain
* Note: The OrtCustomOp* pointer must remain valid until the OrtCustomOpDomain using it is released
*/
ORT_API_STATUS(OrtCustomOpDomain_Add, _In_ OrtCustomOpDomain* custom_op_domain, _In_ OrtCustomOp* op);
ORT_API_STATUS(OrtCustomOpDomain_Add, _Inout_ OrtCustomOpDomain* custom_op_domain, _In_ OrtCustomOp* op);
/*
* Add a custom op domain to the OrtSessionOptions
* Note: The OrtCustomOpDomain* must not be deleted until the sessions using it are released
*/
ORT_API_STATUS(OrtAddCustomOpDomain, _In_ OrtSessionOptions* options, _In_ OrtCustomOpDomain* custom_op_domain);
ORT_API_STATUS(OrtAddCustomOpDomain, _Inout_ OrtSessionOptions* options, _In_ OrtCustomOpDomain* custom_op_domain);
/*
* END EXPERIMENTAL
*/

View file

@ -123,7 +123,8 @@ struct RunOptions : Base<OrtRunOptions> {
RunOptions& SetRunTag(const char* run_tag);
const char* GetRunTag() const;
RunOptions& SetTerminate(bool flag);
RunOptions& EnableTerminate();
RunOptions& DisableTerminate();
};
struct SessionOptions : Base<OrtSessionOptions> {

View file

@ -113,8 +113,13 @@ inline const char* RunOptions::GetRunTag() const {
return out;
}
inline RunOptions& RunOptions::SetTerminate(bool flag) {
ORT_THROW_ON_ERROR(OrtRunOptionsSetTerminate(p_, flag ? 1 : 0));
inline RunOptions& RunOptions::EnableTerminate() {
ORT_THROW_ON_ERROR(OrtRunOptionsEnableTerminate(p_));
return *this;
}
inline RunOptions& RunOptions::DisableTerminate() {
ORT_THROW_ON_ERROR(OrtRunOptionsDisableTerminate(p_));
return *this;
}
@ -284,7 +289,7 @@ inline Unowned<TensorTypeAndShapeInfo> TypeInfo::GetTensorTypeAndShapeInfo() con
inline ONNXType TypeInfo::GetONNXType() const {
ONNXType out;
ORT_THROW_ON_ERROR(OrtOnnxTypeFromTypeInfo(p_, &out));
ORT_THROW_ON_ERROR(OrtGetOnnxTypeFromTypeInfo(p_, &out));
return out;
}
@ -405,7 +410,7 @@ inline std::string CustomOpApi::KernelInfoGetAttribute<std::string>(_In_ const O
OrtReleaseStatus(status);
out.resize(size);
ORT_THROW_ON_ERROR(api_.KernelInfoGetAttribute_string(info, name, &out[0], &size));
out.resize(size - 1); // remove the terminating character '\0'
out.resize(size - 1); // remove the terminating character '\0'
} else {
ORT_THROW_ON_ERROR(status);
}

View file

@ -21,12 +21,12 @@ OrtTypeInfo::~OrtTypeInfo() {
OrtReleaseTensorTypeAndShapeInfo(data);
}
ORT_API_STATUS_IMPL(OrtOnnxTypeFromTypeInfo, _In_ const struct OrtTypeInfo* input, ONNXType* out) {
ORT_API_STATUS_IMPL(OrtGetOnnxTypeFromTypeInfo, _In_ const struct OrtTypeInfo* input, ONNXType* out) {
*out = input->type;
return nullptr;
}
ORT_API_STATUS_IMPL(OrtCastTypeInfoToTensorInfo, _In_ struct OrtTypeInfo* input, const struct OrtTensorTypeAndShapeInfo** out) {
ORT_API_STATUS_IMPL(OrtCastTypeInfoToTensorInfo, _In_ const struct OrtTypeInfo* input, const struct OrtTensorTypeAndShapeInfo** out) {
*out = input->type == ONNX_TYPE_TENSOR ? input->data : nullptr;
return nullptr;
}

View file

@ -33,10 +33,12 @@ ORT_API_STATUS_IMPL(OrtRunOptionsGetRunTag, _In_ const OrtRunOptions* options, c
return nullptr;
}
ORT_API_STATUS_IMPL(OrtRunOptionsSetTerminate, _In_ OrtRunOptions* options, int flag) {
if (!(flag == 0 || flag == 1)) {
return OrtCreateStatus(ORT_INVALID_ARGUMENT, "Invalid value for flag. Should be either 0 or 1");
}
options->terminate = flag;
ORT_API_STATUS_IMPL(OrtRunOptionsEnableTerminate, _Inout_ OrtRunOptions* options) {
options->terminate = true;
return nullptr;
}
ORT_API_STATUS_IMPL(OrtRunOptionsDisableTerminate, _Inout_ OrtRunOptions* options) {
options->terminate = false;
return nullptr;
}

View file

@ -51,7 +51,7 @@ OrtGetValueCount
OrtGetValueType
OrtGetVersionString
OrtIsTensor
OrtOnnxTypeFromTypeInfo
OrtGetOnnxTypeFromTypeInfo
OrtReleaseAllocator
OrtReleaseAllocatorInfo
OrtReleaseCustomOpDomain
@ -69,7 +69,8 @@ OrtRunOptionsGetRunLogVerbosityLevel
OrtRunOptionsGetRunTag
OrtRunOptionsSetRunLogVerbosityLevel
OrtRunOptionsSetRunTag
OrtRunOptionsSetTerminate
OrtRunOptionsEnableTerminate
OrtRunOptionsDisableTerminate
OrtSessionGetInputCount
OrtSessionGetInputName
OrtSessionGetInputTypeInfo

View file

@ -28,7 +28,7 @@ ORT_API(void, OrtReleaseSessionOptions, OrtSessionOptions* ptr) {
delete ptr;
}
ORT_API_STATUS_IMPL(OrtCloneSessionOptions, OrtSessionOptions* input, OrtSessionOptions** out) {
ORT_API_STATUS_IMPL(OrtCloneSessionOptions, const OrtSessionOptions* input, OrtSessionOptions** out) {
API_IMPL_BEGIN
*out = new OrtSessionOptions(*input);
return nullptr;

View file

@ -29,28 +29,28 @@ ORT_API_STATUS_IMPL(OrtKernelInfoGetAttribute_int64, _In_ const OrtKernelInfo* i
return onnxruntime::ToOrtStatus(status);
}
ORT_API_STATUS_IMPL(OrtKernelContext_GetInputCount, const OrtKernelContext* context, _Out_ size_t* out) {
ORT_API_STATUS_IMPL(OrtKernelContext_GetInputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out) {
*out = reinterpret_cast<const onnxruntime::OpKernelContextInternal*>(context)->InputCount();
return nullptr;
};
ORT_API_STATUS_IMPL(OrtKernelContext_GetOutputCount, const OrtKernelContext* context, _Out_ size_t* out) {
ORT_API_STATUS_IMPL(OrtKernelContext_GetOutputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out) {
*out = reinterpret_cast<const onnxruntime::OpKernelContextInternal*>(context)->OutputCount();
return nullptr;
};
ORT_API_STATUS_IMPL(OrtKernelContext_GetInput, const OrtKernelContext* context, _In_ size_t index, _Out_ const OrtValue** out) {
ORT_API_STATUS_IMPL(OrtKernelContext_GetInput, _In_ const OrtKernelContext* context, _In_ size_t index, _Out_ const OrtValue** out) {
*out = reinterpret_cast<const OrtValue*>(reinterpret_cast<const onnxruntime::OpKernelContextInternal*>(context)->GetInputMLValue(index));
return nullptr;
};
ORT_API_STATUS_IMPL(OrtKernelContext_GetOutput, OrtKernelContext* context, _In_ size_t index, _In_ const int64_t* dim_values, size_t dim_count, _Out_ OrtValue** out) {
ORT_API_STATUS_IMPL(OrtKernelContext_GetOutput, _Inout_ OrtKernelContext* context, _In_ size_t index, _In_ const int64_t* dim_values, size_t dim_count, _Out_ OrtValue** out) {
onnxruntime::TensorShape shape(dim_values, dim_count);
*out = reinterpret_cast<OrtValue*>(reinterpret_cast<onnxruntime::OpKernelContextInternal*>(context)->OutputMLValue(index, shape));
return nullptr;
};
ORT_API_STATUS_IMPL(OrtKernelInfoGetAttribute_string, _In_ const OrtKernelInfo* info, _In_ const char* name, _Out_ char* out, _Inout_ size_t *size) {
ORT_API_STATUS_IMPL(OrtKernelInfoGetAttribute_string, _In_ const OrtKernelInfo* info, _In_ const char* name, _Out_ char* out, _Inout_ size_t* size) {
std::string value;
auto status = reinterpret_cast<const onnxruntime::OpKernelInfo*>(info)->GetAttr<std::string>(name, &value);
if (status.IsOK()) {

View file

@ -147,7 +147,7 @@ ORT_API_STATUS_IMPL(OrtGetStringTensorDataLength, _In_ const OrtValue* value, _O
API_IMPL_END
}
ORT_API_STATUS_IMPL(OrtFillStringTensor, _In_ OrtValue* value, _In_ const char* const* s, size_t s_len) {
ORT_API_STATUS_IMPL(OrtFillStringTensor, _Inout_ OrtValue* value, _In_ const char* const* s, size_t s_len) {
TENSOR_READWRITE_API_BEGIN
auto* dst = tensor->MutableData<std::string>();
auto len = static_cast<size_t>(tensor->Shape().Size());
@ -365,7 +365,7 @@ ORT_API_STATUS_IMPL(OrtAddCustomOpDomain, _In_ OrtSessionOptions* options, OrtCu
namespace {
template <typename Loader>
OrtStatus* CreateSessionImpl(_In_ OrtEnv* env, _In_ const OrtSessionOptions* options,
OrtStatus* CreateSessionImpl(_In_ const OrtEnv* env, _In_ const OrtSessionOptions* options,
Loader loader, _Outptr_ OrtSession** out) {
auto sess = std::make_unique<::onnxruntime::InferenceSession>(
options == nullptr ? onnxruntime::SessionOptions() : options->value, env->loggingManager);
@ -395,7 +395,7 @@ OrtStatus* CreateSessionImpl(_In_ OrtEnv* env, _In_ const OrtSessionOptions* opt
}
} // namespace
ORT_API_STATUS_IMPL(OrtCreateSession, _In_ OrtEnv* env, _In_ const ORTCHAR_T* model_path,
ORT_API_STATUS_IMPL(OrtCreateSession, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path,
_In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out) {
API_IMPL_BEGIN
const auto loader = [model_path](InferenceSession& sess) {
@ -405,7 +405,7 @@ ORT_API_STATUS_IMPL(OrtCreateSession, _In_ OrtEnv* env, _In_ const ORTCHAR_T* mo
API_IMPL_END
}
ORT_API_STATUS_IMPL(OrtCreateSessionFromArray, _In_ OrtEnv* env, _In_ const void* model_data, size_t model_data_length,
ORT_API_STATUS_IMPL(OrtCreateSessionFromArray, _In_ const OrtEnv* env, _In_ const void* model_data, size_t model_data_length,
_In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out) {
API_IMPL_BEGIN
const auto loader = [model_data, model_data_length](InferenceSession& sess) {
@ -415,7 +415,7 @@ ORT_API_STATUS_IMPL(OrtCreateSessionFromArray, _In_ OrtEnv* env, _In_ const void
API_IMPL_END
}
ORT_API_STATUS_IMPL(OrtRun, _In_ OrtSession* sess,
ORT_API_STATUS_IMPL(OrtRun, _Inout_ OrtSession* sess,
_In_ const OrtRunOptions* run_options,
_In_ const char* const* input_names, _In_ const OrtValue* const* input, size_t input_len,
_In_ const char* const* output_names1, size_t output_names_len, _Outptr_ OrtValue** output) {
@ -477,7 +477,7 @@ ORT_API_STATUS_IMPL(OrtRun, _In_ OrtSession* sess,
API_IMPL_END
}
ORT_API_STATUS_IMPL(OrtGetTensorMutableData, _In_ OrtValue* value, _Outptr_ void** output) {
ORT_API_STATUS_IMPL(OrtGetTensorMutableData, _Inout_ OrtValue* value, _Outptr_ void** output) {
TENSOR_READWRITE_API_BEGIN
//TODO: test if it's a string tensor
*output = tensor->MutableDataRaw();
@ -933,7 +933,7 @@ ORT_API_STATUS_IMPL(OrtGetValue, const OrtValue* value, int index, OrtAllocator*
///////////////////
// OrtCreateValue
template <typename T>
static OrtStatus* OrtCreateValueImplSeqHelperMap(OrtValue** const in, size_t num_values, OrtValue** out) {
static OrtStatus* OrtCreateValueImplSeqHelperMap(const OrtValue* const* in, size_t num_values, OrtValue** out) {
using SeqType = std::vector<T>;
auto vec_ptr = std::make_unique<SeqType>();
vec_ptr->reserve(num_values);
@ -951,7 +951,7 @@ static OrtStatus* OrtCreateValueImplSeqHelperMap(OrtValue** const in, size_t num
}
template <typename T>
static OrtStatus* OrtCreateValueImplSeqHelper(OrtValue** in, size_t num_values, OrtValue** out) {
static OrtStatus* OrtCreateValueImplSeqHelper(const OrtValue* const* in, size_t num_values, OrtValue** out) {
using SeqType = std::vector<T>;
auto vec_ptr = std::make_unique<SeqType>();
vec_ptr->reserve(num_values);
@ -972,7 +972,7 @@ static OrtStatus* OrtCreateValueImplSeqHelper(OrtValue** in, size_t num_values,
return nullptr;
}
static OrtStatus* OrtCreateValueImplSeq(OrtValue** in, size_t num_values, OrtValue** out) {
static OrtStatus* OrtCreateValueImplSeq(const OrtValue* const* in, size_t num_values, OrtValue** out) {
// We only support limited sequence types. For the sake of simplicity the type of the first
// OrtValue* in OrtValue** will determine the type of the vector used to create the output OrtValue
// this type should be either a tensor of limited types or map of limited types
@ -1069,7 +1069,7 @@ static OrtStatus* OrtCreateValueImplMapHelper(const Tensor& key_tensor, const Te
}
}
static OrtStatus* OrtCreateValueImplMap(OrtValue** in, size_t num_values, OrtValue** out) {
static OrtStatus* OrtCreateValueImplMap(const OrtValue* const* in, size_t num_values, OrtValue** out) {
if (num_values != NUM_MAP_INDICES) {
return OrtCreateStatus(ORT_FAIL, "For map type num_values MUST be 2");
}
@ -1102,7 +1102,7 @@ static OrtStatus* OrtCreateValueImplMap(OrtValue** in, size_t num_values, OrtVal
return OrtCreateStatus(ORT_FAIL, "Key type is not supported yet.");
}
static OrtStatus* OrtCreateValueImpl(OrtValue** in, size_t num_values, enum ONNXType value_type, OrtValue** out) {
static OrtStatus* OrtCreateValueImpl(const OrtValue* const* in, size_t num_values, enum ONNXType value_type, OrtValue** out) {
if (num_values <= 0) {
return OrtCreateStatus(ORT_FAIL, "Number of values should be at least 1.");
}
@ -1115,7 +1115,7 @@ static OrtStatus* OrtCreateValueImpl(OrtValue** in, size_t num_values, enum ONNX
return OrtCreateStatus(ORT_FAIL, "Input is not of type sequence or map.");
}
ORT_API_STATUS_IMPL(OrtCreateValue, OrtValue** in, size_t num_values, enum ONNXType value_type, OrtValue** out) {
ORT_API_STATUS_IMPL(OrtCreateValue, const OrtValue* const* in, size_t num_values, enum ONNXType value_type, OrtValue** out) {
API_IMPL_BEGIN
return OrtCreateValueImpl(in, num_values, value_type, out);
API_IMPL_END