Hi, @richard
Autograd works correctly with the code you supplied. However, runtime error still occurs with the code below, which is part of the forward function of my custom module.
message_weight = torch.sigmoid(fc_self_out_reshape + fc_neig_out_reshape + fc_pointcloud_out_relative) 
message_weight[:, 0, :, :] = 0.5
message_weight = message_weight + 10

The error is:
Traceback (most recent call last):
  File "/home/zhangyi/pytorch-ws/test_PGNNet.py", line 31, in <module>
    main()
  File "/home/zhangyi/pytorch-ws/test_PGNNet.py", line 27, in main
    loss.backward()
  File "/home/zhangyi/miniconda3/lib/python3.6/site-packages/torch/autograd/variable.py", line 148, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables)
  File "/home/zhangyi/miniconda3/lib/python3.6/site-packages/torch/autograd/__init__.py", line 99, in backward
    variables, grad_variables, retain_graph)
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation

If I comment out the line
message_weight[:, 0, :, :] = 0.5

autograd works correctly. Very strange…
Is there any other reason for this runtime error?