ir_mutator.h
6.07 KB
-
[IR] Unify approach to Visitor/Mutator under Functor (#4606) · 983eba88
IRMutator and IRVisitor were the main data structures for doing low level IR visiting. As the project evolves, we start to introduce more powerful variants such as StmtFunctor and ExprFunctor. This PR brings new classes that allows us to migrate the visitor mutator to be sub-class of these functors. List of changes: - Create separate class for ExprMutator and StmtMutator, following convention used in relay. - Introduce copy-on-write to StmtMutator that can later benefit the statement mutations if we use move semantics and keep a single copy of stmt. - Move two generic visit mutate util to use the new classes. We will send followup PRs to migrate the existing passes that use the legacy visitors to the new one.
Tianqi Chen committed