Skip to content

【Paddle Tensor】Fix converter errors under Program IR (#70849) #71643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions paddle/fluid/pybind/pir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,11 @@ void BindOperation(py::module *m) {
attrs_dict[pair.first.c_str()] =
pair.second.dyn_cast<OperationDistAttribute>();
} else {
if (pair.second.isa<pir::FloatAttribute>()) {
VLOG(2) << "The value is stored with float32 precision, "
"which may cause precision issues for higher "
"precision requirements.";
}
attrs_dict[pair.first.c_str()] =
paddle::dialect::GetAttributeData(pair.second);
}
Expand Down
16 changes: 11 additions & 5 deletions python/paddle/tensorrt/impls/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,11 +1049,17 @@ def tile_converter(network, paddle_op, inputs):
repeat_rank = len(repeat_times)
else:
repeat_tensor = inputs[1]
repeat_tensor = resize_to_1d(
network, repeat_tensor, name=[paddle_op.name(), 'repeat_tensor']
)
repeat_shape = paddle_op.operands()[1].source().shape
repeat_rank = repeat_shape[0]
if isinstance(repeat_tensor, list):
repeat_rank = len(repeat_tensor)
repeat_tensor = trt_concat(
network, repeat_tensor, name=[paddle_op.name(), 'repeat_tensor']
)
else:
repeat_tensor = resize_to_1d(
network, repeat_tensor, name=[paddle_op.name(), 'repeat_tensor']
)
repeat_shape = paddle_op.operands()[1].source().shape
repeat_rank = repeat_shape[0]

if rank > repeat_rank:
one_rank_tensor = add_1D_constant_layer(
Expand Down
3 changes: 2 additions & 1 deletion python/paddle/tensorrt/impls/others.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ def share_data_converter(network, paddle_op, inputs):
@converter_registry.register("pd_op.temporal_shift", trt_version="8.x")
def temporal_shift_converter(network, paddle_op, inputs):
input_tensor = inputs[0]
shift_ratio = paddle_op.attrs()["shift_ratio"]
# Add a small bias to shift_ratio to mitigate floating point precision errors
shift_ratio = paddle_op.attrs()["shift_ratio"] + 1e-7
T = paddle_op.attrs()["seg_num"]
data_format = paddle_op.attrs().get("data_format", "NCHW")

Expand Down
3 changes: 3 additions & 0 deletions test/ir/inference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ if(WITH_GPU AND TENSORRT_FOUND)
#set_tests_properties(test_trt_multiclass_nms_op PROPERTIES TIMEOUT 200)

set_tests_properties(test_trt_ops_fp32_mix_precision PROPERTIES TIMEOUT 300)
set_tests_properties(test_trt_convert_expand_v2 PROPERTIES TIMEOUT 1000)
set_tests_properties(test_trt_convert_unary PROPERTIES TIMEOUT 600)
set_tests_properties(test_trt_convert_temporal_shift_deprecated
PROPERTIES TIMEOUT 1000)
set_tests_properties(test_trt_convert_pool2d PROPERTIES TIMEOUT 600)
set_tests_properties(test_trt_convert_slice PROPERTIES TIMEOUT 600)

Expand Down
Loading