Skip to content

Commit 4c1c7c8

Browse files
Weiming Zhaoweimingzha0
Weiming Zhao
authored andcommitted
ODLA: add version check API
1 parent c83e363 commit 4c1c7c8

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

ODLA/include/ODLA/odla_version.h

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ extern "C" {
3333
//! \brief ODLA version number.
3434
#define ODLA_VERSION_NUMBER ((ODLA_MAJOR)*100 + (ODLA_MINOR)*10 + (OLDA_PATCH))
3535

36+
//! \brief Get version info of runtime library.
37+
/*!
38+
\return NULL-terminated string of version info.
39+
*/
40+
const char* odla_GetVersionString();
41+
3642
#ifdef __cplusplus
3743
} // C extern
3844
#endif
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//===- odla_impl_common.h -------------------------------------------------===//
2+
//
3+
// Copyright (C) 2019-2022 Alibaba Group Holding Limited.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
// =============================================================================
17+
18+
#ifndef _ODLA_PLATFORMS_ODLA_COMMON_H_
19+
#define _ODLA_PLATFORMS_ODLA_COMMON_H_
20+
21+
#include "version.inc"
22+
23+
#define STR_HELPER(x) #x
24+
#define STR(x) STR_HELPER(x)
25+
26+
#define VERSION_STR(major, minor, patch, build) \
27+
STR(major) "." STR(minor) "." STR(patch) "." STR(build)
28+
29+
#ifndef NDEBUG
30+
#define ODLA_BUILD_TYPE "DEBUG"
31+
#else
32+
#define ODLA_BUILD_TYPE "RELEASE"
33+
#endif
34+
35+
#define ODLA_VERSION_COMMON_INFO \
36+
"Repo: " ODLA_REPOSITORY ", Rev:" ODLA_REVISION "\nOS:" HALO_BUILT_OS \
37+
"\nBuild Type: " ODLA_BUILD_TYPE "\nBuilt on: " __DATE__ " " __TIME__
38+
39+
#define ODLA_VERSION_STR(lib_name, major, minor, patch, build, extra_info) \
40+
"ODLA library name: " lib_name "\nVersion: " VERSION_STR( \
41+
major, minor, patch, build) "\n" ODLA_VERSION_COMMON_INFO \
42+
"\n" extra_info
43+
#endif

ODLA/platforms/tensorrt/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ add_subdirectory(plugins)
3737
add_odla_library(odla_tensorrt SHARED odla_tensorrt.cc)
3838
add_dependencies(odla_tensorrt ODLA_TRTPLUGIN)
3939

40-
target_include_directories(odla_tensorrt PRIVATE ${CUDA_ROOT}/include)
40+
target_include_directories(odla_tensorrt PRIVATE ${CUDA_ROOT}/include ${CMAKE_BINARY_DIR}/include/halo)
4141
target_compile_options(odla_tensorrt PRIVATE -Wno-deprecated-declarations)
4242
target_link_libraries(odla_tensorrt ODLA ${nvinfer} ${CUDART_LIB} ${nvinfer_plugin})
4343
set_target_properties(odla_tensorrt PROPERTIES LINK_FLAGS

ODLA/platforms/tensorrt/odla_tensorrt.cc

+17-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <unordered_set>
3737
#include <vector>
3838

39-
#include "ODLA/odla_common.h"
39+
#include "../include/odla_impl_common.h"
4040
#include "common.h"
4141
#include "plugins/initPlugin.h"
4242

@@ -46,6 +46,22 @@ using namespace nvinfer1;
4646
#error This library requires minimum ODLA version 0.5
4747
#endif
4848

49+
#define ODLA_TRT_MAJOR HALO_VERSION_MAJOR
50+
#define ODLA_TRT_MINOR HALO_VERSION_MINOR
51+
#define ODLA_TRT_PATCH HALO_VERSION_PATCH
52+
#define ODLA_TRT_BUILD 0
53+
54+
const char* odla_GetVersionString() {
55+
#define EXTRA_INFO \
56+
"Built with TensorRT: " VERSION_STR(NV_TENSORRT_MAJOR, NV_TENSORRT_MINOR, \
57+
NV_TENSORRT_PATCH, NV_TENSORRT_BUILD)
58+
const char* version =
59+
ODLA_VERSION_STR("ODLA for TensorRT", ODLA_TRT_MAJOR, ODLA_TRT_MINOR,
60+
ODLA_TRT_PATCH, ODLA_TRT_BUILD, EXTRA_INFO);
61+
#undef EXTRA_INFO
62+
return version;
63+
}
64+
4965
// Explicitly load cuda runtime before all other ctors, so cuda rt will be
5066
// released after calling dtors of all other global objs. This avoids the error
5167
// of "driver shutting down".

0 commit comments

Comments
 (0)