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 #59586

Conversation

zoooo0820
Copy link
Contributor

@zoooo0820 zoooo0820 commented Dec 1, 2023

PR types

New features

PR changes

APIs

Description

Pcard-78266

This PR is based on #59513 and #59518

  • support type-promotion mechanism for static-mode APIs. This is happened when we call Block.append_op
  • support FLOAT type promotion of Tensor-Tensor for following operaters: +(elementwise_add) / -(elementwise_sub) / *(elementwise_mul) / where 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)

@zoooo0820 zoooo0820 force-pushed the tensor_type_promotion_for_static_mode2 branch from b982699 to b893736 Compare December 1, 2023 06:28
@zoooo0820 zoooo0820 closed this Dec 8, 2023
@zoooo0820 zoooo0820 deleted the tensor_type_promotion_for_static_mode2 branch January 23, 2024 09:09
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.

2 participants