Skip to content

dpt.pow() with dtype=c16 and scalar on gpu/cpu returns different result  #1378

Closed
@vlad-perevezentsev

Description

@vlad-perevezentsev

The below example works differently depending on the device:

import dpctl.tensor as dpt

a = dpt.asarray([0], dtype='c16', device='gpu')
dpt.pow(a,1)
# usm_ndarray([0.+0.j])

a = dpt.asarray([0], dtype='c16', device='cpu')
dpt.pow(a,1)
# usm_ndarray([nan+nanj])

with dtype = 'c8' returns the same result for different devices

import dpctl.tensor as dpt

a = dpt.asarray([0], dtype='c8',device='gpu')
dpt.pow(a ,1)
# usm_ndarray([0.+0.j], dtype=complex64)

a = dpt.asarray([0], dtype='c8',device='cpu')
dpt.pow(a,1)
# usm_ndarray([0.+0.j], dtype=complex64)


I also noticed that dpt.pow works correctly when the input array size is between 2 and 7 for dtype c16.

import dpctl.tensor as dpt


a = dpt.zeros((2,), dtype='c16', device='cpu')
dpt.pow(a,1)
# usm_ndarray([0.+0.j, 0.+0.j])

a = dpt.zeros((7,), dtype='c16', device='cpu')
dpt.pow(a,1)
# usm_ndarray([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])


a = dpt.zeros((8,), dtype='c16', device='cpu')
dpt.pow(a,1)
# usm_ndarray([ 0. +0.j,  0. +0.j,  0. +0.j,  0. +0.j, nan+nanj, nan+nanj,
             nan+nanj, nan+nanj])


Besides this there is an interesting case when x2 (scalar) is numpy dtype
Then dpt.pow with input array with data type c8 returns nans too

import dpctl.tensor as dpt
import numpy

a = dpt.zeros((8,), dtype='c8', device='cpu')
dpt.pow(a, 1)
# usm_ndarray([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,
             0.+0.j], dtype=complex64)

dpt.pow(a, numpy.int32(1))
# usm_ndarray([ 0. +0.j,  0. +0.j,  0. +0.j,  0. +0.j, nan+nanj, nan+nanj,
             nan+nanj, nan+nanj])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions