[all-commits] [llvm/llvm-project] febece: [mlir][memref] Reject empty collapse_shape and exp...
Wijkqwe via All-commits
all-commits at lists.llvm.org
Tue Sep 22 18:19:25 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: febece38855bf752ebc4b8cbce5d56adab78d1aa
https://github.com/llvm/llvm-project/commit/febece38855bf752ebc4b8cbce5d56adab78d1aa
Author: Wijkqwe <188143146+Wijkqwe at users.noreply.github.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
M mlir/test/Dialect/MemRef/invalid.mlir
Log Message:
-----------
[mlir][memref] Reject empty collapse_shape and expand_shape reassociation groups (#225348)
`memref.collapse_shape` and `memref.expand_shape` both accept an empty
reassociation group, which is not a valid reassociation: every group
must be a
non-empty, contiguous segment of dimensions.
* `memref.collapse_shape` with an empty group aborts the compiler for a
non-identity source layout. `CollapseShapeOp::verify` forwards the
reassociation to `computeCollapsedLayoutMap`, which calls
`ArrayRef::back()`
on each group and asserts on the empty one:
mlir-opt: llvm/include/llvm/ADT/ArrayRef.h:151:
const T& llvm::ArrayRef<T>::back() const [with T = long int]:
Assertion `!empty()' failed.
With an identity source layout the op is instead silently accepted.
* `memref.expand_shape` with an empty group is silently accepted: the
empty
group maps a source dimension to no result dimension, so a real
dimension is
dropped without any diagnostic.
The tensor reshape verifiers already reject this input
(https://github.com/llvm/llvm-project/pull/173791,
https://github.com/llvm/llvm-project/issues/222602 /
https://github.com/llvm/llvm-project/pull/222648).
Extract the empty-group check into a helper shared by both memref
verifiers,
mirroring https://github.com/llvm/llvm-project/pull/222648, and invoke
it from `ExpandShapeOp::verify` and
`CollapseShapeOp::verify`.
Add regression tests to `mlir/test/Dialect/MemRef/invalid.mlir`.
Assisted-by: AI.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list