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

math API support int tensor autocast to float32 易用性提升 #69252

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

NKNaN
Copy link
Contributor

@NKNaN NKNaN commented Nov 8, 2024

PR Category

User Experience

PR Types

Improvements

Description

paddle.acos
paddle.asin
paddle.atan
paddle.ceil
paddle.cos
paddle.cosh
paddle.digamma
paddle.erf
paddle.floor
paddle.lgamma
paddle.logcumsumexp
paddle.logit
paddle.logsumexp
paddle.reciprocal
paddle.rsqrt
paddle.sin
paddle.sinh
paddle.nn.functional.sigmoid
paddle.sqrt
paddle.stanh
paddle.tan
paddle.tanh
paddle.erfinv
paddle.acosh
paddle.asinh
paddle.atanh
paddle.i0
paddle.i0e
paddle.i1
paddle.i1e
paddle.polygamma

以上支持整数类型输入自动提升为float32类型。
其中只有 paddle.ceilpaddle.floor 也支持反向,梯度类型与输入类型一致。

paddle.multigammalnpaddle.sinc 由于是组合 API 实现,其中的 API 暂不支持 int 和 float 的类型提升,所以 paddle.multigammalnpaddle.sinc 暂不支持整数类型输入

Copy link

paddle-bot bot commented Nov 8, 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
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

  1. 之前的功能性能不能下降,见Benchmark CI
  2. 之前的功能结果不受影响,见PR-CE-Framework

@@ -617,6 +663,15 @@ class {} : public egr::GradNodeBase {{
}}
"""

TYPE_AUTOCAST_LOGIC_TEMPLATE = """
Copy link
Contributor

Choose a reason for hiding this comment

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

只有int情况下会被cast,还是所有情况下会被cast,不能引入不兼容的性能下降问题,只能对于之前不支持会报错的情况去cast

Copy link
Contributor Author

@NKNaN NKNaN Nov 13, 2024

Choose a reason for hiding this comment

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

只有在指定的op列表里且输入是int的时候会cast,应该不会不兼容。CE-Framework 的报错可能需要修改 PaddleTest 中的一些单测,因为有一些单测里面包含int输入会报错的case。

在 aistudio 上跑的结果
image

在 PaddleTest 中注释掉 paddle.sin 的单测:PaddlePaddle/PaddleTest#2992

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

你有CE-Framework的合入权限没,先把那个提一个PR修改吧,让这个PR能过CI

@@ -388,11 +430,13 @@ def ceil(x: Tensor, name: str | None = None) -> Tensor:
out = \\left \\lceil x \\right \\rceil

Args:
x (Tensor): Input of Ceil operator, an N-D Tensor, with data type float32, float64 or float16.
x (Tensor): Input of Ceil operator, an N-D Tensor, with data type float32, float64, float16, bfloat16,
Copy link
Contributor

Choose a reason for hiding this comment

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

有些上面check_dtype里写了complex64,下面文档里似乎没写,这个上下对齐一下吧

Copy link
Contributor Author

@NKNaN NKNaN Nov 15, 2024

Choose a reason for hiding this comment

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

好的,我再检查一下文档。 PaddleTest 我没有合入的权限,pr 是这个:PaddlePaddle/PaddleTest#2992

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.

2 participants