dpctl icon indicating copy to clipboard operation
dpctl copied to clipboard

`dpctl.tensor.tan` returns incorrect result

Open antonwolfy opened this issue 11 months ago • 1 comments

It seems dpctl.tensor.tan returns result which differs with numpy and Intel MKL:

import dpnp, numpy, dpctl, dpctl.tensor as dpt

a = numpy.array([11], dtype='F')
numpy.tan(a)
# Out: array([-225.95084+0.j], dtype=complex64)

ia = dpnp.array(a, device='cpu')
dpnp.tan(ia)
# array([-225.95085+0.j], dtype=complex64)  tan() from Intel MKL is used

na = dpt.asarray(a, device='cpu')
dpt.tan(da)
# Out: usm_ndarray([-225.68439+0.j], dtype=complex64)

na = dpt.asarray(a, device='gpu')
dpt.tan(na)
# Out: usm_ndarray([-225.68439+0.j], dtype=complex64)

# casting to complex128 resolve the issue:
na = dpt.asarray(a, device='cpu', dtype='D')
dpt.tan(na)
# Out: usm_ndarray([-225.95084645+0.j])

Is the behavior expected? Or is there something which needs to be fixed in dpctl?

antonwolfy avatar Mar 26 '25 14:03 antonwolfy

@antonwolfy Can you provide more information about the machine that you took this on?

I haven't been able to replicate it locally. Update: my mistake, I missed that it was complex. I can replicate it fine.

ndgrigorian avatar Mar 27 '25 16:03 ndgrigorian