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

Tensor type promotion for static mode #59763

Conversation

zoooo0820
Copy link
Contributor

PR types

New features

PR changes

APIs

Description

Pcard-78266

This PR is based on #59513 and #59518

support FLOAT type promotion of Tensor-Tensor for following operaters: +(elementwise_add) / -(elementwise_sub) / *(elementwise_mul) in static mode.

From this PR these operators will meet commutative law (currently, only for FLOAT type),instead of align to former tensor. For example:

>>> paddle.enable_static()
>>> a = paddle.randn((2,3), dtype='float32')
>>> b = paddle.randn((2,3), dtype='float64')
>>> out = a + b

# Before, dtype of out would be same to the former one, i.e. a
>>> out
var tmp_1 : LOD_TENSOR.shape(2, 3).dtype(float32).stop_gradient(True)


# Now, dtype will be promote to float64
>>> out
var tmp_1 : LOD_TENSOR.shape(2, 3).dtype(float64).stop_gradient(True)

Copy link

paddle-bot bot commented Dec 6, 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.

Copy link
Contributor

@zxcd zxcd left a comment

Choose a reason for hiding this comment

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

LGTM

zxcd

This comment was marked as duplicate.

Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM

@jeff41404 jeff41404 merged commit 6e09e44 into PaddlePaddle:develop Dec 8, 2023
28 of 29 checks passed
@zoooo0820 zoooo0820 deleted the tensor_type_promotion_for_static_mode3 branch December 8, 2023 06:27
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.

4 participants