princeton-vl / lietorch

BSD 3-Clause "New" or "Revised" License
679 stars 50 forks source link

vec() method failing. #21

Open NicolayP opened 2 years ago

NicolayP commented 2 years ago

Hi, I have this use case where I have an SE3 element of shape [2, 3]. When looking at the vec embedding of a subsection of it, the method fails. Here is a snap of the code to reproduce the error

poses = torch.tensor(np.zeros(shape=(2, 3, 7)), dtype=dtype, device=device)
poses[:, :, -1] = 1.
M = SE3.InitFromVec(poses)

M_init = M[:, :2] 
M_init.vec() # Fails

Upon investigation, it is triggered in the broadcasting method of the library. So I changed from view to reshape. (Can't explain the why of the solution) Line 13 of broadcasting.py is change from

return (x.view(-1, xd).contiguous(), ), x.shape[:-1]

to

return (x.reshape(-1, xd).contiguous(), ), x.shape[:-1]