Skip to content

Fix onnxscript/rewriter/redundant_scatter_nd.py #2430

@justinchuby

Description

@justinchuby

In onnxscript/rewriter/redundant_scatter_nd.py, fail was not called correctly. Follow onnxscript/rewriter/matmul_add_to_gemm.py as an example to improve the calls.

Traceback (most recent call last):
  File "/home/justinchu/anaconda3/envs/onnx/lib/python3.13/site-packages/onnx_ir/passes/_pass_infra.py", line 237, in call
    pass_result = pass_(model)
  File "/home/justinchu/anaconda3/envs/onnx/lib/python3.13/site-packages/onnx_ir/passes/_pass_infra.py", line 126, in __call__
    result = self.call(model)
  File "/home/justinchu/dev/onnxscript/onnxscript/rewriter/__init__.py", line 58, in call
    count = self.rules.apply_to_model(model)
  File "/home/justinchu/dev/onnxscript/onnxscript/rewriter/_rewrite_rule.py", line 583, in apply_to_model
    count = self._apply_to_graph_or_function(
        model, model.graph, verbose=verbose, tracer=tracer
    )
  File "/home/justinchu/dev/onnxscript/onnxscript/rewriter/_rewrite_rule.py", line 474, in _apply_to_graph_or_function
    delta = rule.try_rewrite(
        model, graph_or_function, node, verbose=verbose, tracer=tracer
    )
  File "/home/justinchu/dev/onnxscript/onnxscript/rewriter/_rewrite_rule.py", line 179, in try_rewrite
    check_match_result = self._condition_function(context, **match.bindings)
  File "/home/justinchu/dev/onnxscript/onnxscript/rewriter/redundant_scatter_nd.py", line 89, in check
    return fail("The shape of 'data' and 'updates' are different.", data, updates)
  File "/home/justinchu/dev/onnxscript/onnxscript/rewriter/redundant_scatter_nd.py", line 28, in fail
    return onnxscript.rewriter.MatchResult().fail(*args)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
TypeError: MatchResult.fail() takes from 1 to 3 positional arguments but 4 were given

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions