Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions plugin_execution_providers/tensorrt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
cmake_minimum_required(VERSION 3.26)
project(TensorRTEp VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
set(plugin_ep_common_dir ${CMAKE_SOURCE_DIR}/../common)
include(${plugin_ep_common_dir}/cmake/onnxruntime_library_utils.cmake)

enable_language(CUDA) # via nvcc to get the CUDA tool kit
file(TO_CMAKE_PATH "/usr/local/cuda" CUDAToolkit_ROOT)
Expand All @@ -28,12 +30,17 @@ endif()
add_definitions(-DONNX_NAMESPACE=onnx)
add_definitions(-DONNX_ML)
add_definitions(-DNOMINMAX)
file(GLOB tensorrt_src "./*.cc" "./utils/*.cc" "./cuda/unary_elementwise_ops_impl.cu" "./*.h")
file(GLOB tensorrt_src "./src/*.cc" "./src/utils/*.cc" "./src/cuda/unary_elementwise_ops_impl.cu" "./src/*.h")
add_library(TensorRTEp SHARED ${tensorrt_src})

if (NOT ORT_HOME)
message(FATAL_ERROR "Please specify ORT_HOME, e.g. -DORT_HOME=/path/to/ort/")
endif()
set_onnxruntime_paths(
ORT_HOME ${ORT_HOME}
DEFAULT_ORT_VERSION "1.23.2"
ORT_INCLUDE_DIR_VAR ORT_INCLUDE_DIR
ORT_LIBRARY_DIR_VAR ORT_LIBRARY_DIR)

message(STATUS "ORT_LIBRARY_DIR: ${ORT_LIBRARY_DIR}")
message(STATUS "ORT_INCLUDE_DIR: ${ORT_INCLUDE_DIR}")

if (NOT TENSORRT_HOME)
message(FATAL_ERROR "Please specify TENSORRT_HOME, e.g. -DTENSORRT_HOME=/path/to/trt/")
Expand Down Expand Up @@ -111,7 +118,7 @@ if (WIN32) # Windows
"${DEPS_PATH}/onnx-build/${CMAKE_BUILD_TYPE}/onnx_proto.lib")

set(TRT_EP_LIB_LINK_FLAG
"-DEF:${CMAKE_SOURCE_DIR}/tensorrt_execution_provider.def")
"-DEF:${CMAKE_SOURCE_DIR}/src/tensorrt_execution_provider.def")

else() # Linux
set(ORT_LIB "${ORT_HOME}/lib/libonnxruntime.so")
Expand Down Expand Up @@ -142,7 +149,7 @@ set_property(TARGET TensorRTEp APPEND_STRING PROPERTY LINK_FLAGS
${TRT_EP_LIB_LINK_FLAG})

target_include_directories(TensorRTEp PUBLIC "${ORT_HOME}/include"
"./utils"
"./src/utils"
"/usr/local/cuda/include"
"${TENSORRT_HOME}/include"
"${DEPS_PATH}/flatbuffers-src/include"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct TensorrtComputeState {
std::string compute_capability;
size_t max_workspace_size = 1 << 30; // 1GB;
bool fp16_enable = false;
bool bf16_enable = false;
bool int8_enable = false;
bool int8_calibration_cache_available = false;
bool dla_enable = false;
Expand Down Expand Up @@ -276,6 +277,7 @@ struct TensorrtExecutionProvider : public OrtEp, public ApiPtrs {
size_t max_workspace_size_ = 1 << 30; // 1GB
bool fp16_enable_ = false;
bool int8_enable_ = false;
bool bf16_enable_ = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is bf16 support fully implemented? it looks like this is only used to determine whether to set the flag nvinfer1::NetworkDefinitionCreationFlag::kSTRONGLY_TYPED.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, added the missing parts for bf16 support.

bool dla_enable_ = false;
int dla_core_ = 0;
bool force_sequential_engine_build_ = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ constexpr const char* kMinSubgraphSize = "trt_min_subgraph_size";
constexpr const char* kMaxWorkspaceSize = "trt_max_workspace_size";
constexpr const char* kFp16Enable = "trt_fp16_enable";
constexpr const char* kInt8Enable = "trt_int8_enable";
constexpr const char* kBf16Enable = "trt_bf16_enable";
constexpr const char* kInt8CalibTable = "trt_int8_calibration_table_name";
constexpr const char* kInt8UseNativeCalibTable = "trt_int8_use_native_calibration_table";
constexpr const char* kDLAEnable = "trt_dla_enable";
Expand Down Expand Up @@ -95,6 +96,7 @@ TensorrtExecutionProviderInfo TensorrtExecutionProviderInfo::FromProviderOptions
.AddAssignmentToReference(tensorrt::provider_option_names::kMaxWorkspaceSize, info.max_workspace_size)
.AddAssignmentToReference(tensorrt::provider_option_names::kFp16Enable, info.fp16_enable)
.AddAssignmentToReference(tensorrt::provider_option_names::kInt8Enable, info.int8_enable)
.AddAssignmentToReference(tensorrt::provider_option_names::kBf16Enable, info.bf16_enable)
.AddAssignmentToReference(tensorrt::provider_option_names::kInt8CalibTable, info.int8_calibration_table_name)
.AddAssignmentToReference(tensorrt::provider_option_names::kInt8UseNativeCalibTable, info.int8_use_native_calibration_table)
.AddAssignmentToReference(tensorrt::provider_option_names::kDLAEnable, info.dla_enable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct TensorrtExecutionProviderInfo {
size_t max_workspace_size{1 << 30};
bool fp16_enable{false};
bool int8_enable{false};
bool bf16_enable{false};
std::string int8_calibration_table_name{""};
bool int8_use_native_calibration_table{false};
bool dla_enable{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ AllocatorUniquePtr<T> MakeUniquePtrFromOrtAllocator(OrtAllocator* ort_allocator,
return AllocatorUniquePtr<T>{p, [ort_allocator](T* p) { ort_allocator->Free(ort_allocator, p); }};
}

// Following helper functions/struct, GetNodeInputEdgeCount, GetOutputNodes, KahnsTopologicalSort, VisitorPriorityQueue, PriorityNodeCompare are added but are not used for now.
// TODO: They will be used for graph partition in the following PR.

template <typename T>
struct VisitorPriorityQueue {
using ComparatorType = std::function<bool(T, T)>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace trt_ep {

TensorrtExecutionProviderFactory::TensorrtExecutionProviderFactory(const char* ep_name, const OrtLogger& default_logger, ApiPtrs apis)
: ApiPtrs(apis), default_logger_{default_logger}, ep_name_{ep_name} {
: OrtEpFactory {}, ApiPtrs(apis), default_logger_{default_logger}, ep_name_{ep_name} {
ort_version_supported = ORT_API_VERSION; // set to the ORT version we were compiled with.
GetName = GetNameImpl;
GetVendor = GetVendorImpl;
Expand Down
Loading
Loading