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

[IR] Support symbolic values? #1438

Open
Tracked by #1324
justinchuby opened this issue Apr 23, 2024 · 3 comments
Open
Tracked by #1324

[IR] Support symbolic values? #1438

justinchuby opened this issue Apr 23, 2024 · 3 comments
Assignees
Labels
contribution welcome We welcome code contributions for this topic: IR Intermediate representation
Milestone

Comments

@justinchuby
Copy link
Collaborator

Create a field in Value to support representing equivalence relations among values.

  1. Value' is an alias of Value, e.g. output of identity or +0
  2. Value is a Sequence containing known values as elements
@justinchuby justinchuby added the topic: IR Intermediate representation label Apr 23, 2024
@justinchuby justinchuby mentioned this issue Apr 23, 2024
67 tasks
@justinchuby justinchuby added the contribution welcome We welcome code contributions for this label Apr 23, 2024
@justinchuby
Copy link
Collaborator Author

Before this is created, I recommend using a key in the meta dictionary to store this information. It is possible to create a helper function to interact with the dictionary. Replacing it with the new field when the field is implemented should be easy.

Another question is how we can make the field robust. Is there a lightweight pass we can run every time the graph is changed? Do we need to create any invariance on this field?

@justinchuby
Copy link
Collaborator Author

cc @gramalingam

I came up with a new idea for this. It may be helpful to create an auxiliary data structure for this, rather than making it a field in values since it is more usage specific. Consider a data structure with these apis:

  1. mark_equivalence(value_1, value_2) and mark_equivalence(value_1, [<sequence of values>]) Establishes that two values are equivalent
  2. unmark_equivalence(value_1, value_2) breaks the equivalence relationship
  3. assign(value, ir.Tensor) binds a constant tensor to a value, and internally also binds it to all values that share the equivalence relation
  4. are_equivalent(value_1, value_2) returns whether two values are the same
  5. etc.

This way it is very easy to establish and manage equivalence relationships. Internally it can be represented as a tree like structure.

@justinchuby justinchuby changed the title [IR] Support symbolic values [IR] Support symbolic values? May 8, 2024
@justinchuby justinchuby added this to the 0.1 milestone May 9, 2024
@gramalingam
Copy link
Collaborator

Keeping it a separate data-structure makes sense: making it clear it is the user's responsibility in all regards. Agree with that. However, a dictionary mapping an IR value to its symbolic value would work better for this particular usage than an equivalence-relation data-structure. I think I will try that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome We welcome code contributions for this topic: IR Intermediate representation
Projects
None yet
Development

No branches or pull requests

3 participants