Skip to content

MatchResult dictionary for pattern rewrite #1387

@gramalingam

Description

@gramalingam

Consider a pattern such as Add(MatMul(X,Y), Z). Every successful match of this pattern in an input model will bind variables X, Y and Z to values in the IR representation of the model.

The existing two representations of MatchResult return a dictionary mapping the variable names (like "X") to a value. But one representation returns the IR-value that X is bound to, while the second representation returns the IR-value's name instead. It would be good to reconcile this difference.

My suggestion is to use the first one. This makes it easier for the user-code, because they use this to check things like the shape or type of the value X is bound to, or whether it is a constant-value, etc. Given the name, the users have to do an additional lookup on the model/graph to go from the name to the IR-value. And when we write a rule, we don't even have the model/graph available.

See examples in the repo or this document

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions