Skip to content

Commit 6c10ea7

Browse files
committed
Pass sycl_queue to default_float_type() calls in dpnp.gradient() implementation
1 parent b07f185 commit 6c10ea7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

dpnp/dpnp_iface_mathematical.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def _gradient_build_dx(f, axes, *varargs):
141141
if dpnp.issubdtype(distances.dtype, dpnp.integer):
142142
# Convert integer types to default float type to avoid modular
143143
# arithmetic in dpnp.diff(distances).
144-
distances = distances.astype(dpnp.default_float_type())
144+
distances = distances.astype(
145+
dpnp.default_float_type(sycl_queue=f.sycl_queue)
146+
)
145147
diffx = dpnp.diff(distances)
146148

147149
# if distances are constant reduce to the scalar case
@@ -2707,9 +2709,9 @@ def gradient(f, *varargs, axis=None, edge_order=1):
27072709
# All other types convert to floating point.
27082710
# First check if f is a dpnp integer type; if so, convert f to default
27092711
# float type to avoid modular arithmetic when computing changes in f.
2712+
otype = dpnp.default_float_type(sycl_queue=f.sycl_queue)
27102713
if dpnp.issubdtype(otype, dpnp.integer):
2711-
f = f.astype(dpnp.default_float_type())
2712-
otype = dpnp.default_float_type()
2714+
f = f.astype(otype)
27132715

27142716
for axis_, ax_dx in zip(axes, dx):
27152717
if f.shape[axis_] < edge_order + 1:

0 commit comments

Comments
 (0)