Clarify naming of the API involving the RunOptions terminate flag. (#1768)

* Clarify naming of the RunOptions terminate flag.

* Update C# code to use new names.
This commit is contained in:
Scott McKay 2019-09-10 08:32:33 +10:00 committed by GitHub
parent 75f241d02c
commit 2e242a4089
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 19 deletions

View file

@ -237,10 +237,10 @@ namespace Microsoft.ML.OnnxRuntime
// 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.
[DllImport(nativeLib, CharSet = charSet)]
public static extern IntPtr /*(OrtStatus*)*/ OrtRunOptionsEnableTerminate(IntPtr /* OrtRunOptions* */ options);
public static extern IntPtr /*(OrtStatus*)*/ OrtRunOptionsSetTerminate(IntPtr /* OrtRunOptions* */ options);
[DllImport(nativeLib, CharSet = charSet)]
public static extern IntPtr /*(OrtStatus*)*/ OrtRunOptionsDisableTerminate(IntPtr /* OrtRunOptions* */ options);
public static extern IntPtr /*(OrtStatus*)*/ OrtRunOptionsUnsetTerminate(IntPtr /* OrtRunOptions* */ options);

View file

@ -65,7 +65,7 @@ namespace Microsoft.ML.OnnxRuntime
/// <summary>
/// Sets a flag to terminate any other Run() call that is using the same RunOptions object
/// Sets a flag to terminate all Run() calls that are currently using this RunOptions object
/// Default = false
/// </summary>
public bool Terminate
@ -78,12 +78,12 @@ namespace Microsoft.ML.OnnxRuntime
{
if (!_terminate && value)
{
NativeApiStatus.VerifySuccess(NativeMethods.OrtRunOptionsEnableTerminate(_nativePtr));
NativeApiStatus.VerifySuccess(NativeMethods.OrtRunOptionsSetTerminate(_nativePtr));
_terminate = true;
}
else if (_terminate && !value)
{
NativeApiStatus.VerifySuccess(NativeMethods.OrtRunOptionsDisableTerminate(_nativePtr));
NativeApiStatus.VerifySuccess(NativeMethods.OrtRunOptionsUnsetTerminate(_nativePtr));
_terminate = false;
}
}

View file

@ -300,10 +300,11 @@ ORT_API_STATUS(OrtRunOptionsGetRunLogVerbosityLevel, _In_ const OrtRunOptions* o
ORT_API_STATUS(OrtRunOptionsGetRunLogSeverityLevel, _In_ const OrtRunOptions* options, _Out_ int* out);
ORT_API_STATUS(OrtRunOptionsGetRunTag, _In_ const OrtRunOptions*, _Out_ const char** out);
// 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.
ORT_API_STATUS(OrtRunOptionsEnableTerminate, _Inout_ OrtRunOptions* options);
ORT_API_STATUS(OrtRunOptionsDisableTerminate, _Inout_ OrtRunOptions* options);
// Set a flag so that ALL incomplete OrtRun calls that are using this instance of OrtRunOptions
// will exit as soon as possible.
ORT_API_STATUS(OrtRunOptionsSetTerminate, _Inout_ OrtRunOptions* options);
// Unset the terminate flag to enable this OrtRunOptions instance being used in new OrtRun calls.
ORT_API_STATUS(OrtRunOptionsUnsetTerminate, _Inout_ OrtRunOptions* options);
/**
* Create a tensor from an allocator. OrtReleaseValue will also release the buffer inside the output value

View file

@ -125,8 +125,10 @@ struct RunOptions : Base<OrtRunOptions> {
RunOptions& SetRunTag(const char* run_tag);
const char* GetRunTag() const;
RunOptions& EnableTerminate();
RunOptions& DisableTerminate();
// terminate ALL currently executing Session::Run calls that were made using this RunOptions instance
RunOptions& SetTerminate();
// unset the terminate flag so this RunOptions instance can be used in a new Session::Run call
RunOptions& UnsetTerminate();
};
struct SessionOptions : Base<OrtSessionOptions> {

View file

@ -116,13 +116,13 @@ inline const char* RunOptions::GetRunTag() const {
return out;
}
inline RunOptions& RunOptions::EnableTerminate() {
ORT_THROW_ON_ERROR(OrtRunOptionsEnableTerminate(p_));
inline RunOptions& RunOptions::SetTerminate() {
ORT_THROW_ON_ERROR(OrtRunOptionsSetTerminate(p_));
return *this;
}
inline RunOptions& RunOptions::DisableTerminate() {
ORT_THROW_ON_ERROR(OrtRunOptionsDisableTerminate(p_));
inline RunOptions& RunOptions::UnsetTerminate() {
ORT_THROW_ON_ERROR(OrtRunOptionsUnsetTerminate(p_));
return *this;
}

View file

@ -43,12 +43,12 @@ ORT_API_STATUS_IMPL(OrtRunOptionsGetRunTag, _In_ const OrtRunOptions* options, c
return nullptr;
}
ORT_API_STATUS_IMPL(OrtRunOptionsEnableTerminate, _Inout_ OrtRunOptions* options) {
ORT_API_STATUS_IMPL(OrtRunOptionsSetTerminate, _Inout_ OrtRunOptions* options) {
options->terminate = true;
return nullptr;
}
ORT_API_STATUS_IMPL(OrtRunOptionsDisableTerminate, _Inout_ OrtRunOptions* options) {
ORT_API_STATUS_IMPL(OrtRunOptionsUnsetTerminate, _Inout_ OrtRunOptions* options) {
options->terminate = false;
return nullptr;
}

View file

@ -67,8 +67,8 @@ OrtRunOptionsGetRunTag
OrtRunOptionsSetRunLogVerbosityLevel
OrtRunOptionsSetRunLogSeverityLevel
OrtRunOptionsSetRunTag
OrtRunOptionsEnableTerminate
OrtRunOptionsDisableTerminate
OrtRunOptionsSetTerminate
OrtRunOptionsUnsetTerminate
OrtSessionGetInputCount
OrtSessionGetInputName
OrtSessionGetInputTypeInfo