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

Provide transform and inverse method implementations on AbstractBijection #193

Merged
merged 3 commits into from
Oct 23, 2024

Conversation

danielward27
Copy link
Owner

Provide an implementation for transform and inverse in AbstractBijection, by taking self.transform_and_log_det(x, condition)[0], self.inverse_and_log_det(y, condition)[0] . The original motivation for separately defining the methods was to avoid computing the log_det during transform and inverse. However, under JIT, the code seems to be removed by the compilers dead code elimination, and I have not seen any performance degradation from switching to this simpler approach. There is likely a performance penalty of this approach outside of JIT, but this is not something I am majorly concerned about.

We now only wrap the *_log_det methods with shape checking, as the transform and inverse methods will be checked by calling the *_log_det methods anyway. This does provide some risk for users who have defined custom bijections, as they will now be overwriting the transform and inverse methods, with a non-shape checked version. In general, I'd recommend no longer defining the inverse and transform methods.

@danielward27 danielward27 merged commit 1462f73 into main Oct 23, 2024
1 check passed
@danielward27 danielward27 deleted the dev branch October 23, 2024 10:39
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

Successfully merging this pull request may close these issues.

1 participant