Skip to content

Commit

Permalink
feats: add TensorRT related. ⬆️
Browse files Browse the repository at this point in the history
  • Loading branch information
Joker2770 committed Aug 2, 2024
1 parent 0a74369 commit a6c91c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ if(ENABLE_OPENVINO)
add_definitions(-DUSE_OPENVINO)
endif(ENABLE_OPENVINO)

option(ENABLE_TENSORRT OFF)
if(ENABLE_TENSORRT)
message("build project with TensorRT")
add_definitions(-DUSE_TENSORRT)
endif(ENABLE_TENSORRT)

include_directories("${ONNXRUNTIME_ROOTDIR}/include"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/src/pbrain-Z2I/toml11"
Expand Down
1 change: 1 addition & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOFTWARE.
// #define SMALL_BOARD_MODE
// #define USE_CUDA
// #define USE_OPENVINO
// #define USE_TENSORRT

#define CHANNEL_SIZE 3

Expand Down
8 changes: 8 additions & 0 deletions src/onnx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ NeuralNetwork::NeuralNetwork(const std::string model_path, const unsigned int ba
CheckStatus(g_ort, g_ort->SessionOptionsAppendExecutionProvider_OpenVINO(session_options, &OpenVINO_Options));
#endif

#ifdef USE_TENSORRT
const OrtApiBase* ptr_api_base = OrtGetApiBase();
const OrtApi* g_ort = ptr_api_base->GetApi(ORT_API_VERSION);
OrtTensorRTProviderOptions TensorRT_Options;
TensorRT_Options.device_id = 0;
CheckStatus(g_ort, g_ort->SessionOptionsAppendExecutionProvider_TensorRT(session_options, &TensorRT_Options));
#endif

#ifdef _WIN32
// std::wstring widestr = std::wstring(model_path.begin(), model_path.end());
std::wstring wstr(model_path.length(), L' ');
Expand Down

0 comments on commit a6c91c8

Please sign in to comment.