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

Enable support for Python operators in usm_ndarray class #1324

Merged
merged 28 commits into from
Aug 9, 2023

Conversation

oleksandr-pavlyk
Copy link
Collaborator

This PR has the effect of unlocking use of dpctl.tensor elementwise functions to power special methods in usm_ndarray class.

In [1]: import dpctl.tensor as dpt, numpy as np

In [2]: dpt.ones(10) / 2
Out[2]: usm_ndarray([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], dtype=float32)
  • 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?

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

usm_ndarray constructor's array_namespace argument's default value of None
is now interpreted to mean that usm_ndarray.__array_namespace__ returns
dpctl.tensor, rather than None.

This directly affects how Python operator special methods of usm_ndarray
behave. They would now look up corresponding attribute in dpctl.tensor
namespace.
@coveralls
Copy link
Collaborator

coveralls commented Aug 3, 2023

Coverage Status

coverage: 84.919% (+0.08%) from 84.839% when pulling ebd1faf on enable-operators into acd1a60 on master.

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_89 ran successfully.
Passed: 796
Failed: 204
Skipped: 119

```
In [1]: dpctl.tensor._usmarray as ua

ua._basic_slice_meta((0, slice(1, 0, None)), (4, 4), (4, 1), 0)
```

The issue was discovered by array API conformance tests.
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_90 ran successfully.
Passed: 796
Failed: 204
Skipped: 119

oleksandr-pavlyk and others added 2 commits August 3, 2023 11:56
```
import dpctl.tensor as dpt
x = dpt.empy((0,2), dtype='i4')
x[Ellipsis, 1]
     returns empty 1d array
```
- "power" corrected to "pow, "mod" corrected to "remainder"
- logical functions corrected to bitwise
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_91 ran successfully.
Passed: 799
Failed: 201
Skipped: 119

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_95 ran successfully.
Passed: 905
Failed: 95
Skipped: 119

oleksandr-pavlyk and others added 2 commits August 3, 2023 14:55
```
import dpctl.tensor as dpt
import dpctl.tensor._usmarray as ua

x = dpt.asarray([[0, 0], [1, 0]], dtype='int8')
key = (None, 0, slice(1, None, -1))

meta = ua._basic_slice_meta(key, x.shape, x.strides, x._element_offset)

y = dpt.usm_ndarray.__new__(dpt.usm_ndarray, meta[0], dtype=x.dtype, strides=meta[1], buffer=x.usm_data, offset=meta[2])

print(y.flags)
```

Both 'C' and 'F' flags of the created array used to be set, now both
are correctly unset.
- Incorrect test logic was being hidden by the bug
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_97 ran successfully.
Passed: 891
Failed: 109
Skipped: 119

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_100 ran successfully.
Passed: 894
Failed: 106
Skipped: 119

Array API tests pointed out an error in implementation of order='K'
in dpctl.tensor.astype. Moved _empty_like_orderK and fried from
_type_utils to _copy_utils and used it to implement astype.

Modified import statement in _elementwise_common where _empty_like*
are used.
@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_102 ran successfully.
Passed: 907
Failed: 93
Skipped: 119

1 similar comment
@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_102 ran successfully.
Passed: 907
Failed: 93
Skipped: 119

The dpctl/tests/test_type_utils.py has been removed.
```
import dpctl.tensor as dpt
x1 = dpt.full(tuple(), 77, dtype='u2')
x2 = dpt.zeros(2, dtype='uint8')[dpt.newaxis, :]

dpt.concat((x1, x2), axis=None)
```

The reason the exception was raised is that
_copy_usm_ndarray_for_reshape which is used in the
implementation of concat with axis=None requires
both source and destination to have the same
data-type.
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_106 ran successfully.
Passed: 909
Failed: 91
Skipped: 119

If both arguments are -inf, the result is also -inf.
The change is to suppress RuntimeWarning arising from within
assert_allclose utility.
Use `self.flags_` directly, instead of getting it via temporary
Flags object.
@oleksandr-pavlyk oleksandr-pavlyk marked this pull request as ready for review August 8, 2023 10:14
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_118 ran successfully.
Passed: 912
Failed: 88
Skipped: 119

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_119 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_120 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

1 similar comment
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_120 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

@oleksandr-pavlyk
Copy link
Collaborator Author

Given that this PR has grown big, I am inclined to get it merged while deferring further changes to new PRs.

Would like a feedback from dpnp team about any disruption to dpnp test suite.

@antonwolfy
Copy link
Collaborator

Given that this PR has grown big, I am inclined to get it merged while deferring further changes to new PRs.

Would like a feedback from dpnp team about any disruption to dpnp test suite.

All dpnp tests are successfully passed with the PR.

Copy link
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

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

If you won't be adding more changes and dpnp has no issues, then this PR LGTM @oleksandr-pavlyk .

@oleksandr-pavlyk oleksandr-pavlyk merged commit 341d4da into master Aug 9, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the enable-operators branch August 9, 2023 20:23
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

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

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Array API standard conformance tests for dpctl=0.14.6dev1=py310h7bf5fec_29 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

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.

4 participants