Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformations: (reconcile-unrealized-casts) Pass can't handle 1 to n and n to 1 casts #3686

Open
watermelonwolverine opened this issue Dec 30, 2024 · 0 comments

Comments

@watermelonwolverine
Copy link
Contributor

The reconcile-unrealized-casts pass from xDSL fails to reconcile 1 to n and n to 1 casts.

Example:

Using the pass on

module {

  func.func @reconcile_unrealized_casts(
    %value1 : f64,
    %value2 : f64
  ) -> (f64, f64) {

    %box = "builtin.unrealized_conversion_cast"(%value1, %value2) : (f64, f64) -> !box.box<[f64, f64]>
    %value1_, %value2_ = "builtin.unrealized_conversion_cast"(%box) : (!box.box<[f64, f64]>) -> (f64, f64)

    func.return %value1_, %value2_ : f64, f64
  }
}

raises an exception:

Traceback (most recent call last):
  File "/workspaces/Master_Thesis_Code/.venv/lib/python3.10/site-packages/xdsl/pattern_rewriter.py", line 835, in _process_worklist
    self.pattern.match_and_rewrite(op, rewriter)
  File "/workspaces/Master_Thesis_Code/.venv/lib/python3.10/site-packages/xdsl/pattern_rewriter.py", line 433, in impl
    func(self, op, rewriter)
  File "/workspaces/Master_Thesis_Code/.venv/lib/python3.10/site-packages/xdsl/transforms/reconcile_unrealized_casts.py", line 110, in match_and_rewrite
    _try_remove_cast_chain(op, rewriter, self.warn_on_failure)
  File "/workspaces/Master_Thesis_Code/.venv/lib/python3.10/site-packages/xdsl/transforms/reconcile_unrealized_casts.py", line 71, in _try_remove_cast_chain
    assert len(cast.results) == len(op.inputs)
AssertionError

mlir-opt succeeds with:

module {
  func.func @reconcile_unrealized_casts(%arg0: f64, %arg1: f64) -> (f64, f64) {
    return %arg0, %arg1 : f64, f64
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant