Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during backward if groups are created with wrong data shapes #12

Open
Xanthorapedia opened this issue Oct 30, 2021 · 1 comment
Open

Comments

@Xanthorapedia
Copy link

Hi, thanks for creating this wonderful library!❤️ However, I ran into the following bug when using it with torch.autograd.

For example, if I try to find the Jacobian w.r.t. a group parameter:

x = LieGroupParameter(SE3.Identity(1))
p = torch.ones(1000, 3)

def func1(x_, p_):
    # have to wrap with lietorch.SE3 because arguments are passed as tensors
    return SE3(x_).act(p_).sum()

# throws error: double free or corruption (!prev)
print(torch.autograd.functional.jacobian(func1, (x, p)))

The problem seems to be that during the preprocessing stage of torch.autograd, it clones the input data, but for LieGroupParameter, this only retrieves the tangent space data. Somehow the forward function was happy with those 1-dim-less inputs and didn't throw an error until the backward call. The same error appears if I do:

SE3(torch.zeros(1, 6, requires_grad=True)).act(torch.ones(1000, 3)).sum().backward() #double free or corruption (!prev)

It would be nice if you can help look into the above error. Also, it's probably a good idea for LieGroup.__init__ or the op implementations to have some sanity check on the input dimensions so that it catches the problem earlier. Otherwise, thank you for your hard work!😃

@Xanthorapedia
Copy link
Author

Xanthorapedia commented Oct 30, 2021

PS: For my hypothetical use case above, I was able to workaround by:

def func2(x_, p_):
    return SE3.Identity(x_.shape[:-1]).retr(x_).act(p_).sum()

print(torch.autograd.functional.jacobian(func2, (x, p)))

Output:

(tensor([[1000., 1000., 1000.,    0.,    0.,    0.]]), tensor([[1., 1., 1.],
        [1., 1., 1.],
        [1., 1., 1.],
        ...,
        [1., 1., 1.],
        [1., 1., 1.],
        [1., 1., 1.]]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant