Skip to content

Support arithmetic operations with scalar #592

Closed

Description

@Alexander-Makaryev
In [1]: import dpctl.tensor as dpt

In [2]: import numpy

In [3]: a = numpy.arange(4)

In [4]: b = dpt.from_numpy(a)

In [5]: b * 2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-e8bdcb44ebff> in <module>
----> 1 b * 2

TypeError: unsupported operand type(s) for *: 'dpctl.tensor._usmarray.usm_ndarray' and 'int'

In [6]: 2 * b
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-fde996378900> in <module>
----> 1 2 * b

/localdisk/work/amakarye/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_usmarray.pyx in dpctl.tensor._usmarray.usm_ndarray.__mul__()

/localdisk/work/amakarye/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_usmarray.pyx in dpctl.tensor._usmarray._dispatch_binary_elementwise()

AttributeError: 'int' object has no attribute '__array_namespace__'

Activity

  1. added 4 commits that reference this issue on Sep 21, 2021
    fdb119c
    9fac56d
    e60a9f8
    936bd69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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