Skip to content

Incorrect result in dpctl.tensor.tensordot for axes=0 #1570

Closed

Description

@ndgrigorian
In [27]: x1 = dpt.asarray(1, dtype="i2")

In [28]: x2 = dpt.asarray([0, 1, 0, 0], dtype="i2")

In [29]: dpt.tensordot(x1, x2, axes=0)
Out[29]: usm_ndarray([0, 1, 1, 1], dtype=int16)

This does not occur for int32, but does appear for int8, uint8, and float16. Likely being caused by the gemm tree reduction implementation.

Does not occur for complex

In [45]: x1 = dpt.asarray(1, dtype="c8")

In [46]: x2 = dpt.asarray([0, 1, 0, 0], dtype="c8")

In [47]: dpt.tensordot(x1, x2, axes=0)
Out[47]: usm_ndarray([0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j], dtype=complex64)

Also only occurs for small cases

In [16]: x1 = dpt.asarray(1, dtype="i2")

In [17]: x2 = dpt.zeros(256, dtype="i2")

In [18]: x2[50] = 1

In [19]: dpt.tensordot(x1, x2, axes=0)
Out[19]:
usm_ndarray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int16)

Activity

  1. added a commit that references this issue on Mar 1, 2024
    da065b5
  2. added a commit that references this issue on Mar 1, 2024
    289ac65
  3. added 2 commits that reference this issue on Mar 26, 2024
    2f60f37
    9543077
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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