1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include <tuple>
17
18 #include "pybind11/pybind11.h"
19 #include "tensorflow/compiler/tf2tensorrt/common/utils.h"
20 #include "tensorflow/compiler/tf2tensorrt/utils/py_utils.h"
21
get_linked_tensorrt_version()22 std::tuple<int, int, int> get_linked_tensorrt_version() {
23 return tensorflow::tensorrt::GetLinkedTensorRTVersion();
24 }
25
get_loaded_tensorrt_version()26 std::tuple<int, int, int> get_loaded_tensorrt_version() {
27 return tensorflow::tensorrt::GetLoadedTensorRTVersion();
28 }
29
PYBIND11_MODULE(_pywrap_py_utils,m)30 PYBIND11_MODULE(_pywrap_py_utils, m) {
31 m.doc() = "_pywrap_py_utils: Various TensorRT utilities";
32 m.def("get_linked_tensorrt_version", get_linked_tensorrt_version,
33 "Return the compile time TensorRT library version as the tuple "
34 "(Major, Minor, Patch).");
35 m.def("get_loaded_tensorrt_version", get_loaded_tensorrt_version,
36 "Return the runtime time TensorRT library version as the tuple "
37 "(Major, Minor, Patch).");
38 m.def("is_tensorrt_enabled", tensorflow::tensorrt::IsGoogleTensorRTEnabled,
39 "Returns True if TensorRT is enabled.");
40 }
41