Boolean reductions allocate int32 temporary as USM-device#1565
Merged
oleksandr-pavlyk merged 1 commit intomasterfrom Feb 26, 2024
Merged
Conversation
Closes gh-1563 Allocating the temporary as USM-device ensures that atomic updates are always possible.
ndgrigorian
approved these changes
Feb 26, 2024
Collaborator
ndgrigorian
left a comment
There was a problem hiding this comment.
This fixes the problem for me locally
In [5]: x
Out[5]:
usm_ndarray([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
[20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
[30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
[40, 41, 42, 43, 44, 45, 46, 47, 48, 49],
[50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
[60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
[70, 71, 72, 73, 74, 75, 76, 77, 78, 79],
[80, 81, 82, 83, 84, 85, 86, 87, 88, 89],
[90, 91, 92, 93, 94, 95, 96, 97, 98, 99]], dtype=int32)
In [6]: x.usm_type
Out[6]: 'host'
In [7]: dpt.all(x)
Out[7]: usm_ndarray(False)
In [8]: dpt.any(x)
Out[8]: usm_ndarray(True)
before:
In [3]: dpt.any(x)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[3], line 1
----> 1 dpt.any(x)
File ~/repos/dpctl/dpctl/tensor/_utility_functions.py:126, in any(x, axis, keepdims)
101 def any(x, axis=None, keepdims=False):
102 """any(x, axis=None, keepdims=False)
103
104 Tests whether any input array elements evaluate to True along a given axis.
(...)
124 containing the results of the logical OR reduction.
125 """
--> 126 return _boolean_reduction(x, axis, keepdims, tri._any)
File ~/repos/dpctl/dpctl/tensor/_utility_functions.py:45, in _boolean_reduction(x, axis, keepdims, func)
38 wait_list = []
39 res_tmp = dpt.empty(
40 res_shape,
41 dtype=dpt.int32,
42 usm_type=res_usm_type,
43 sycl_queue=exec_q,
44 )
---> 45 hev0, ev0 = func(
46 src=x_tmp,
47 trailing_dims_to_reduce=red_nd,
48 dst=res_tmp,
49 sycl_queue=exec_q,
50 )
51 wait_list.append(hev0)
53 # copy to boolean result array
ValueError: This reduction is not supported for this device and usm_type.
|
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Collaborator
|
Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_22 ran successfully. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes gh-1563
Allocating the temporary as USM-device ensures that atomic updates are always possible.