From b1b0ddbb67d206de7dd2ea028a3e5eff8f6bdf49 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 28 Oct 2020 08:28:51 -0400 Subject: [PATCH] [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 --- .../mlir/Dialect/Linalg/Transforms/Transforms.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h index 566ae79..3069063 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(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 ts); /// The interchange vector to reorder the tiled loops. - SmallVector interchangeVector{}; + SmallVector interchangeVector = {}; + LinalgTilingOptions &setInterchange(ArrayRef 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 distribution = None; + LinalgTilingOptions & - setDistributionOptions(LinalgLoopDistributionOptions &distributionOptions) { - distribution = distributionOptions; + setDistributionOptions(LinalgLoopDistributionOptions distributionOptions) { + distribution = std::move(distributionOptions); return *this; } }; -- 2.7.4