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

[Hackathon NO.76] 为 Paddle-TRT 添加elementwise_mod 算子 #50974

Merged
merged 9 commits into from
Mar 6, 2023

Conversation

AndSonder
Copy link
Contributor

@AndSonder AndSonder commented Feb 27, 2023

PR types

Others

PR changes

Others

Describe

使用已有 TensorRT 算子组合实现 elementwise_mod

没有新创建单测代码,在已有单测代码 python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_elementwise.py 的基础上添加 elementwise_mod 的单测,已通过单测,测试截图如下:

251677488390_ pic

@paddle-bot
Copy link

paddle-bot bot commented Feb 27, 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 paddle-bot bot added contributor External developers status: proposed labels Feb 27, 2023
@paddle-bot
Copy link

paddle-bot bot commented Feb 27, 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.

@CLAassistant
Copy link

CLAassistant commented Feb 27, 2023

CLA assistant check
All committers have signed the CLA.

@@ -2415,6 +2415,7 @@ USE_TRT_CONVERTER(elementwise_max_tensor);
USE_TRT_CONVERTER(elementwise_min_tensor);
USE_TRT_CONVERTER(elementwise_pow_tensor);
USE_TRT_CONVERTER(elementwise_floordiv_tensor);
USE_TRT_CONVERTER(elementwise_mod_tensor);
Copy link
Contributor

Choose a reason for hiding this comment

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

elementwise_mod_weight也添加上

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已添加

@AndSonder AndSonder requested a review from zhangjun March 1, 2023 04:27
@@ -791,6 +796,7 @@ def generate_weight(op_type):
"elementwise_min",
"elementwise_max",
"elementwise_floordiv",
"elementwise_mod",
Copy link
Contributor

@zhangjun zhangjun Mar 1, 2023

Choose a reason for hiding this comment

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

目前单测精度上有问题,coverage ci无法通过。可能是因为包含有floordiv,需要对对应的输入做修改,如generate_input或者generate_weight,由于np.random.random范围为[0,1.0), 需将np.random.random替换为np.random.uniform。
参考如下,

        def generate_input(shape, op_type):
            # elementwise_floordiv is integer only
            if op_type == "elementwise_floordiv":
                return np.random.randint(
                    low=1, high=10000, size=shape, dtype=np.int32
                )
            elif op_type == "elementwise_mod":
                return np.random.uniform(low=0.1, high=1.0, size=shape).astype(np.float32)
            else:
                return np.random.random(shape).astype(np.float32)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更新,正常通过单测

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

按照您说的修改后 coverage ci 还是无法通过

Copy link
Contributor

Choose a reason for hiding this comment

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

generate_input或者generate_weight

看着还是有精度diff 是不是所有的generate_input或者generate_weight都需要修改,可以本地环境验证下(CUDA 10.2, TensorRT 7.2.3.4)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

看着还是有精度diff 是不是所有的generate_input或者generate_weight都需要修改,可以本地环境验证下(CUDA 10.2, TensorRT 7.2.3.4)

本地 cuda11.7 tensorrt 8.4 的环境可以吗

Copy link
Contributor

Choose a reason for hiding this comment

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

看着还是有精度diff 是不是所有的generate_input或者generate_weight都需要修改,可以本地环境验证下(CUDA 10.2, TensorRT 7.2.3.4)

本地 cuda11.7 tensorrt 8.4 的环境可以吗

11.7可以作为辅助 建议在https://hub.docker.com/r/paddlepaddle/paddle下拉取10.2环境,当前未通过ci是10.2

Copy link
Contributor Author

@AndSonder AndSonder Mar 2, 2023

Choose a reason for hiding this comment

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

现在本地的单测已经不报错了,线上的也没有出现上面的精度问题,但是报了一个本地没有出现过的错误

@AndSonder AndSonder requested a review from zhangjun March 1, 2023 09:12
@AndSonder
Copy link
Contributor Author

目前 TRT7, TRT8 本地环境验证正常

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.

image

单测文件这3行动态shape配置有问题会导致ci覆盖问题,分别改成4,64,32

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

@luotao1 luotao1 merged commit cf1a1c4 into PaddlePaddle:develop Mar 6, 2023
@luotao1
Copy link
Contributor

luotao1 commented Mar 6, 2023

hi, @AndSonder

  • 非常感谢你对飞桨框架的贡献,我们正在运营一个PFCC组织,会通过定期分享技术知识与发布开发者主导任务的形式持续为飞桨框架做贡献,详情可见 https://github.com/luotao1 主页说明。
  • 如果你对PFCC有兴趣,请发送邮件至 ext_paddle_oss@baidu.com,我们会邀请你加入~

@AndSonder AndSonder deleted the elementwise_mod branch April 23, 2024 13:57
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.

5 participants