Efficient PnP weighting bug fix

Summary:
There is a bug in efficient PnP that incorrectly weights points. This fixes it.

The test does not pass for the previous version with the bug.

Reviewed By: shapovalov

Differential Revision: D22449357

fbshipit-source-id: f5a22081e91d25681a6a783cce2f5c6be429ca6a
This commit is contained in:
David Novotny
2020-07-09 06:39:25 -07:00
committed by Facebook GitHub Bot
parent 2f3cd98725
commit daf9eac801
2 changed files with 67 additions and 12 deletions

View File

@@ -66,6 +66,10 @@ def _build_M(y, alphas, weight):
def prepad(t, v):
return F.pad(t, (1, 0), value=v)
if weight is not None:
# weight the alphas in order to get a correctly weighted version of M
alphas = alphas * weight[:, :, None]
# outer left-multiply by alphas
def lm_alphas(t):
return torch.matmul(alphas[..., None], t).reshape(bs, n, 12)
@@ -82,9 +86,6 @@ def _build_M(y, alphas, weight):
dim=-1,
).reshape(bs, -1, 12)
if weight is not None:
M = M * weight.repeat(1, 2)[:, :, None]
return M