[mlir] NFC: small fixes to LinalgTilingOptions API
authorLei Zhang <antiagainst@google.com>
Wed, 28 Oct 2020 12:28:51 +0000 (08:28 -0400)
committerLei Zhang <antiagainst@google.com>
Wed, 28 Oct 2020 12:28:58 +0000 (08:28 -0400)
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

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

index 566ae79..3069063 100644 (file)
@@ -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;
   }
 };