Skip to content

Fixed regression in iteration space simplifier, fixed arguments of numpy to usm_ndarray copying function #1202

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

Merged
merged 3 commits into from
May 8, 2023

Conversation

oleksandr-pavlyk
Copy link
Contributor

This PR fixes issues in simplify_iteration_space* functions introduced in gh-1198.

It also corrects calculation of numpy array byte-boundaries to form sycl::buffer accessing
content of NumPy's array from a SYCL kernel.

Closes gh-1201

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you opening the PR as a draft?

For nd==1, and when simplifying iteration over multiple arrays,
strides should only change sign if all strides are negative.
When figuring out the bytes-boundary of numpy array to form
the sycl::buffer we use simplified strides and shapes, and hence
must start with src_offset, not with zero.

Now, both of these copy calls correctly populate the destination
usm_ndarray.

```
In [2]: n, m = 10**2, 10**3

In [3]: a = np.hstack((np.arange(n, dtype=np.int32),) * m)

In [4]: b = np.flipud(a)

In [5]:

In [5]: c = dpt.asarray(b, device='cpu')

In [6]: c
Out[6]: usm_ndarray([99, 98, 97, ...,  2,  1,  0], dtype=int32)

In [7]: import dpctl.tensor._tensor_impl as ti

In [8]: c = dpt.empty(b.shape, dtype=b.dtype)[::-1]

In [9]: ti._copy_numpy_ndarray_into_usm_ndarray(src=b, dst=c, sycl_queue=c.sycl_queue)

In [10]: c
Out[10]: usm_ndarray([99, 98, 97, ...,  2,  1,  0], dtype=int32)

In [11]: c = dpt.empty(b.shape, dtype=b.dtype)

In [12]: ti._copy_numpy_ndarray_into_usm_ndarray(src=b, dst=c, sycl_queue=c.sycl_queue)

In [13]: c
Out[13]: usm_ndarray([99, 98, 97, ...,  2,  1,  0], dtype=int32)
```
@github-actions
Copy link

github-actions bot commented May 8, 2023

@coveralls
Copy link
Collaborator

Coverage Status

Coverage: 83.322%. Remained the same when pulling 8e43c77 on fix-gh-1201 into 004e3d9 on master.

@github-actions
Copy link

github-actions bot commented May 8, 2023

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_48 ran successfully.
Passed: 153
Failed: 847
Skipped: 116

1 similar comment
@github-actions
Copy link

github-actions bot commented May 8, 2023

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_48 ran successfully.
Passed: 153
Failed: 847
Skipped: 116

Copy link
Collaborator

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it works fine with dpnp, thank you @oleksandr-pavlyk !

@oleksandr-pavlyk oleksandr-pavlyk merged commit 1320d39 into master May 8, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the fix-gh-1201 branch May 8, 2023 20:52
@github-actions
Copy link

github-actions bot commented May 8, 2023

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@github-actions
Copy link

github-actions bot commented May 8, 2023

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_48 ran successfully.
Passed: 153
Failed: 847
Skipped: 116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression after merge of gh-1198
3 participants