-
Notifications
You must be signed in to change notification settings - Fork 68
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
[WIP] add a preprocessor #207
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, it would be good to start seeing some test here to find edge cases. A few notes:
- I would make a comment pass, see if we can highlight which operation we are reducing at each stage.
- The input/output pairing worries me a little bit. I wonder if we leave this as "internal"
oe.contract(..., preprocess=True)
- It would be good to have a pathway for the
propocess=True
pathway.
Super cool addition!
from .parser import find_output_str | ||
|
||
|
||
def unique(it): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we type these? I cannot quite tell what this is doing, somewhat looks like a set operation.
) | ||
|
||
|
||
def make_simplifier(*args, backend="numpy"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def make_simplifier(*args, backend="numpy"): | |
def expression_simplifier(*args, backend="numpy"): |
array([[0.65245661, 0.14684493, 0.42543411, 0.32350895], | ||
[0.38357005, 0.08632807, 0.25010672, 0.19018636]]) | ||
""" | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need quite a few tests around this tech, too bad we cannot reproduce the original parsing tech here.
Description
This adds a potential preprocessor that takes an equation and converts it into a minimal form with the following simplifications:
along with a function, that transforms input arrays into the inputs for the new simplified
eq
. It is a function so that it could be part of a contract 'expression'.This would address (#114, #99, #112, #167, #189, ...).
Example from the docstring:
Todos
Notable points that this PR has either accomplished or will accomplish.
size_dict
) be used and propagated for use with a contraction expression (and so that the smallest tensor to multiply scalars into can be most accurately chosen)?currently the parsing is a single sweep, should it iteratively sweep til no more changes? E.g. currently examples likeab,ab->
transform toab->
but if processed again could transform to->
Status