I used the detect_anomally to detect the forward error, and it told me that the line of fake_h had an in-place operation.
In my opinion, those two lines are the same. Why only the second line caused the error while the first line passed? And the second question is why the second line is an in-place operation?
The shape of grid is [B, 3778, 2]. The error is listed below.
[W python_anomaly_mode.cpp:104] Warning: Error detected in MaxBackward1. Traceback of forward call that caused the error:
....................................
....................................
File "/home/xywang/xywang/hj-hassony2/meshreg/models/meshregnet.py", line 587, in gridsamplefun
fake_h = torch.max(grid[:, :, 1])
And I still have a question that in some codes why people do .clone() when operating on the same elements (e.g. grid[:, :, 0] = 2.0 * grid[:, :, 0].clone())?