Skip to content
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

[Paddle TensorRT No.19] Add pd_op.cumsum converter #69330

Merged
merged 9 commits into from
Jan 3, 2025

Conversation

Hanyonggong
Copy link
Contributor

PR Category

Inference

PR Types

New features

Description

card-71500
添加了pd_op.cumsum Marker 和Converter

Copy link

paddle-bot bot commented Nov 12, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link

paddle-ci-bot bot commented Dec 12, 2024

Sorry to inform you that da03c88's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

YuanRisheng
YuanRisheng previously approved these changes Dec 23, 2024
dtype = input_tensor.dtype
axis = paddle_op.operands()[1].source().get_defining_op().attrs()["value"]
input_shape = input_tensor.shape
rank = len(input_shape)
Copy link
Contributor

Choose a reason for hiding this comment

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

现在支持rank=0了,和旧ir的converter保持对齐吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

现在rank=0的情况似乎通过zero_dims_to_one_dims自动转为rank = 1了

@lizexu123
Copy link
Contributor

lizexu123 commented Dec 26, 2024 via email

@Hanyonggong
Copy link
Contributor Author

对 发自我的iPhone

------------------ Original ------------------ From: Hanyonggong @.> Date: Thu,Dec 26,2024 2:51 PM To: PaddlePaddle/Paddle @.> Cc: lizexu123 @.>, Comment @.> Subject: Re: [PaddlePaddle/Paddle] [Paddle TensorRT No.19] Add pd_op.cumsumconverter (PR #69330) @Hanyonggong commented on this pull request. In python/paddle/tensorrt/impls/math.py: > @@ -227,6 +228,96 @@ def all_converter(network, paddle_op, inputs): ) @._registry.register("pd_op.cumsum", trt_version="8.x") +def cumsum_converter(network, paddle_op, inputs): + input_tensor = inputs[0] + dtype = input_tensor.dtype + axis = paddle_op.operands()[1].source().get_defining_op().attrs()["value"] + input_shape = input_tensor.shape + rank = len(input_shape) 现在rank=0的情况似乎通过zero_dims_to_one_dims自动转为rank = 1了 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

那应该就不用加rank =0 的情况了吧

# Obtain the number of cycles
if input_shape[axis] > 0:
axis_tensor = np.array(input_shape[axis], dtype=np.int32)
trip_limit = network.add_constant((), axis_tensor)
Copy link
Contributor

Choose a reason for hiding this comment

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

add_1d_constant_layer(scalar也要区分是否为标量),

axis_tensor = np.array(input_shape[axis], dtype=np.int32)
trip_limit = network.add_constant((), axis_tensor)
else:
dynamic_shape = network.add_shape(input_tensor).get_output(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

trt_reshape和get_shape_tensor_element复用

# Obtain the slice shape
shape_list = []
for i in range(rank):
if i == axis:
Copy link
Contributor

Choose a reason for hiding this comment

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

你这块代码和旧ir的差距较大,我建议你也写一个getAxisLength函数,这边怎么输入维度<0,又要reshape维度

start = [0] * rank
size = [1] * rank
stride = [1] * rank
input_sliced = network.add_slice(input_tensor, start, size, stride)
Copy link
Contributor

Choose a reason for hiding this comment

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

如果axis=0,sizes_tensor为add_1d_constant_layer(network,1),否则get_axis_length,这段代码在哪,strides_tensor呢

@lizexu123 lizexu123 merged commit 16ac142 into PaddlePaddle:develop Jan 3, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants