While trying to implement a backward pass, I keep getting the error of CUDA Illegal Memory Access.
@staticmethod
    def backward(ctx, grad_output):
         grad_label = grad_output.clone()
        num_ft = grad_output.shape[0]
        # grad_label.data.resize_(num_ft, 32, 41)
        lin_indices_3d, lin_indices_2d = ctx.saved_variables
        num_ind = lin_indices_3d.data[0]
        grad_label.data.view(num_ft, -1).index_copy_(1, lin_indices_2d.data[1:1 + num_ind],
                                                     torch.index_select(grad_output.data.contiguous().view(num_ft, -1),
                                                                        1, lin_indices_3d.data[1:1 + num_ind]))
        # raw_input('sdflkj')
        return grad_label, None, None, None

I tried using pdb to see what might be the possible cause
image1224×142 49.7 KB
I am not sure what is wrong in the implementation here. Any help would be highly appreciated.
I am using PyTorch 1.3 but the same error persists on 1.4 and 1.5