Skip to content

[mlir] How to test folding an op "once" #145300

@yangtetris

Description

@yangtetris

This issue originates from PR #142124. Currently, the canonicalizer is the most widely used approach for testing folders. However, when people want to test the specific behavior of a folder, such as ensuring its efficiency, the canonicalizer seems somewhat inappropriate because it will repeatedly apply the folder until the corresponding op can no longer be folded. I have tried the max-iterations option, but it doesn't seem to work for folding. The reason might be in this code - when an op is folded in place, it gets re-added to the worklist, so it can still be folded multiple times within a single iteration.

if (foldResults.empty()) {
    // Op was modified in-place.
    notifyOperationModified(op);

PR #142124 worked around this testing issue by renaming the existing TestConstantFold pass to TestSingleFold. But I'm wondering if there are better ways to achieve the "fold once" purpose. Any thoughts or suggestions on would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions