dpnp icon indicating copy to clipboard operation
dpnp copied to clipboard

BUG: Compute-follows-data breaks on the inverse operation

Open samaid opened this issue 2 years ago • 2 comments

x = dpnp.asarray([1.0, 2.0, 3.0])
y = 1.0/x

y is numpy array vs. dpnp array

Complete reproducer is here https://gist.github.com/samaid/b4510dbcd7285ceed36b42dd96acf30c

samaid avatar May 17 '23 02:05 samaid

Problem in type operator:

In: type(dpnp.float32(1.0))
Out: <class 'numpy.float32'>
In: dpnp.float32(1.0) / x
Out: array([array(1.), array(0.5), array(0.33333333)], dtype=object)

npolina4 avatar May 17 '23 12:05 npolina4

To avoid this problem you can use:

y = np.asarray(1.0, dtype=np.float32) / x

instead of

y = np.float32(1.0) / x

npolina4 avatar May 17 '23 12:05 npolina4