diff --git a/mlir/include/mlir/IR/StandardTypes.h b/mlir/include/mlir/IR/StandardTypes.h --- a/mlir/include/mlir/IR/StandardTypes.h +++ b/mlir/include/mlir/IR/StandardTypes.h @@ -658,6 +658,20 @@ /// `t` with simplified layout. MemRefType canonicalizeStridedLayout(MemRefType t); +/// Given MemRef `sizes` that are either static or dynamic, returns the +/// canonical "contiguous" strides AffineExpr. Strides are multiplicative and +/// once a dynamic dimension is encountered, all canonical strides become +/// dynamic and need to be encoded with a different symbol. +/// For canonical strides expressions, the offset is always 0 and and fastest +/// varying stride is always `1`. +/// +/// Examples: +/// - memref<3x4x5xf32> has canonical stride expression `20*d0 + 5*d1 + d2`. +/// - memref<3x?x5xf32> has canonical stride expression `s0*d0 + 5*d1 + d2`. +/// - memref<3x4x?xf32> has canonical stride expression `s1*d0 + s0*d1 + d2`. +AffineExpr makeCanonicalStridedLayoutExpr(ArrayRef sizes, + MLIRContext *context); + /// Return true if the layout for `t` is compatible with strided semantics. bool isStrided(MemRefType t); diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp --- a/mlir/lib/IR/StandardTypes.cpp +++ b/mlir/lib/IR/StandardTypes.cpp @@ -456,19 +456,8 @@ return success(); } -/// Given MemRef `sizes` that are either static or dynamic, returns the -/// canonical "contiguous" strides AffineExpr. Strides are multiplicative and -/// once a dynamic dimension is encountered, all canonical strides become -/// dynamic and need to be encoded with a different symbol. -/// For canonical strides expressions, the offset is always 0 and and fastest -/// varying stride is always `1`. -/// -/// Examples: -/// - memref<3x4x5xf32> has canonical stride expression `20*d0 + 5*d1 + d2`. -/// - memref<3x?x5xf32> has canonical stride expression `s0*d0 + 5*d1 + d2`. -/// - memref<3x4x?xf32> has canonical stride expression `s1*d0 + s0*d1 + d2`. -static AffineExpr makeCanonicalStridedLayoutExpr(ArrayRef sizes, - MLIRContext *context) { +AffineExpr mlir::makeCanonicalStridedLayoutExpr(ArrayRef sizes, + MLIRContext *context) { AffineExpr expr; bool dynamicPoisonBit = false; unsigned nSymbols = 0;