szha commented on issue #18789:
URL:
https://github.com/apache/incubator-mxnet/issues/18789#issuecomment-669334140
```python
In [3]: from mxnet import nd
...: import mxnet as mx
...: x = mx.np.zeros((10,))
...: x.attach_grad()
...: mx.npx.set_np()
...: class Op(mx.autograd.Function):
...: def forward(self, x):
...: out = x + 1
...: return out
...:
...: def backward(self, grad):
...: grad_x = grad
...: return grad_x
...:
...: op = Op()
...: with mx.autograd.record():
...: y = op(x)
...: y.sum().backward()
...:
...: print(x.grad)
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
In [4]:
Do you really want to exit ([y]/n)?
```
----------------------------------------------------------------
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]