Skip to content

Commit 6470d80

Browse files
authored
【Paddle Tensor】fix converter old ir issues -1 (#70849) (#71643)
* Update manipulation.py * Update manipulation.py * Update manipulation.py * fix temporal_shift * Update others.py * Update others.py * update * fix codestyle * Update auto_scan_test.py * Update auto_scan_test.py * modify softmax * fix codestyle * Update CMakeLists.txt * fix codestyle * Update manipulation.py * Update manipulation.py * Update manipulation.py * update * Update pir.cc * Update pir.cc * fix codestyle * Update pir.cc * fix codestyle * fix * delete old_softmax * Update pir.cc * fix codestyle * fix tile * fix tile * fix expand * fix codestyle * fix range * fix tile * Update test_trt_convert_temporal_shift_deprecated.py * fix tile * fix codestyle * add expand
1 parent aac2570 commit 6470d80

File tree

8 files changed

+567
-117
lines changed

8 files changed

+567
-117
lines changed

paddle/fluid/pybind/pir.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,11 @@ void BindOperation(py::module *m) {
984984
attrs_dict[pair.first.c_str()] =
985985
pair.second.dyn_cast<OperationDistAttribute>();
986986
} else {
987+
if (pair.second.isa<pir::FloatAttribute>()) {
988+
VLOG(2) << "The value is stored with float32 precision, "
989+
"which may cause precision issues for higher "
990+
"precision requirements.";
991+
}
987992
attrs_dict[pair.first.c_str()] =
988993
paddle::dialect::GetAttributeData(pair.second);
989994
}

python/paddle/tensorrt/impls/manipulation.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,11 +1049,17 @@ def tile_converter(network, paddle_op, inputs):
10491049
repeat_rank = len(repeat_times)
10501050
else:
10511051
repeat_tensor = inputs[1]
1052-
repeat_tensor = resize_to_1d(
1053-
network, repeat_tensor, name=[paddle_op.name(), 'repeat_tensor']
1054-
)
1055-
repeat_shape = paddle_op.operands()[1].source().shape
1056-
repeat_rank = repeat_shape[0]
1052+
if isinstance(repeat_tensor, list):
1053+
repeat_rank = len(repeat_tensor)
1054+
repeat_tensor = trt_concat(
1055+
network, repeat_tensor, name=[paddle_op.name(), 'repeat_tensor']
1056+
)
1057+
else:
1058+
repeat_tensor = resize_to_1d(
1059+
network, repeat_tensor, name=[paddle_op.name(), 'repeat_tensor']
1060+
)
1061+
repeat_shape = paddle_op.operands()[1].source().shape
1062+
repeat_rank = repeat_shape[0]
10571063

10581064
if rank > repeat_rank:
10591065
one_rank_tensor = add_1D_constant_layer(

python/paddle/tensorrt/impls/others.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ def share_data_converter(network, paddle_op, inputs):
323323
@converter_registry.register("pd_op.temporal_shift", trt_version="8.x")
324324
def temporal_shift_converter(network, paddle_op, inputs):
325325
input_tensor = inputs[0]
326-
shift_ratio = paddle_op.attrs()["shift_ratio"]
326+
# Add a small bias to shift_ratio to mitigate floating point precision errors
327+
shift_ratio = paddle_op.attrs()["shift_ratio"] + 1e-7
327328
T = paddle_op.attrs()["seg_num"]
328329
data_format = paddle_op.attrs().get("data_format", "NCHW")
329330

test/ir/inference/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ if(WITH_GPU AND TENSORRT_FOUND)
169169
#set_tests_properties(test_trt_multiclass_nms_op PROPERTIES TIMEOUT 200)
170170

171171
set_tests_properties(test_trt_ops_fp32_mix_precision PROPERTIES TIMEOUT 300)
172+
set_tests_properties(test_trt_convert_expand_v2 PROPERTIES TIMEOUT 1000)
172173
set_tests_properties(test_trt_convert_unary PROPERTIES TIMEOUT 600)
174+
set_tests_properties(test_trt_convert_temporal_shift_deprecated
175+
PROPERTIES TIMEOUT 1000)
173176
set_tests_properties(test_trt_convert_pool2d PROPERTIES TIMEOUT 600)
174177
set_tests_properties(test_trt_convert_slice PROPERTIES TIMEOUT 600)
175178

0 commit comments

Comments
 (0)