Abdelrahman_Akram:

depth = depth @ rot_mat_T


When you do that, you make the “depth” python variable point to the result of depth @ rot_mat_T instead of the Tensor it was pointing out before (the result of torch.randn((22000,3), requires_grad= True)).
But the .grad field is only populated for leaf Tensors that require gradients.
And you can check that the “depth” just afterr creating it at the top .is_leaf==True.
But after depth = depth @ rot_mat_T the new Tensor “depth” points to has .is_leaf==False.
So the .grad field won’t be populated, hence the warning.