diff options
| author | River Riddle <riverriddle@google.com> | 2019-12-07 10:35:01 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-07 10:35:41 -0800 |
| commit | d6ee6a031063cb99ca9828f1698a60536ffbb38a (patch) | |
| tree | b8b1b6ecf500d93818366914f56dc818054339f3 /mlir/lib/Transforms | |
| parent | 9d1a0c72b4ae54b97809966257bd1b9cb3140dfe (diff) | |
| download | bcm5719-llvm-d6ee6a031063cb99ca9828f1698a60536ffbb38a.tar.gz bcm5719-llvm-d6ee6a031063cb99ca9828f1698a60536ffbb38a.zip | |
Update the builder API to take ValueRange instead of ArrayRef<Value *>
This allows for users to provide operand_range and result_range in builder.create<> calls, instead of requiring an explicit copy into a separate data structure like SmallVector/std::vector.
PiperOrigin-RevId: 284360710
Diffstat (limited to 'mlir/lib/Transforms')
| -rw-r--r-- | mlir/lib/Transforms/Utils/LoopUtils.cpp | 5 | ||||
| -rw-r--r-- | mlir/lib/Transforms/Vectorize.cpp | 12 |
2 files changed, 7 insertions, 10 deletions
diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 7b38809ce49..f718d9a5637 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -73,9 +73,8 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, } unsigned step = forOp.getStep(); - - SmallVector<Value *, 4> lbOperands(forOp.getLowerBoundOperands()); - auto lb = b.create<AffineApplyOp>(forOp.getLoc(), lbMap, lbOperands); + auto lb = b.create<AffineApplyOp>(forOp.getLoc(), lbMap, + forOp.getLowerBoundOperands()); // For each upper bound expr, get the range. // Eg: affine.for %i = lb to min (ub1, ub2), diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index 16b43e3f136..036e53435ae 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -775,7 +775,7 @@ void VectorizationState::registerReplacement(Value *key, Value *value) { // Apply 'map' with 'mapOperands' returning resulting values in 'results'. static void computeMemoryOpIndices(Operation *op, AffineMap map, - ArrayRef<Value *> mapOperands, + ValueRange mapOperands, SmallVectorImpl<Value *> &results) { OpBuilder builder(op); for (auto resultExpr : map.getResults()) { @@ -822,15 +822,14 @@ static LogicalResult vectorizeRootOrTerminal(Value *iv, // as needed by various targets. if (auto load = dyn_cast<AffineLoadOp>(opInst)) { OpBuilder b(opInst); - SmallVector<Value *, 4> mapOperands(load.getMapOperands()); + ValueRange mapOperands = load.getMapOperands(); SmallVector<Value *, 8> indices; indices.reserve(load.getMemRefType().getRank()); if (load.getAffineMap() != b.getMultiDimIdentityMap(load.getMemRefType().getRank())) { computeMemoryOpIndices(opInst, load.getAffineMap(), mapOperands, indices); } else { - indices.append(load.getMapOperands().begin(), - load.getMapOperands().end()); + indices.append(mapOperands.begin(), mapOperands.end()); } auto permutationMap = makePermutationMap(opInst, indices, state->strategy->loopToVectorDim); @@ -1052,7 +1051,7 @@ static Operation *vectorizeOneOperation(Operation *opInst, auto *value = store.getValueToStore(); auto *vectorValue = vectorizeOperand(value, opInst, state); - SmallVector<Value *, 4> mapOperands(store.getMapOperands()); + ValueRange mapOperands = store.getMapOperands(); SmallVector<Value *, 8> indices; indices.reserve(store.getMemRefType().getRank()); if (store.getAffineMap() != @@ -1060,8 +1059,7 @@ static Operation *vectorizeOneOperation(Operation *opInst, computeMemoryOpIndices(opInst, store.getAffineMap(), mapOperands, indices); } else { - indices.append(store.getMapOperands().begin(), - store.getMapOperands().end()); + indices.append(mapOperands.begin(), mapOperands.end()); } auto permutationMap = |

