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

Memoize Transform.inv #885

Merged
merged 1 commit into from
Jan 21, 2021
Merged

Memoize Transform.inv #885

merged 1 commit into from
Jan 21, 2021

Conversation

fritzo
Copy link
Member

@fritzo fritzo commented Jan 21, 2021

Fixes behavior mismatch blocking pyro-ppl/funsor#427 identified by @eb8680

This makes NumPyro's Transform.inv property act more like PyTorch's.

Tested

  • added a new assertion
  • verified funsor tests pass locally

@@ -1038,6 +1038,7 @@ def test_bijective_transforms(transform, event_shape, batch_shape):
z = transform.inv(y)
assert_allclose(x, z, atol=1e-6, rtol=1e-6)
assert transform.inv.inv is transform
assert transform.inv is transform.inv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, @fritzo!

@fritzo fritzo merged commit 7e48b74 into master Jan 21, 2021
@fritzo fritzo deleted the transform-inv-weakref branch January 21, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants