Skip to content

What is the best way to match against optional attributes? #1902

Open
@xuzhenqi

Description

@xuzhenqi

Suppose we need to remove an optional input of a node, for example, we want to replace DFT(x, None, -2) with DFT(x), since the default axis is -2, so we can remove the axis input.

The DFT node has two optional attributes (onesided and inverse). What is the best way to write pattern to cover these cases:

  • DFT(x, None, -2) -> DFT(x)
  • DFT(x, None, -2, onesided=1) -> DFT(x, onesided=1)
  • DFT(x, None, -2, inverse=1) -> DFT(x, inverse=1)
  • DFT(x, None, -2, inverse=1, onesided=1) -> DFT(x, inverse=1, onesided=1)

It seems we need write four rules for the four cases, is there any better solutions? cc @justinchuby

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