This is an archive of the discontinued LLVM Phabricator instance.

[mlir][MemRef] Deprecate unspecified trailing offset, size, and strides semantics of `OffsetSizeAndStridesOpInterface`.
ClosedPublic

Authored by mravishankar on Dec 13 2021, 2:15 PM.

Details

Summary

The semantics of the ops that implement the
OffsetSizeAndStrideOpInterface is that if the number of offsets,
sizes or strides are less than the rank of the source, then some
default values are filled along the trailing dimensions (0 for offset,
source dimension of sizes, and 1 for strides). This is confusing,
especially with rank-reducing semantics. Immediate issue here is that
the methods of OffsetSizeAndStridesOpInterface assumes that the
number of values is same as the source rank. This cause out-of-bounds
errors.

So simplifying the specification of OffsetSizeAndStridesOpInterface
to make it invalid to specify number of offsets/sizes/strides not
equal to the source rank.

Diff Detail

Event Timeline

mravishankar created this revision.Dec 13 2021, 2:15 PM
mravishankar requested review of this revision.Dec 13 2021, 2:15 PM
nicolasvasilache accepted this revision.Dec 13 2021, 2:17 PM

Thanks much!

I have similar lingering issues with tensor::ExtractSliceOp and/or tensor::InsertSliceOp.
If you have cycles to get to those too that would be super helpful!
If not no worries, I'll apply a similar fix tomorrow.

This revision is now accepted and ready to land.Dec 13 2021, 2:17 PM

Thanks much!

I have similar lingering issues with tensor::ExtractSliceOp and/or tensor::InsertSliceOp.
If you have cycles to get to those too that would be super helpful!
If not no worries, I'll apply a similar fix tomorrow.

I changed the interface itself. I'll look at the tensor.extract_slice and tensor.insert_slice as well. They should all be flagged as errors now anyway.

Remove similar convention from tensor.extract_slice and tensor.insert_slice.

Also retitle the patch and update patch description.

nicolasvasilache accepted this revision.Dec 13 2021, 2:40 PM

Fantastic, thanks Mahesh!

mravishankar retitled this revision from [mlir][MemRef] Deprecate unspecified trailing offset, size, and strides semantics of `memref.subview`. to [mlir][MemRef] Deprecate unspecified trailing offset, size, and strides semantics of `OffsetSizeAndStridesOpInterface`..Dec 13 2021, 3:43 PM
mravishankar edited the summary of this revision. (Show Details)

Rebase and fix more failures.
Also add a canonicalizer to fold no-op subviews.