-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Check and fix tensor and scalar type promotion #28299
Check and fix tensor and scalar type promotion #28299
Conversation
Thanks for your contribution! |
…ttps://github.com/chenwhql/Paddle into func/check_and_fix_tensor_and_scalar_type_promotion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… func/check_and_fix_tensor_and_scalar_type_promotion
@@ -149,28 +149,46 @@ def _binary_creator_(method_name, | |||
reverse=False, | |||
scalar_method=None): | |||
def __impl__(self, other_var): | |||
# tensor and ComplexVariable opetator | |||
# 0. check tensor and ComplexVariable opetator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opetator -> operator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, I'll fix it in next PR
PR types
Function optimization
PR changes
APIs
Describe
Check and fix the type promotion problem when calculating paddle tensor and scalar.
For the calculation between tensor and scalar, paddle was originally partially supported. In some scenarios, there are problems with the results and types of calculate result.
This PR add some unittests for each binary operation, including:
+ (add)
: tensor + scalar- (sub & rsub)
: tensor - scalar, scalar - tensor* (mul)
: tensor * scalar/ (div & rdiv)
: tensor / scalar, scalar / tensor** (pow & rpow)
: tensor ** scalar, scalar ** tensor// (floordiv)
: tensor // scalar% (mod)
: tensor % scalarFix several error cases
Performance: Almost no effect
Test Case:
CPU Time(with t.numpy()):
GPU Time(with t.numpy()):
Function that may need support
// (floordiv)
does not supportfloating type
, no related kernel