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

Merging developmental snapshot tagged 0.14.6dev2 to gold/2021 #1337

Merged
merged 53 commits into from
Aug 11, 2023

Conversation

oleksandr-pavlyk
Copy link
Collaborator

This PR merges development snapshot tagged 0.14.6dev2 of dpctl to gold/2021.

This picks up

oleksandr-pavlyk and others added 30 commits August 2, 2023 18:20
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.
```
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.
```
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
```
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
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.
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.
```

In [1]: import dpctl.tensor as dpt

In [2]: a = dpt.arange(10, dtype='int64')
   ...: b = dpt.arange(10, dtype='float32')

In [3]: dpt.concat((a,b))
Out[3]:
usm_ndarray([0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 0., 1., 2., 3., 4.,
             5., 6., 7., 8., 9.], dtype=float32)

In [4]: _.sycl_device.name
Out[4]: 'Intel(R) Graphics [0x9a49]'
```
- 'or' conditions can sometimes cause wrong results when using the OS compiler
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 and others added 23 commits August 9, 2023 10:10
When source array must be broadcast, non-zero strides corresponding
to unit size dimensions must be zeroed out, otherwise if such dimension is
broadcasted, constructor would expected a bigger buffer than is really
necessary.
Enable support for Python operators in usm_ndarray class
This commit short-circuited broadcastability of shapes for zero-size
rhs in __setitem__.

Refix array API test failure without introducing this regression and
reuse _manipulation_functions._broadcast_strides as suggested by
@ndgrigorian
…twise_funcs

impl_minimum_maximum_elementwise_funcs
Also added comment to explain the logic of the code.
Added declaration, doxygen docs, implementation and tests.
Also enabled overlooked check_default_context
It is not yet supported on Windows.
* Adds `math_utils.hpp` with complex comparison functions

* Refactors comparison functions to use math_utils implementations

* Refactors maximum and minimum to use math_utils implementations
* Fixed some complex special cases for expm1

* Silence remaining warnings in elementwise tests

* Tweaks to expm1 complex special case logic

* expm1 special case change

For `inf` real part and finite, nonzero imaginary part, now guaranteed to be (+/-`inf`, +/-`inf`), with cosine and sine of the imaginary part determining the sign, respectively
This returns default index type for give device. Since all devices
are 64-bit devices, it always returns "i8".
Closes gh-1335.

The issue was caused by nonzero using default integral data type,
not default index data type.
A non-empty array which is effectively 1D (only one dimension has
size greater than one) should be marked as both C- and F- contiguous.

```
In [1]: import dpctl.tensor as dpt

In [2]: a = dpt.ones((2, 3))
   ...: dpt.reshape(a, (1, 6, 1)).flags
Out[2]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  WRITABLE : True

In [3]: a = dpt.ones((2, 3), order='F')
   ...: dpt.reshape(a, (1, 6, 1), order='F').flags
Out[3]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  WRITABLE : True

In [4]: a = dpt.ones((2, 3, 4))
   ...: dpt.sum(a, axis=(1, 2), keepdims=True).flags
Out[4]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  WRITABLE : True
```
SyclPlatform equality operator implemented
usm_ndarray.to_device(dev, stream=queue) support
@oleksandr-pavlyk
Copy link
Collaborator Author

@xaleryb For awareness. Merging right away.

@oleksandr-pavlyk oleksandr-pavlyk merged commit 9e81f89 into gold/2021 Aug 11, 2023
@github-actions
Copy link

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

@github-actions
Copy link

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev2=py310h7bf5fec_31 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.

3 participants