Skip to content

Commit ca23bd7

Browse files
bondhugulatensorflower-gardener
authored andcommitted
NFC - update doc, comments, vim syntax file
- for the symbol rules, the code was updated but the doc wasn't. Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#284 COPYBARA_INTEGRATE_REVIEW=tensorflow/mlir#284 from bondhugula:doc 9aad8b8a715559f7ce61265f3da3f8a3c11b45ea PiperOrigin-RevId: 284283712
1 parent fcc215e commit ca23bd7

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

mlir/g3doc/Dialects/Affine.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ function, a value defined at the top level of that function (outside of all
6666
loops and if operations), the result of a
6767
[`constant` operation](Standard.md#constant-operation), or the result of an
6868
[`affine.apply` operation](#affineapply-operation) that recursively takes as
69-
arguments any symbolic identifiers. Dimensions may be bound not only to anything
70-
that a symbol is bound to, but also to induction variables of enclosing
71-
[`affine.for` operations](#affinefor-operation), and the result of an
69+
arguments any symbolic identifiers, or the result of a [`dim`
70+
operation](Standard.md#dim-operation) on either a memref that is a function
71+
argument or a memref where the corresponding dimension is either static or a
72+
dynamic one in turn bound to a symbolic identifier. Dimensions may be bound not
73+
only to anything that a symbol is bound to, but also to induction variables of
74+
enclosing [`affine.for` operations](#affinefor-operation), and the result of an
7275
[`affine.apply` operation](#affineapply-operation) (which recursively may use
7376
other dimensions and symbols).
7477

mlir/include/mlir/Analysis/AffineStructures.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class FlatAffineConstraints {
655655
Optional<int64_t> getConstantUpperBound(unsigned pos) const;
656656

657657
/// Gets the lower and upper bound of the pos^th identifier treating
658-
/// [0, offset) U [offset + num, symbStartPos) as dimensions and
658+
/// [0, offset) U [offset + num, symStartPos) as dimensions and
659659
/// [symStartPos, getNumDimAndSymbolIds) as symbols. The returned
660660
/// multi-dimensional maps in the pair represent the max and min of
661661
/// potentially multiple affine expressions. The upper bound is exclusive.
@@ -664,7 +664,7 @@ class FlatAffineConstraints {
664664
std::pair<AffineMap, AffineMap>
665665
getLowerAndUpperBound(unsigned pos, unsigned offset, unsigned num,
666666
unsigned symStartPos, ArrayRef<AffineExpr> localExprs,
667-
MLIRContext *context);
667+
MLIRContext *context) const;
668668

669669
/// Returns true if the set can be trivially detected as being
670670
/// hyper-rectangular on the specified contiguous set of identifiers.
@@ -788,11 +788,13 @@ class FlatAffineConstraints {
788788
AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims,
789789
unsigned numSymbols);
790790

791-
/// Flattens 'expr' into 'flattenedExpr'. Returns failure if 'expr' could not be
792-
/// flattened (i.e., semi-affine is not yet handled). 'cst' contains constraints
793-
/// that connect newly introduced local identifiers to existing dimensional and
794-
/// symbolic identifiers. See documentation for AffineExprFlattener on how
795-
/// mod's and div's are flattened.
791+
/// Flattens 'expr' into 'flattenedExpr', which contains the coefficients of the
792+
/// dimensions, symbols, and additional variables that represent floor divisions
793+
/// of dimensions, symbols, and in turn other floor divisions. Returns failure
794+
/// if 'expr' could not be flattened (i.e., semi-affine is not yet handled).
795+
/// 'cst' contains constraints that connect newly introduced local identifiers
796+
/// to existing dimensional and symbolic identifiers. See documentation for
797+
/// AffineExprFlattener on how mod's and div's are flattened.
796798
LogicalResult
797799
getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols,
798800
llvm::SmallVectorImpl<int64_t> *flattenedExpr,

mlir/include/mlir/IR/AffineExpr.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,8 @@ AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims,
267267

268268
/// Flattens 'expr' into 'flattenedExpr'. Returns true on success or false
269269
/// if 'expr' could not be flattened (i.e., semi-affine is not yet handled).
270-
/// 'cst' contains constraints that connect newly introduced local identifiers
271-
/// to existing dimensional and / symbolic identifiers. See documentation for
272-
/// AffineExprFlattener on how mod's and div's are flattened.
270+
/// See documentation for AffineExprFlattener on how mod's and div's are
271+
/// flattened.
273272
bool getFlattenedAffineExpr(AffineExpr expr, unsigned numDims,
274273
unsigned numSymbols,
275274
llvm::SmallVectorImpl<int64_t> *flattenedExpr);

mlir/lib/Analysis/AffineStructures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ void FlatAffineConstraints::removeRedundantInequalities() {
15251525

15261526
std::pair<AffineMap, AffineMap> FlatAffineConstraints::getLowerAndUpperBound(
15271527
unsigned pos, unsigned offset, unsigned num, unsigned symStartPos,
1528-
ArrayRef<AffineExpr> localExprs, MLIRContext *context) {
1528+
ArrayRef<AffineExpr> localExprs, MLIRContext *context) const {
15291529
assert(pos + offset < getNumDimIds() && "invalid dim start pos");
15301530
assert(symStartPos >= (pos + offset) && "invalid sym start pos");
15311531
assert(getNumLocalIds() == localExprs.size() &&

mlir/lib/Dialect/AffineOps/AffineOps.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ static bool isDimOpValidSymbol(DimOp dimOp) {
173173

174174
// Value can be used as a symbol if it is a constant, or it is defined at
175175
// the top level, or it is a result of affine apply operation with symbol
176-
// arguments.
176+
// arguments, or a result of the dim op on a memref satisfying certain
177+
// constraints.
177178
bool mlir::isValidSymbol(Value *value) {
178179
// The value must be an index type.
179180
if (!value->getType().isIndex())
@@ -747,6 +748,8 @@ template <typename AffineOpTy>
747748
struct SimplifyAffineOp : public OpRewritePattern<AffineOpTy> {
748749
using OpRewritePattern<AffineOpTy>::OpRewritePattern;
749750

751+
/// Replace the affine op with another instance of it with the supplied
752+
/// map and mapOperands.
750753
void replaceAffineOp(PatternRewriter &rewriter, AffineOpTy affineOp,
751754
AffineMap map, ArrayRef<Value *> mapOperands) const;
752755

@@ -2039,5 +2042,9 @@ OpFoldResult AffineMinOp::fold(ArrayRef<Attribute> operands) {
20392042
return results[minIndex];
20402043
}
20412044

2045+
//===----------------------------------------------------------------------===//
2046+
// TableGen'd op method definitions
2047+
//===----------------------------------------------------------------------===//
2048+
20422049
#define GET_OP_CLASSES
20432050
#include "mlir/Dialect/AffineOps/AffineOps.cpp.inc"

mlir/utils/vim/syntax/mlir.vim

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ syn match mlirType /x\s*\zsvector/
3131
" Operations.
3232
" Core ops (not exhaustive yet).
3333
" TODO: the list is not exhaustive.
34-
syn keyword mlirOps alloc addf addi call call_indirect cmpi constant dealloc dma_start dma_wait dim extract_element for getTensor if load memref_cast mulf muli splat store select subf subi tensor_cast
34+
syn keyword mlirOps alloc alloca addf addi call call_indirect cmpi constant
35+
syn keyword mlirOps dealloc divf dma_start dma_wait dim extract_element
36+
syn keyword getTensor index_cast load memref_cast memref_shape_cast mulf muli
37+
syn keyword prefetch sitofp splat store select subf subi subview tensor_cast
38+
syn keyword view
3539

3640
" Affine ops.
3741
syn match mlirOps /\<affine\.apply\>/
@@ -41,13 +45,17 @@ syn match mlirOps /\<affine\.for\>/
4145
syn match mlirOps /\<affine\.if\>/
4246
syn match mlirOps /\<affine\.load\>/
4347
syn match mlirOps /\<affine\.store\>/
48+
syn match mlirOps /\<loop\.for\>/
49+
syn match mlirOps /\<loop\.if\>/
4450

4551
" TODO: dialect name prefixed ops (llvm or std).
4652

4753
" Keywords.
4854
syn keyword mlirKeyword
55+
\ dense
4956
\ else
5057
\ func
58+
\ module
5159
\ return
5260
\ step
5361
\ to

0 commit comments

Comments
 (0)