diff options
| author | Uday Bondhugula <uday@polymagelabs.com> | 2019-12-06 16:16:32 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-06 16:17:06 -0800 |
| commit | ca23bd78d4bed96020f7e681a88c4c767fe594aa (patch) | |
| tree | 5e5aa03cf1d2a3cad336c582cc5f3998270fb01c | |
| parent | fcc215e39979b0f678de84b37a5e2ab208839a8c (diff) | |
| download | bcm5719-llvm-ca23bd78d4bed96020f7e681a88c4c767fe594aa.tar.gz bcm5719-llvm-ca23bd78d4bed96020f7e681a88c4c767fe594aa.zip | |
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=https://github.com/tensorflow/mlir/pull/284 from bondhugula:doc 9aad8b8a715559f7ce61265f3da3f8a3c11b45ea
PiperOrigin-RevId: 284283712
| -rw-r--r-- | mlir/g3doc/Dialects/Affine.md | 9 | ||||
| -rw-r--r-- | mlir/include/mlir/Analysis/AffineStructures.h | 16 | ||||
| -rw-r--r-- | mlir/include/mlir/IR/AffineExpr.h | 5 | ||||
| -rw-r--r-- | mlir/lib/Analysis/AffineStructures.cpp | 2 | ||||
| -rw-r--r-- | mlir/lib/Dialect/AffineOps/AffineOps.cpp | 9 | ||||
| -rw-r--r-- | mlir/utils/vim/syntax/mlir.vim | 10 |
6 files changed, 35 insertions, 16 deletions
diff --git a/mlir/g3doc/Dialects/Affine.md b/mlir/g3doc/Dialects/Affine.md index 60494570d0c..11cb93c10ea 100644 --- a/mlir/g3doc/Dialects/Affine.md +++ b/mlir/g3doc/Dialects/Affine.md @@ -66,9 +66,12 @@ function, a value defined at the top level of that function (outside of all loops and if operations), the result of a [`constant` operation](Standard.md#constant-operation), or the result of an [`affine.apply` operation](#affineapply-operation) that recursively takes as -arguments any symbolic identifiers. Dimensions may be bound not only to anything -that a symbol is bound to, but also to induction variables of enclosing -[`affine.for` operations](#affinefor-operation), and the result of an +arguments any symbolic identifiers, or the result of a [`dim` +operation](Standard.md#dim-operation) on either a memref that is a function +argument or a memref where the corresponding dimension is either static or a +dynamic one in turn bound to a symbolic identifier. Dimensions may be bound not +only to anything that a symbol is bound to, but also to induction variables of +enclosing [`affine.for` operations](#affinefor-operation), and the result of an [`affine.apply` operation](#affineapply-operation) (which recursively may use other dimensions and symbols). diff --git a/mlir/include/mlir/Analysis/AffineStructures.h b/mlir/include/mlir/Analysis/AffineStructures.h index ce49c842a40..143956e3b5c 100644 --- a/mlir/include/mlir/Analysis/AffineStructures.h +++ b/mlir/include/mlir/Analysis/AffineStructures.h @@ -655,7 +655,7 @@ public: Optional<int64_t> getConstantUpperBound(unsigned pos) const; /// Gets the lower and upper bound of the pos^th identifier treating - /// [0, offset) U [offset + num, symbStartPos) as dimensions and + /// [0, offset) U [offset + num, symStartPos) as dimensions and /// [symStartPos, getNumDimAndSymbolIds) as symbols. The returned /// multi-dimensional maps in the pair represent the max and min of /// potentially multiple affine expressions. The upper bound is exclusive. @@ -664,7 +664,7 @@ public: std::pair<AffineMap, AffineMap> getLowerAndUpperBound(unsigned pos, unsigned offset, unsigned num, unsigned symStartPos, ArrayRef<AffineExpr> localExprs, - MLIRContext *context); + MLIRContext *context) const; /// Returns true if the set can be trivially detected as being /// hyper-rectangular on the specified contiguous set of identifiers. @@ -788,11 +788,13 @@ private: AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols); -/// Flattens 'expr' into 'flattenedExpr'. Returns failure if 'expr' could not be -/// flattened (i.e., semi-affine is not yet handled). 'cst' contains constraints -/// that connect newly introduced local identifiers to existing dimensional and -/// symbolic identifiers. See documentation for AffineExprFlattener on how -/// mod's and div's are flattened. +/// Flattens 'expr' into 'flattenedExpr', which contains the coefficients of the +/// dimensions, symbols, and additional variables that represent floor divisions +/// of dimensions, symbols, and in turn other floor divisions. Returns failure +/// if 'expr' could not be flattened (i.e., semi-affine is not yet handled). +/// 'cst' contains constraints that connect newly introduced local identifiers +/// to existing dimensional and symbolic identifiers. See documentation for +/// AffineExprFlattener on how mod's and div's are flattened. LogicalResult getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, llvm::SmallVectorImpl<int64_t> *flattenedExpr, diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h index 2420deb5b7e..cca7eac536f 100644 --- a/mlir/include/mlir/IR/AffineExpr.h +++ b/mlir/include/mlir/IR/AffineExpr.h @@ -267,9 +267,8 @@ AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims, /// Flattens 'expr' into 'flattenedExpr'. Returns true on success or false /// if 'expr' could not be flattened (i.e., semi-affine is not yet handled). -/// 'cst' contains constraints that connect newly introduced local identifiers -/// to existing dimensional and / symbolic identifiers. See documentation for -/// AffineExprFlattener on how mod's and div's are flattened. +/// See documentation for AffineExprFlattener on how mod's and div's are +/// flattened. bool getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, llvm::SmallVectorImpl<int64_t> *flattenedExpr); diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index 80dc73755c7..e57045c639d 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -1525,7 +1525,7 @@ void FlatAffineConstraints::removeRedundantInequalities() { std::pair<AffineMap, AffineMap> FlatAffineConstraints::getLowerAndUpperBound( unsigned pos, unsigned offset, unsigned num, unsigned symStartPos, - ArrayRef<AffineExpr> localExprs, MLIRContext *context) { + ArrayRef<AffineExpr> localExprs, MLIRContext *context) const { assert(pos + offset < getNumDimIds() && "invalid dim start pos"); assert(symStartPos >= (pos + offset) && "invalid sym start pos"); assert(getNumLocalIds() == localExprs.size() && diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp index 2cd357fd541..7232c6eb28c 100644 --- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp +++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp @@ -173,7 +173,8 @@ static bool isDimOpValidSymbol(DimOp dimOp) { // Value can be used as a symbol if it is a constant, or it is defined at // the top level, or it is a result of affine apply operation with symbol -// arguments. +// arguments, or a result of the dim op on a memref satisfying certain +// constraints. bool mlir::isValidSymbol(Value *value) { // The value must be an index type. if (!value->getType().isIndex()) @@ -747,6 +748,8 @@ template <typename AffineOpTy> struct SimplifyAffineOp : public OpRewritePattern<AffineOpTy> { using OpRewritePattern<AffineOpTy>::OpRewritePattern; + /// Replace the affine op with another instance of it with the supplied + /// map and mapOperands. void replaceAffineOp(PatternRewriter &rewriter, AffineOpTy affineOp, AffineMap map, ArrayRef<Value *> mapOperands) const; @@ -2039,5 +2042,9 @@ OpFoldResult AffineMinOp::fold(ArrayRef<Attribute> operands) { return results[minIndex]; } +//===----------------------------------------------------------------------===// +// TableGen'd op method definitions +//===----------------------------------------------------------------------===// + #define GET_OP_CLASSES #include "mlir/Dialect/AffineOps/AffineOps.cpp.inc" diff --git a/mlir/utils/vim/syntax/mlir.vim b/mlir/utils/vim/syntax/mlir.vim index 5774d10e774..d9b6a3b29a1 100644 --- a/mlir/utils/vim/syntax/mlir.vim +++ b/mlir/utils/vim/syntax/mlir.vim @@ -31,7 +31,11 @@ syn match mlirType /x\s*\zsvector/ " Operations. " Core ops (not exhaustive yet). " TODO: the list is not exhaustive. -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 +syn keyword mlirOps alloc alloca addf addi call call_indirect cmpi constant +syn keyword mlirOps dealloc divf dma_start dma_wait dim extract_element +syn keyword getTensor index_cast load memref_cast memref_shape_cast mulf muli +syn keyword prefetch sitofp splat store select subf subi subview tensor_cast +syn keyword view " Affine ops. syn match mlirOps /\<affine\.apply\>/ @@ -41,13 +45,17 @@ syn match mlirOps /\<affine\.for\>/ syn match mlirOps /\<affine\.if\>/ syn match mlirOps /\<affine\.load\>/ syn match mlirOps /\<affine\.store\>/ +syn match mlirOps /\<loop\.for\>/ +syn match mlirOps /\<loop\.if\>/ " TODO: dialect name prefixed ops (llvm or std). " Keywords. syn keyword mlirKeyword + \ dense \ else \ func + \ module \ return \ step \ to |

