Skip to content

Commit

Permalink
allow protobuf lite build for TRT EP (#19498)
Browse files Browse the repository at this point in the history
allow protobuf-lite builds with TensorRT EP as long as it's built with
the trt built-in parser and not the oss-parser.
This is because trt built-in parser statically links protobuf so there
aren't any conflicts for protobuf-lite.
  • Loading branch information
jywu-msft authored Feb 13, 2024
1 parent 4dfba53 commit 5e70c6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ option(onnxruntime_CROSS_COMPILING "Cross compiling onnx runtime" OFF)
option(onnxruntime_GCOV_COVERAGE "Compile with options necessary to run code coverage" OFF)
option(onnxruntime_DONT_VECTORIZE "Do not vectorize operations in Eigen" OFF)

#It's preferred to turn it OFF when onnxruntime is dynamically linked to PROTOBUF. But Tensort always required the full version of protobuf.
cmake_dependent_option(onnxruntime_USE_FULL_PROTOBUF "Link to libprotobuf instead of libprotobuf-lite when this option is ON" OFF "NOT onnxruntime_USE_TENSORRT" ON)
option(onnxruntime_USE_FULL_PROTOBUF "Link to libprotobuf instead of libprotobuf-lite when this option is ON" OFF)
option(tensorflow_C_PACKAGE_PATH "Path to tensorflow C package installation dir")
option(onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS "Enable operator implemented in language other than cpp" OFF)
option(onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS "Dump debug information about node inputs and outputs when executing the model." OFF)
Expand Down
12 changes: 9 additions & 3 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,9 +1236,15 @@ def generate_build_tree(
"-Donnxruntime_USE_OPENVINO_AUTO=" + ("ON" if args.use_openvino.startswith("AUTO") else "OFF"),
]

# TensorRT and OpenVINO providers currently only support
# full_protobuf option.
if args.use_full_protobuf or args.use_tensorrt or args.use_openvino or args.use_vitisai or args.gen_doc:
# VitisAI and OpenVINO providers currently only support
# full_protobuf option. TensorRT provider only requires it if built with oss_parser
if (
args.use_full_protobuf
or (args.use_tensorrt and args.use_tensorrt_oss_parser)
or args.use_openvino
or args.use_vitisai
or args.gen_doc
):
cmake_args += ["-Donnxruntime_USE_FULL_PROTOBUF=ON", "-DProtobuf_USE_STATIC_LIBS=ON"]

if args.use_tvm and args.llvm_path is not None:
Expand Down

0 comments on commit 5e70c6b

Please sign in to comment.