[PATCH] D142445: [mlir][tensor|memref] Harden the checks on dim op
Quentin Colombet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 02:55:57 PST 2023
qcolombet created this revision.
qcolombet added reviewers: ftynse, springerm, nicolasvasilache, mehdi_amini.
qcolombet added a project: MLIR.
Herald added subscribers: hanchung, Moerafaat, zero9178, bzcheeseman, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle.
Herald added a reviewer: rriddle.
Herald added a reviewer: antiagainst.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a subscriber: stephenneuendorffer.
Prior to this patch it was possible to use the dim operation on a 0-D
memref/tensor.
Unless we want to change the semantic of a 0-D shape, this doesn't make
sense because, paraphrasing the dim op semantic, this is guaranteed to
produce something that is undefined. (The requested index is guaranteed
to be equal to or greater than the rank.)
Harden the type requirements for the dim op by disallowing 0-D shaped
types.
While here, also fix an issue with negative indices (or very large indices)
that would be wrongly considered in bound.
(Happy to do a separate patch if people truly want something independent here.)
This "fixes" llvm.org/PR60195 by rejecting dim op on 0-D shapes instead of
crashing during LLVM conversion.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142445
Files:
mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/include/mlir/IR/OpBase.td
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/test/Dialect/MemRef/invalid.mlir
mlir/test/Dialect/Tensor/bufferize.mlir
mlir/test/Dialect/Tensor/invalid.mlir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142445.491681.patch
Type: text/x-patch
Size: 8100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230124/8c421f29/attachment.bin>
More information about the llvm-commits
mailing list