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

Add trt pow converter. #53462

Merged
merged 4 commits into from
May 6, 2023
Merged

Add trt pow converter. #53462

merged 4 commits into from
May 6, 2023

Conversation

jiweibo
Copy link
Contributor

@jiweibo jiweibo commented Apr 28, 2023

PR types

Others

PR changes

Others

Description

增加pow的trt converter映射。

@paddle-bot
Copy link

paddle-bot bot commented Apr 28, 2023

你的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.

@paddle-bot
Copy link

paddle-bot bot commented Apr 28, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

@jiweibo jiweibo requested a review from zhangjun May 5, 2023 02:28
paddle/fluid/inference/tensorrt/convert/elementwise_op.cc Outdated Show resolved Hide resolved
Comment on lines 1104 to 1109
for shape in [
[32],
[batch, 32],
[batch, 32, 32],
[batch, 32, 16, 32],
]:
Copy link
Contributor

Choose a reason for hiding this comment

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

加上shape为[]

Copy link
Contributor Author

@jiweibo jiweibo May 5, 2023

Choose a reason for hiding this comment

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

done

VLOG(3) << "Convert a pow op to TensorRT IElementWiseLayer";
framework::OpDesc op_desc(op, nullptr);
auto* X = engine_->GetITensor(op_desc.Input("X").front());
float factor = PADDLE_GET_CONST(float, op_desc.GetAttr("factor"));
Copy link
Contributor

Choose a reason for hiding this comment

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

根据pow op的定义,factor attr应该有其他数据类型(float|int|Tensor),这里或者op_teller里是不是应该做过滤?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pow op factor存到模型中只可能是float,如果是tensor,则会成为elementwise_pow
// The diff between pow and elementwise_pow is in:
// https://github.com/PaddlePaddle/Paddle/blob/release/2.4/python/paddle/tensor/math.py#L420

Copy link
Contributor

Choose a reason for hiding this comment

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

int呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

int的话,模型中会存储成float

Copy link
Contributor

@zhangjun zhangjun left a comment

Choose a reason for hiding this comment

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

LGTM

@zhangjun zhangjun merged commit 5a44bf7 into PaddlePaddle:develop May 6, 2023
@jiweibo jiweibo deleted the support_pow branch May 6, 2023 02:41
zhangjun pushed a commit to zhangjun/Paddle that referenced this pull request May 12, 2023
* Add trt pow converter.

* update to use AddConstantLayer

* add dims=0 ut
qingqing01 pushed a commit that referenced this pull request May 13, 2023
…rRT (#53752)

* scale, square, sum, swish trt op converter support zero dim (#53660)

* [Paddle-Inference] Support trt 0dims of expand_as_v2 and mish. (#53627)

* support_expand_mish

* add unitest for reshpe 0 dims (#53685)

* Add trt pow converter. (#53462)

* Add trt pow converter.

* update to use AddConstantLayer

* add dims=0 ut

* [inference Zero-Dim]add equal, elementwise_op trt 0d (#53704)

* [inference Zero-Dim]prelu trt converter support zero dim tensor (#53634)

* prelu op trt converter support zero dim

* [Inference Zero-Dim] Support trt 0dim of gelu, hard_swish, hard_sigmoid and leaky_relu (#53714)

* support_act
* delete_silu

* [inference zero dim] softmax, stack op trt converter support zero dim (#53729)

* softmax support

* support stack

* remove unused code

* update

---------

Co-authored-by: Yuanle Liu <yuanlehome@163.com>
Co-authored-by: xiaoxiaohehe001 <49090790+xiaoxiaohehe001@users.noreply.github.com>
Co-authored-by: zhoutianzi666 <39978853+zhoutianzi666@users.noreply.github.com>
Co-authored-by: Wilber <jiweibo@baidu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants