Skip to content

Commit

Permalink
Add an API for retrieve ORT version (#1263)
Browse files Browse the repository at this point in the history
* Add an API for retrieve ORT version
  • Loading branch information
snnn committed Jun 20, 2019
1 parent 5b87f07 commit 766c6b6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ endif()

set(REPO_ROOT ${PROJECT_SOURCE_DIR}/..)
set(ONNXRUNTIME_ROOT ${PROJECT_SOURCE_DIR}/../onnxruntime)
file (STRINGS "${REPO_ROOT}/VERSION_NUMBER" VERSION_NUMBER)
file (STRINGS "${REPO_ROOT}/VERSION_NUMBER" ORT_VERSION)

if(onnxruntime_USE_OPENMP)
find_package(OpenMP)
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ add_custom_command(OUTPUT ${SYMBOL_FILE}

add_custom_target(onnxruntime_generate_def ALL DEPENDS ${SYMBOL_FILE})
add_library(onnxruntime SHARED ${onnxruntime_session_srcs})
set_target_properties(onnxruntime PROPERTIES VERSION ${VERSION_NUMBER})
set_target_properties(onnxruntime PROPERTIES VERSION ${ORT_VERSION})
add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT})
onnxruntime_add_include_to_target(onnxruntime gsl)
Expand Down
1 change: 1 addition & 0 deletions cmake/onnxruntime_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
#cmakedefine HAS_USELESS_CAST
#cmakedefine HAS_IGNORED_ATTRIBUTES
#cmakedefine HAS_DEPRECATED_COPY
#cmakedefine ORT_VERSION "@ORT_VERSION@"
1 change: 1 addition & 0 deletions include/onnxruntime/core/session/onnxruntime_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ ORT_API_STATUS(OrtAllocatorGetInfo, _In_ const OrtAllocator* ptr, _Out_ const Or
ORT_API_STATUS(OrtCreateDefaultAllocator, _Out_ OrtAllocator** out);
ORT_API(void, OrtReleaseAllocator, _In_ OrtAllocator* allocator);

ORT_API(const char*, OrtGetVersionString);
/**
* \param msg A null-terminated string. Its content will be copied into the newly created OrtStatus
*/
Expand Down
3 changes: 2 additions & 1 deletion onnxruntime/core/providers/cpu/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ OrtGetTypeInfo
OrtGetValue
OrtGetValueCount
OrtGetValueType
OrtGetVersionString
OrtIsTensor
OrtOnnxTypeFromTypeInfo
OrtReleaseAllocator
Expand Down Expand Up @@ -76,9 +77,9 @@ OrtSessionGetOutputName
OrtSessionGetOutputTypeInfo
OrtSessionOptionsAppendExecutionProvider_CPU
OrtSetDimensions
OrtSetSessionGraphOptimizationLevel
OrtSetSessionLogId
OrtSetSessionLogVerbosityLevel
OrtSetSessionGraphOptimizationLevel
OrtSetSessionThreadPoolSize
OrtSetTensorElementType
OrtTensorProtoToOrtValue
4 changes: 4 additions & 0 deletions onnxruntime/core/session/onnxruntime_c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ ORT_API_STATUS_IMPL(OrtCreateEnvWithCustomLogger, OrtLoggingFunction logging_fun
API_IMPL_END
}

ORT_API(const char*, OrtGetVersionString) {
return ORT_VERSION;
}

ORT_API_STATUS_IMPL(OrtCreateEnv, OrtLoggingLevel default_warning_level,
_In_ const char* logid, _Out_ OrtEnv** out) {
API_IMPL_BEGIN
Expand Down
5 changes: 4 additions & 1 deletion onnxruntime/test/onnx/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ void usage() {
"\t-e [EXECUTION_PROVIDER]: EXECUTION_PROVIDER could be 'cpu', 'cuda', 'mkldnn', 'tensorrt', 'ngraph' or 'openvino'. "
"Default: 'cpu'.\n"
"\t-x: Use parallel executor, default (without -x): sequential executor.\n"
"\t-h: help\n");
"\t-h: help\n"
"\n"
"onnxruntime version: %s\n",
OrtGetVersionString());
}

#ifdef _WIN32
Expand Down

0 comments on commit 766c6b6

Please sign in to comment.