qat.experimental.dialect.pulse.transforms package

class FoldConstantConstantOp

Bases: RewritePattern

Finds arithmetic operations whose operands are both constant-like and folds them into a single ConstantOp with the result of the operation as its value.

This is hooked in from canonicalization passes, and eliminates redundant arithmetic operations in the pulse dialect.

For example,

%frequency1 = pulse.constant<5e9> : !pulse.frequency
%frequency2 = pulse.constant<1e9> : !pulse.frequency
%result = pulse.add(%frequency1, %frequency2) : !pulse.frequency

can be replaced with

match_and_rewrite(op: Operation, rewriter: PatternRewriter) None

Match an operation, and optionally perform a rewrite using the rewriter.

Return type:

None

Submodules