This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] [docs] Fix misguided examples in memref.subview operation.
ClosedPublic

Authored by makesource on Nov 23 2021, 9:39 PM.

Details

Summary

The examples in memref.subview operation are misguided in that subview's strides operands mean "memref-rank number of strides that compose multiplicatively with the base memref strides in each dimension.".
So the below examples should be changed from Strides: [64, 4, 1] to Strides: [1, 1, 1]

Before changes

// Subview with constant offsets, sizes and strides.
%1 = memref.subview %0[0, 2, 0][4, 4, 4][64, 4, 1]
  : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to
    memref<4x4x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2 + 8)>

After changes

// Subview with constant offsets, sizes and strides.
%1 = memref.subview %0[0, 2, 0][4, 4, 4][1, 1, 1]
  : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to
    memref<4x4x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2 + 8)>

Also I fixed some syntax issues in docs related with memref layout map and added detailed explanation in subview rank reducing case.

Diff Detail

Event Timeline

makesource created this revision.Nov 23 2021, 9:39 PM
makesource requested review of this revision.Nov 23 2021, 9:39 PM
makesource set the repository for this revision to rG LLVM Github Monorepo.
herhut accepted this revision.Nov 24 2021, 4:16 AM

Thanks for the clarification.

mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
1410

Nit: can this be line wrapped?

This revision is now accepted and ready to land.Nov 24 2021, 4:16 AM

Address comments and minor fixes.

makesource marked an inline comment as done.Nov 24 2021, 7:50 AM
makesource closed this revision.Nov 25 2021, 3:58 AM
makesource reopened this revision.Nov 25 2021, 4:00 AM
This revision is now accepted and ready to land.Nov 25 2021, 4:00 AM