Uh oh!
There was an error while loading. Please reload this page.
Add dtype and manipulation functions - #1566
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
View rendered docs @ https://intelpython.github.io/dpnp/pull/1566/index.html |
vtavana
commented
Sep 25, 2023
It seems we do not to skip the fallowing tests anymore. tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast_arrays |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ndgrigorian
commented
Oct 5, 2023
@npolina4 |
antonwolfy
commented
Oct 9, 2023
The below example works differently with numpy and description: a=numpy.ones((2, 3), dtype='i4')
b=a.astype('i4', copy=False)
bisa# Out: Truea=dpnp.ones((2, 3), dtype='i4')
b=a.astype('i4', copy=False)
bisa# Out: False |
| Parameters | ||
| ---------- | ||
| dtype : dtype | ||
| Target data type. |
There was a problem hiding this comment.
What is about None value? It would be good to state clearly, since dpctl and numpy supports that but might behave differently.
| return dpt.astype(x1, dtype, order=order, casting=casting, copy=copy) | ||
| Parameters | ||
| ---------- | ||
| dtype : dtype |
There was a problem hiding this comment.
Need to describe x1 and casting
| Otherwise, a copy is returned. | ||
| Parameters | ||
| ---------- | ||
| dtype : dtype |
| Limitations | ||
| ----------- | ||
| Parameter `subok` is supported with default value. | ||
| Otherwise the function will be executed sequentially on CPU. |
There was a problem hiding this comment.
Probably it would be better to get rid of the falling back on CPU and to raise an exception explicitly, like cupy does?
| new_array = self.__new__(dpnp_array) | ||
| new_array._array_obj = dpt.astype( | ||
| self._array_obj, dtype, order=order, casting=casting, copy=copy | ||
| return dpnp.astype( |
There was a problem hiding this comment.
It would be better to have main implementation here and then dpnp.astype will be equal to
if dpnp.is_supported_array_type(x1):
return x1.astype(...)
else:
raise TypeError(...)
Also it will allow us to avoid invoking dpnp.get_usm_ndarray(...) and dpnp_array._create_from_usm_ndarray(...).
| @@ -150,30 +151,41 @@ def asnumpy(input, order="C"): | |||
| def astype(x1, dtype, order="K", casting="unsafe", subok=True, copy=True): | |||
There was a problem hiding this comment.
Neither numpy or cupy has astype method (they have it only in the context of ndarray), so I would propose to remove unsupported subok parameter here.
| ------- | ||
| out : dpnp.array | ||
| If ``copy`` is False and no cast is required, then the array itself is returned. | ||
| Otherwise, it returns a (possibly casted) copy of the array. |
There was a problem hiding this comment.
It sounds a bit unclear what "possibly casted" means. Could you please clarify that in the description or rephrase it.
In general, numpy and dpctl returns a view where possible.
| def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True): | ||
| """Copy the array with data type casting. | ||
| """ |
There was a problem hiding this comment.
Could you please check tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView and unmute where possible?
Also it would be great refresh test_ndarray_copy_and_view.py file.
RP will separate:
#1582 Leverage dpctl.tensor.iinfo() and dpctl.tensor.finfo() implementation.
#1583 Clean up old implementation of logic functions
#1585 Updated atleast_2d and atleast_3d functions
#1586 Implemented dpnp.tile function.
Add dtype and manipulation functions and tests.
Manipulation functions: dpnp.broadcast_arrays, dpnp.repeat, dpnp.vstack, dpnp.ravel
Data Type functions: dpnp.can_cast