Skip to content
Open
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
9 changes: 8 additions & 1 deletion python/paddle/tensorrt/impls/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ def arange_converter(network, paddle_op, inputs):
name=[paddle_op.name(), 'quotient_tensor'],
)
else:
quotient_tensor = f_quotient_tensor
# zero_tensor (above) is int32; on TRT>=10 the integer quotient is int64,
# which would mismatch in the trt_sub below. Cast it to int32 too.
quotient_tensor = trt_cast(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 这个 cast 修的是 start/end/step 作为 TensorRT 输入 tensor 时的非 float 分支,但现有 arange converter 测试只用常量输入(test/tensorrt/test_converter_creation.py:109-114feed_list 为空)。常量折叠路径不会稳定覆盖 f_quotient_tensor 在 TRT>=10 上产生 int64 后再和 zero_tensortrt_sub 的运行时 subgraph;后续删除或改坏这行 cast 时,现有测试仍可能通过。

建议修复方式:
新增一个 arange TensorRT 用例,把 startendstep 放进 feed_list(例如三个 int64、shape 为 [1] 的输入),并设置对应的输入 shape 数据,使 pd_op.arange 的 integer 分支以 runtime tensor 进入 converter;该用例应在 TRT>=10.8 删除这行 cast 时 engine build 失败。

network,
f_quotient_tensor,
trt.int32,
name=[paddle_op.name(), 'quotient_tensor'],
)

delta_1 = trt_sub(
network,
Expand Down
10 changes: 7 additions & 3 deletions python/paddle/tensorrt/impls/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,13 @@ def stack_converter(network, paddle_op, inputs):
if axis < 0:
axis += output_rank

shape_tensor = network.add_shape(input_tensors[0])
set_layer_name(shape_tensor, paddle_op)
shape_tensor = shape_tensor.get_output(0)
# Use trt_shape() instead of raw add_shape: TRT 10.8 changed Shape's output
# to int64, which then collides with the int32 add_1D_constant_layer below in
# add_concatenation ("Error Code 4: incompatible types Int32 and Int64").
# trt_shape() casts the shape tensor back to int32 on TRT>=10.
shape_tensor = trt_shape(
network, input_tensors[0], name=[paddle_op.name(), 'shape_tensor']
)
shape_tensor_vec = []
for i in range(output_rank):
if i < axis:
Expand Down