Nothing Special   »   [go: up one dir, main page]

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

Constant Funsor #548

Merged
merged 32 commits into from
Sep 23, 2021
Merged

Constant Funsor #548

merged 32 commits into from
Sep 23, 2021

Conversation

ordabayevy
Copy link
Member

Addresses #547

@ordabayevy ordabayevy added enhancement New feature or request WIP labels Aug 25, 2021
Copy link
Member Author
@ordabayevy ordabayevy left a comment

Choose a reason for hiding this comment

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

Implementation of Constant Funsor with patterns for substitution, unary, binary, some of the reduction ops, and to_data, to_funsor functions. One use case is in Delta.eager_reduce as lazy Zero terms.

funsor/delta.py Outdated
if point.inputs:
scale += (point == point).all().log()
scale += funsor.Constant(point.inputs, Number(0))
Copy link
Member Author

Choose a reason for hiding this comment

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

This is one use case (and line 191) for Constant term.

funsor/joint.py Outdated Show resolved Hide resolved
@ordabayevy ordabayevy removed the WIP label Aug 27, 2021
@ordabayevy ordabayevy marked this pull request as draft September 19, 2021 16:44
@fritzo
Copy link
Member
fritzo commented Sep 21, 2021

@eb8680 I wonder if we could remove sample_inputs from MonteCarlo and instead read those from a constant funsor. E.g. in #549 I'm struggling with MonteCarlo introducing sample inputs in adjoint, and a possible simplification would be to add a Constant funsor to the root 🤔

@ordabayevy
Copy link
Member Author

After working on this I came to a conclusion that the counterpart of ProvenanceTensor is not Constant funsor but something more like Delta. So the to_funsor and to_data patterns should be removed from this PR I believe.

Copy link
Member
@eb8680 eb8680 left a comment

Choose a reason for hiding this comment

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

Sorry for such a late review. This mostly looks good, and it's self-contained, so I'm OK merging modulo a few nits. It would be good to sync again about the larger context for this PR since it sounds like your thinking has changed.

funsor/constant.py Show resolved Hide resolved
funsor/constant.py Show resolved Hide resolved
@ordabayevy ordabayevy marked this pull request as ready for review September 23, 2021 19:27
@ordabayevy
Copy link
Member Author

@eb8680 I made the changes that we discussed over Zoom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants