This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow negative strides and offset in StridedLayoutAttr
ClosedPublic

Authored by Hardcode84 on Sep 18 2022, 2:50 PM.

Details

Summary

Negative strides are useful for creating reverse-view of array. We don't have specific example for negative offset yet but will add it for consistency.

Diff Detail

Event Timeline

Hardcode84 created this revision.Sep 18 2022, 2:50 PM
Herald added a project: Restricted Project. · View Herald Transcript
Hardcode84 requested review of this revision.Sep 18 2022, 2:50 PM
ezhulenev added inline comments.
mlir/lib/IR/BuiltinAttributes.cpp
275

If negative strides supported to represent reversed arrays, maybe zero strides should be also supported to represent broadcasted arrays?

bondhugula added inline comments.
mlir/lib/IR/BuiltinAttributes.cpp
275

There is a fundamental difference between the two and they shouldn't be equated. Negative strides still imply a one-to-one function. However, zero strides make the mapping many-to-one.

nicolasvasilache accepted this revision.Sep 19 2022, 3:32 AM

Thanks Ivan!

mlir/lib/IR/BuiltinAttributes.cpp
275

+1 to @bondhugula's comment, the indexing scheme is still expected to not have internal aliasing.

This revision is now accepted and ready to land.Sep 19 2022, 3:32 AM

use consumeIf, basic llvm lowering test