• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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 "tensorflow/compiler/tf2tensorrt/utils/py_utils.h"
17 
18 #if GOOGLE_CUDA && GOOGLE_TENSORRT
19 #include "tensorrt/include/NvInfer.h"
20 #endif
21 
22 namespace tensorflow {
23 namespace tensorrt {
24 
IsGoogleTensorRTEnabled()25 bool IsGoogleTensorRTEnabled() {
26   // TODO(laigd): consider also checking if tensorrt shared libraries are
27   // accessible. We can then direct users to this function to make sure they can
28   // safely write code that uses tensorrt conditionally. E.g. if it does not
29   // check for for tensorrt, and user mistakenly uses tensorrt, they will just
30   // crash and burn.
31 #if GOOGLE_CUDA && GOOGLE_TENSORRT
32   return true;
33 #else
34   return false;
35 #endif
36 }
37 
GetLinkedTensorRTVersion(int * major,int * minor,int * patch)38 void GetLinkedTensorRTVersion(int* major, int* minor, int* patch) {
39 #if GOOGLE_CUDA && GOOGLE_TENSORRT
40   *major = NV_TENSORRT_MAJOR;
41   *minor = NV_TENSORRT_MINOR;
42   *patch = NV_TENSORRT_PATCH;
43 #else
44   *major = 0;
45   *minor = 0;
46   *patch = 0;
47 #endif
48 }
49 
GetLoadedTensorRTVersion(int * major,int * minor,int * patch)50 void GetLoadedTensorRTVersion(int* major, int* minor, int* patch) {
51 #if GOOGLE_CUDA && GOOGLE_TENSORRT
52   int ver = getInferLibVersion();
53   *major = ver / 1000;
54   ver = ver - *major * 1000;
55   *minor = ver / 100;
56   *patch = ver - *minor * 100;
57 #else
58   *major = 0;
59   *minor = 0;
60   *patch = 0;
61 #endif
62 }
63 
64 }  // namespace tensorrt
65 }  // namespace tensorflow
66