Skip to content

[Feature request] Support different out dtypes for elementwise func #1717

Closed
@vlad-perevezentsev

Description

@vlad-perevezentsev

Current implementations of elementwise functions in dpctl.tensor do not support out data type other than bool and raise ValueError if out is not bool.

import dpctl.tensor as dpt

a = dpt.asarray([1,2,3])
out = dpt.empty_like(a,dtype='f4')
dpt.logical_not(a,out=out)

# ValueError: Output array of type bool is needed, got float32

While numpy can cast the result depending on out data type.

import numpy

a_np = dpt.asnumpy(a)
out_np = dpt.asnumpy(out)
numpy.logical_not(a_np, out_np)

# array([0., 0., 0.], dtype=float32)

Since the Python Array API has no description for out parameter we can implement any logic we want.
I think it would be useful to follow the logic of numpy and cast the result depending on out data type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions