sxjscience commented on a change in pull request #18342:
URL: https://github.com/apache/incubator-mxnet/pull/18342#discussion_r426198168
##########
File path: tests/python/unittest/test_numpy_ndarray.py
##########
@@ -1327,3 +1327,26 @@ def test_np_ndarray_pickle():
a_load = pickle.load(f)
same(a.asnumpy(), a_load.asnumpy())
[email protected]('dtype', [np.float32, np.int32])
[email protected]('size', [
+ (3, 4, 5, 6),
+ (2, 10),
+ (15,),
+ ()
+])
+@use_np
+def test_dlpack(dtype, size):
+ a = mx.np.random.uniform(size=size)
+ a_np = a.copy()
+
+ pack = mx.npx.to_dlpack_for_read(a)
+ b = mx.npx.from_dlpack(pack)
+
+ a_copy = a.copy()
+ pack2 = mx.npx.to_dlpack_for_write(a_copy)
+ c = mx.npx.from_dlpack(pack2)
Review comment:
Follow the comment above:
I suggest adding the test of `c += 1` and check whether `a_copy` is mutated
(test for wait to read).
```python
c = mx.npx.from_dlpack(pack2)
c += 1
same(a_np + 1, b)
same(a_np + 2, a_copy)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]