Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dpctl.tensor.put returns incorrect result #1360

Closed
vlad-perevezentsev opened this issue Aug 21, 2023 · 3 comments
Closed

dpctl.tensor.put returns incorrect result #1360

vlad-perevezentsev opened this issue Aug 21, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@vlad-perevezentsev
Copy link
Collaborator

The code below works incorrectly in dpctl when dpctl.tensor.put needs to rewrite the duplicate index of an element with a different value

import dpctl.tensor as dpt

x = dpt.ones((5,))
ind = dpt.asarray([0, 0])

dpt.put(x, ind, [10, 20])
x
> usm_ndarray([10.,  1.,  1.,  1.,  1.])

import numpy
a = numpy.ones((5,))
numpy.put(a, [0, 0], [10, 20])
a
> array([20.,  1.,  1.,  1.,  1.])

@vlad-perevezentsev vlad-perevezentsev added the bug Something isn't working label Aug 21, 2023
@oleksandr-pavlyk
Copy link
Contributor

put parallelizes assignments, and the present input results in race condition.

@ndgrigorian ndgrigorian self-assigned this Apr 17, 2024
oleksandr-pavlyk added a commit that referenced this issue Apr 23, 2024
Document race condition in put when indices array contain duplicated.
Provide an example of resolving race condition for 1-d ``x``, ``indices``,
and ``vals``.
oleksandr-pavlyk added a commit that referenced this issue Apr 23, 2024
@oleksandr-pavlyk
Copy link
Contributor

#1653 adds a docstring note for dpt.put warning of the race condition, and provides sample code for resolving it for 1D case.

This addition resolves this issue, which we intend to closed in a few days.

@ndgrigorian
Copy link
Collaborator

Closing this issue as resolved now that #1653 is in and #1384 is closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants