-
Notifications
You must be signed in to change notification settings - Fork 23
Fix power #500
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
Fix power #500
Conversation
res_type = x1.dtype | ||
if isinstance(x2, float) and (res_type == dpnp.int64 or res_type == dpnp.int32): | ||
res_type = dpnp.float64 | ||
result = dparray(x1.size, dtype=res_type) |
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.
result = dparray(x1.size, dtype=res_type) | |
result = dparray(x1.shape, dtype=res_type) |
to avoid reshape in further
return call_fptr_2in_1out(DPNP_FN_POWER, x1, x2, x1.shape) | ||
cpdef dparray dpnp_power(dparray x1, x2): | ||
cdef dparray result | ||
if dpnp.isscalar(x2): |
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.
Do we have any test that covers the branch?
cdef dparray result | ||
if dpnp.isscalar(x2): | ||
res_type = x1.dtype | ||
if isinstance(x2, float) and (res_type == dpnp.int64 or res_type == dpnp.int32): |
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.
E.g. such approach
dpnp/dpnp/dpnp_algo/dpnp_algo_mathematical.pyx
Lines 139 to 147 in c56b575
types_map = { | |
(dpnp.int32, dpnp.int32): dpnp.int32, | |
(dpnp.int32, dpnp.int64): dpnp.int64, | |
(dpnp.int64, dpnp.int32): dpnp.int64, | |
(dpnp.int64, dpnp.int64): dpnp.int64, | |
(dpnp.float32, dpnp.float32): dpnp.float32, | |
} | |
res_type = types_map.get((x1.dtype, x2.dtype), dpnp.float64) |
x2_ = dpnp.array([x2]) | ||
|
||
types_map = { | ||
(dpnp.dtype(dpnp.int32), dpnp.dtype(dpnp.float64)): dpnp.float64, |
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.
it looks like it needs to be adjusted to the same things as you did in other PR
cpdef dparray dpnp_power(dparray x1, x2): | ||
cdef dparray result | ||
if dpnp.isscalar(x2): | ||
x2_ = dpnp.array([x2]) |
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.
Is it possible to avoid creating one-element array?
No description provided.