khaotik commented on issue #6526:
URL:
https://github.com/apache/incubator-mxnet/issues/6526#issuecomment-790279925
Hi, I'm looking for simple issues for my first PR. Upon reviewing C++ code,
it seems this issue is already resolved, or am I missing anything?
I also made a small test case:
```python
#!/usr/bin/env python
from itertools import product
import numpy as np
import mxnet as mx
CTX_LIST = [mx.gpu(), mx.cpu()]
DTYPE_LIST = ['float16', 'float32', 'float64']
for CTX, DTYPE in product(CTX_LIST, DTYPE_LIST):
with mx.autograd.record():
v_x = mx.nd.random.uniform(
-1., 1., shape=(4,5,6),
dtype=DTYPE, ctx=CTX)
v_x.attach_grad(grad_req='add')
v_x.grad[:] = 0.
v_y = mx.nd.swapaxes(v_x, 1, 2)
v_err = mx.nd.square(v_y)
v_err.backward(retain_graph=True)
v_y = mx.nd.swapaxes(v_x, 0, 1)
v_err = mx.nd.square(v_y)
v_err.backward(retain_graph=True)
v_y = mx.nd.swapaxes(v_x, 0, 2)
v_err = mx.nd.square(v_y)
v_err.backward(retain_graph=True)
assert(np.allclose(v_x.asnumpy()*6, v_x.grad.asnumpy()))
```
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]