I’m (mostly) someone-else’s code in combination with PWC-Net 1 with (their) existing inputs. I’m getting an error in one of the cases (not every case). Here is all the code that I think is relevant:
    print("Shape of mask is:", mask.shape)
    s = (mask > 0.999).shape
    print("Shape of (mask > 0.999) is:", s)
    mask[mask > 0.999] = 1.0  # <-- Error occurs here!

Here, mask is a PyTorch tensor. The output is:

Shape of mask is: torch.Size([1, 1, 28, 40])
Shape of (mask > 0.999) is: torch.Size([1, 1, 28, 40])
Traceback (most recent call last):

File “/home/algomorph/Workbench/NeuralTracking/model/pwcnet.py”, line 41, in Backward
mask[mask > 0.999] = 1.0  # ← Error occurs here!
RuntimeError: invalid shape dimension -1096498240

The only clue I found online is the C++ header file 3 that raises this error in PyTorch.
Any clues as to what might be happening here?
Aside: I’m using PyTorch 1.7.1 compiled from source, i.e. version ‘1.7.0a0+57bffc3’ [also tested with the official 1.8.1 CUDA 11.1 release for pip]
Another aside: mask is of type torch.cuda.FloatTensor and is located on the cuda:0 device.
Here is the mask tensor serialized via torch.save(…) . When I load it in a separate python shell and try to perform the operation on it, the error does not occur.