Skip to content

Incorrect behavior of dpctl.tensor.all and dpctl.tensor.any with axis=0 parameter  #1327

Closed
@vlad-perevezentsev

Description

@vlad-perevezentsev

The dpctl.tensor.all function returns an incorrect result with the parameter axis=0 and dimension >=3 of the input ndarray.

Running on GPU

import dpctl.tensor as dpt
import numpy

a = numpy.arange(24).reshape(2, 3, 4) - 10

a.dtype
>dtype('int64')

dpt_a = dpt.asarray(a)

numpy.all(a,axis=0)
>array([[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True, False,  True]])

dpt.all(dpt_a,axis=0)
>usm_ndarray([[ True, False, False, False],
              [False, False, False, False],
              [False, False, False, False]])

# at the same for dtype=int32

# floating types and boolean work correctly 

a = a.astype('float32')
dpt_a = dpt.asarray(a)

numpy.all(a,axis=0)
>array([[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True, False,  True]])

dpt.all(dpt_a,axis=0)
>usm_ndarray([[ True,  True,  True,  True],
              [ True,  True,  True,  True],
              [ True,  True,  True,  True]])

Running on CPU for integer and floating types throws Segmentation fault
for boolean type incorrect result

import dpctl.tensor as dpt
import numpy

a = numpy.arange(24).reshape(2, 3, 4) - 10
dpt_a = dpt.asarray(a)
dpt.all(dpt_a,axis=0)
> Segmentation fault

dpt_a = dpt.astype(dpt_a, 'float32')
dpt.all(dpt_a,axis=0)
> Segmentation fault

dpt_a = dpt.astype(dpt_a, 'bool')
> usm_ndarray([[ True,  True,  True,  True],
              [ True,  True,  True,  True],
              [False, False,  True, False]])


# for ndim<3 works

a = numpy.arange(6).reshape(2, 3) - 4
dpt_a = dpt.asarray(a)
dpt.all(dpt_a,axis=0)
> usm_ndarray([ True, False,  True])

The dpctl.tensor.any function does not work on CPU (Segmentation fault) with the parameter axis=0 and dimension >=3 of the input ndarray for all dtypes.

import dpctl.tensor as dpt

dpt_a = dpt.ones((2, 3, 4))
dpt.any(dpt_a,axis=0)
Segmentation fault (core dumped)

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions