Skip to content

Commit fe82754

Browse files
authored
cherry-pick prs. (#33932)
1 parent 16ed3cc commit fe82754

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

cmake/inference_lib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ function(version version_file)
345345
file(APPEND ${version_file} "CXX compiler version: ${CMAKE_CXX_COMPILER_VERSION}\n")
346346
if(TENSORRT_FOUND)
347347
file(APPEND ${version_file}
348-
"WITH_TENSORRT: ${TENSORRT_FOUND}\n" "TensorRT version: v${TENSORRT_MAJOR_VERSION}\n")
348+
"WITH_TENSORRT: ${TENSORRT_FOUND}\n" "TensorRT version: v${TENSORRT_MAJOR_VERSION}.${TENSORRT_MINOR_VERSION}.${TENSORRT_PATCH_VERSION}.${TENSORRT_BUILD_VERSION}\n")
349349
endif()
350350
if(WITH_LITE)
351351
file(APPEND ${version_file} "WITH_LITE: ${WITH_LITE}\n" "LITE_GIT_TAG: ${LITE_GIT_TAG}\n")

cmake/tensorrt.cmake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,23 @@ if(TENSORRT_FOUND)
4747
file(READ ${TENSORRT_INCLUDE_DIR}/NvInfer.h TENSORRT_VERSION_FILE_CONTENTS)
4848
string(REGEX MATCH "define NV_TENSORRT_MAJOR +([0-9]+)" TENSORRT_MAJOR_VERSION
4949
"${TENSORRT_VERSION_FILE_CONTENTS}")
50+
string(REGEX MATCH "define NV_TENSORRT_MINOR +([0-9]+)" TENSORRT_MINOR_VERSION
51+
"${TENSORRT_VERSION_FILE_CONTENTS}")
52+
string(REGEX MATCH "define NV_TENSORRT_PATCH +([0-9]+)" TENSORRT_PATCH_VERSION
53+
"${TENSORRT_VERSION_FILE_CONTENTS}")
54+
string(REGEX MATCH "define NV_TENSORRT_BUILD +([0-9]+)" TENSORRT_BUILD_VERSION
55+
"${TENSORRT_VERSION_FILE_CONTENTS}")
5056

5157
if("${TENSORRT_MAJOR_VERSION}" STREQUAL "")
5258
file(READ ${TENSORRT_INCLUDE_DIR}/NvInferVersion.h TENSORRT_VERSION_FILE_CONTENTS)
5359
string(REGEX MATCH "define NV_TENSORRT_MAJOR +([0-9]+)" TENSORRT_MAJOR_VERSION
5460
"${TENSORRT_VERSION_FILE_CONTENTS}")
61+
string(REGEX MATCH "define NV_TENSORRT_MINOR +([0-9]+)" TENSORRT_MINOR_VERSION
62+
"${TENSORRT_VERSION_FILE_CONTENTS}")
63+
string(REGEX MATCH "define NV_TENSORRT_PATCH +([0-9]+)" TENSORRT_PATCH_VERSION
64+
"${TENSORRT_VERSION_FILE_CONTENTS}")
65+
string(REGEX MATCH "define NV_TENSORRT_BUILD +([0-9]+)" TENSORRT_BUILD_VERSION
66+
"${TENSORRT_VERSION_FILE_CONTENTS}")
5567
endif()
5668

5769
if("${TENSORRT_MAJOR_VERSION}" STREQUAL "")
@@ -60,9 +72,15 @@ if(TENSORRT_FOUND)
6072

6173
string(REGEX REPLACE "define NV_TENSORRT_MAJOR +([0-9]+)" "\\1"
6274
TENSORRT_MAJOR_VERSION "${TENSORRT_MAJOR_VERSION}")
75+
string(REGEX REPLACE "define NV_TENSORRT_MINOR +([0-9]+)" "\\1"
76+
TENSORRT_MINOR_VERSION "${TENSORRT_MINOR_VERSION}")
77+
string(REGEX REPLACE "define NV_TENSORRT_PATCH +([0-9]+)" "\\1"
78+
TENSORRT_PATCH_VERSION "${TENSORRT_PATCH_VERSION}")
79+
string(REGEX REPLACE "define NV_TENSORRT_BUILD +([0-9]+)" "\\1"
80+
TENSORRT_BUILD_VERSION "${TENSORRT_BUILD_VERSION}")
6381

6482
message(STATUS "Current TensorRT header is ${TENSORRT_INCLUDE_DIR}/NvInfer.h. "
65-
"Current TensorRT version is v${TENSORRT_MAJOR_VERSION}. ")
83+
"Current TensorRT version is v${TENSORRT_MAJOR_VERSION}.${TENSORRT_MINOR_VERSION}.${TENSORRT_PATCH_VERSION}.${TENSORRT_BUILD_VERSION} ")
6684
include_directories(${TENSORRT_INCLUDE_DIR})
6785
link_directories(${TENSORRT_LIBRARY})
6886
add_definitions(-DPADDLE_WITH_TENSORRT)

paddle/fluid/inference/api/paddle_analysis_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ struct PD_INFER_DECL AnalysisConfig {
678678
bool xpu_adaptive_seqlen_;
679679

680680
// mkldnn related.
681-
int mkldnn_cache_capacity_{0};
681+
int mkldnn_cache_capacity_{10};
682682
bool use_mkldnn_quantizer_{false};
683683
std::shared_ptr<MkldnnQuantizerConfig> mkldnn_quantizer_config_;
684684
bool use_mkldnn_bfloat16_{false};

tools/remove_grad_op_and_kernel.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import sys
2121
import re
2222
import glob
23+
import io
2324

2425

2526
def find_type_files(cur_dir, file_type, file_list=[]):
@@ -124,7 +125,7 @@ def update_operator_cmake(cmake_file):
124125
custom_pattern2 = custom_pattern2[:-1]
125126

126127
all_matches = []
127-
with open(op_file, 'r') as f:
128+
with io.open(op_file, 'r', encoding='utf-8') as f:
128129
content = ''.join(f.readlines())
129130

130131
op, op_count = remove_grad_op_and_kernel(content, op_pattern1,
@@ -157,8 +158,8 @@ def update_operator_cmake(cmake_file):
157158
for i in all_matches:
158159
content = content.replace(i, '')
159160

160-
with open(op_file, 'w') as f:
161-
f.write(content)
161+
with io.open(op_file, 'w', encoding='utf-8') as f:
162+
f.write(u'{}'.format(content))
162163

163164
# 2. update operators/CMakeLists.txt
164165
cmake_file = os.path.join(tool_dir,

0 commit comments

Comments
 (0)