[Mlir-commits] [mlir] b1b0ddb - [mlir] NFC: small fixes to LinalgTilingOptions API

Lei Zhang llvmlistbot at llvm.org
Wed Oct 28 05:29:09 PDT 2020


Author: Lei Zhang
Date: 2020-10-28T08:28:58-04:00
New Revision: b1b0ddbb67d206de7dd2ea028a3e5eff8f6bdf49

URL: https://github.com/llvm/llvm-project/commit/b1b0ddbb67d206de7dd2ea028a3e5eff8f6bdf49
DIFF: https://github.com/llvm/llvm-project/commit/b1b0ddbb67d206de7dd2ea028a3e5eff8f6bdf49.diff

LOG: [mlir] NFC: small fixes to LinalgTilingOptions API

This commit changes to use plain values instead of references.
We need to copy it anyway. References forbid using temporary
values generated from expressions.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D90277

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 566ae79d2515a..30690636ac8cd 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -331,16 +331,19 @@ enum class LinalgTilingLoopType {
   AffineLoops = 1,
   ParallelLoops = 2,
 };
+
 using TileSizeComputationFunction =
     std::function<SmallVector<Value, 4>(OpBuilder &, Operation *)>;
+
 struct LinalgTilingOptions {
   /// Computation function that returns the tile sizes for each operation.
   /// Delayed construction of constant tile sizes should occur to interoperate
   /// with folding.
   TileSizeComputationFunction tileSizeComputationFunction = nullptr;
+
   LinalgTilingOptions &
-  setTileSizeComputationFunction(TileSizeComputationFunction &fun) {
-    tileSizeComputationFunction = fun;
+  setTileSizeComputationFunction(TileSizeComputationFunction fun) {
+    tileSizeComputationFunction = std::move(fun);
     return *this;
   }
   /// Set the `tileSizeComputationFunction` to return the values `ts`. The
@@ -356,13 +359,16 @@ struct LinalgTilingOptions {
   LinalgTilingOptions &setTileSizes(ArrayRef<int64_t> ts);
 
   /// The interchange vector to reorder the tiled loops.
-  SmallVector<unsigned, 4> interchangeVector{};
+  SmallVector<unsigned, 4> interchangeVector = {};
+
   LinalgTilingOptions &setInterchange(ArrayRef<unsigned> interchange) {
     interchangeVector.assign(interchange.begin(), interchange.end());
     return *this;
   }
+
   /// The type of tile loops to generate.
-  LinalgTilingLoopType loopType{LinalgTilingLoopType::Loops};
+  LinalgTilingLoopType loopType = LinalgTilingLoopType::Loops;
+
   LinalgTilingOptions &setLoopType(LinalgTilingLoopType lt) {
     loopType = lt;
     return *this;
@@ -371,9 +377,10 @@ struct LinalgTilingOptions {
   /// When specified, specifies distribution of generated tile loops to
   /// processors.
   Optional<LinalgLoopDistributionOptions> distribution = None;
+
   LinalgTilingOptions &
-  setDistributionOptions(LinalgLoopDistributionOptions &distributionOptions) {
-    distribution = distributionOptions;
+  setDistributionOptions(LinalgLoopDistributionOptions distributionOptions) {
+    distribution = std::move(distributionOptions);
     return *this;
   }
 };


        


More information about the Mlir-commits mailing list