This is an archive of the discontinued LLVM Phabricator instance.

[mlir][memref] Introduce memref.offset and memref.stride ops
AbandonedPublic

Authored by Hardcode84 on Jul 31 2022, 9:26 AM.

Details

Summary

These ops allow to extract offset/strides from memref as ssa values.

This patch only introduces ops definiton with basic printing/parsing tests.
Additional folding and llvm lowering will be introduced in separate patches.

Diff Detail

Event Timeline

Hardcode84 created this revision.Jul 31 2022, 9:26 AM
Hardcode84 requested review of this revision.Jul 31 2022, 9:26 AM

fix linux build

mravishankar requested changes to this revision.Aug 3 2022, 11:09 AM
mravishankar added a subscriber: mravishankar.

I think this has been attempted before. I dont know what the context of that discussion is. So I will leave that for more expreienced folks to weigh in on. Have some comments on the patch though.

mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
759

THe naming is now confusing cause the same function is used to verify dim ops, stride ops and offset ops. I'd rather not templatize this and just copy the same logic into the individual operation verify methods.

1000

I think the stride op is valid if getStridesAndOffset method here returns success. Otherwise it might not be possible to actually compute this operation. Same is true for the offset op.

This revision now requires changes to proceed.Aug 3 2022, 11:09 AM
Hardcode84 updated this revision to Diff 450435.Aug 5 2022, 3:37 PM

getStridesAndOffset

Hardcode84 marked an inline comment as done.Aug 5 2022, 3:39 PM
Hardcode84 added inline comments.
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
759

This code is too big for copypase IMO. Tried to get better name

Hardcode84 updated this revision to Diff 450440.Aug 5 2022, 3:41 PM

fix test func name

chelini added inline comments.Aug 8 2022, 5:11 AM
mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
546

I would drop this line I don't think add much. Also here we have a single operand.

mravishankar resigned from this revision.Aug 8 2022, 8:15 PM

Dropping my self from reviewers list. This needs some one from core to approve.