Skip to content

Constant Funsor#548

Merged
eb8680 merged 32 commits into
masterfrom
constant
Sep 23, 2021
Merged

Constant Funsor#548
eb8680 merged 32 commits into
masterfrom
constant

Conversation

@ordabayevy
Copy link
Copy Markdown
Member

Addresses #547

@ordabayevy ordabayevy added enhancement New feature or request WIP labels Aug 25, 2021
Copy link
Copy Markdown
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.

Comment thread funsor/delta.py Outdated
# XXX obscenely wasteful - need a lazy Zero term
if point.inputs:
scale += (point == point).all().log()
scale += funsor.Constant(point.inputs, Number(0))
Copy link
Copy Markdown
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.

Comment thread funsor/joint.py
@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread funsor/constant.py
Comment thread funsor/constant.py
@ordabayevy ordabayevy marked this pull request as ready for review September 23, 2021 19:27
@ordabayevy
Copy link
Copy Markdown
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