Skip to content

dpctl.tensor returns int8 arrays from ceil, trunc and floor function for bool input array #2030

Closed
@antonwolfy

Description

@antonwolfy

The example below works differently with numpy:

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

np.__version__
# Out: '2.2.4'

dpctl.__version__
# Out: '0.20.0dev0+71.gc5d18f4b6f'

a = np.ones(5, dtype='?')
ia = dpt.ones(5, dtype='?')

np.ceil(a).dtype
# Out: dtype('bool')

np.trunc(a).dtype
# Out: dtype('bool')

np.floor(a).dtype
# Out: dtype('bool')

dpt.ceil(ia).dtype
# Out: dtype('int8')

dpt.trunc(ia).dtype
# Out: dtype('int8')

dpt.floor(ia).dtype
# Out: dtype('int8')

In overall, it seems Python array API standard requires dtype of output array to be matched with dtype of input array:

out (array) – an array containing the rounded result for each element in x. The returned array must have the same data type as x.

Although the support of bool dtypes is not mandated:

x (array) – input array. Should have a real-valued data type.

It sounds like if dpctl provides the support of bool dtype, it has to return out array of bool dtype also.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions