RewriteRuleSet

class onnxscript.rewriter.pattern.RewriteRuleSet(rules: Sequence[RewriteRule], *, commute: bool = False)[source]
apply_to_model(model: Model, *, verbose: int | None = None, tracer: MatchingTracer | None = None) int[source]

Apply the rewrite rules in the set to the model.

Parameters:
  • model – The model to which the rewrite rules are applied.

  • verbose – The verbosity level of messages. Defaults to None.

  • tracer – if specified, no changes are made to the model, only information about the best matches found is computed.

Returns:

The number of applications of rewrite rules.