diff options
author | River Riddle <riverriddle@google.com> | 2019-07-01 10:29:09 -0700 |
---|---|---|
committer | jpienaar <jpienaar@google.com> | 2019-07-01 11:39:00 -0700 |
commit | 54cd6a7e97a226738e2c85b86559918dd9e3cd5d (patch) | |
tree | affa803347d6695be575137d1ad55a055a8021e3 /mlir/examples/Linalg/Linalg4/Example.cpp | |
parent | 84bd67fc4fd116e80f7a66bfadfe9a7fd6fd5e82 (diff) | |
download | bcm5719-llvm-54cd6a7e97a226738e2c85b86559918dd9e3cd5d.tar.gz bcm5719-llvm-54cd6a7e97a226738e2c85b86559918dd9e3cd5d.zip |
NFC: Refactor Function to be value typed.
Move the data members out of Function and into a new impl storage class 'FunctionStorage'. This allows for Function to become value typed, which will greatly simplify the transition of Function to FuncOp(given that FuncOp is also value typed).
PiperOrigin-RevId: 255983022
Diffstat (limited to 'mlir/examples/Linalg/Linalg4/Example.cpp')
-rw-r--r-- | mlir/examples/Linalg/Linalg4/Example.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/mlir/examples/Linalg/Linalg4/Example.cpp b/mlir/examples/Linalg/Linalg4/Example.cpp index cdc05a1cc21..873e57e78f3 100644 --- a/mlir/examples/Linalg/Linalg4/Example.cpp +++ b/mlir/examples/Linalg/Linalg4/Example.cpp @@ -34,27 +34,27 @@ using namespace linalg; using namespace linalg::common; using namespace linalg::intrinsics; -Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { +Function makeFunctionWithAMatmulOp(Module &module, StringRef name) { MLIRContext *context = module.getContext(); auto dynamic2DMemRefType = floatMemRefType<2>(context); - mlir::Function *f = linalg::common::makeFunction( + mlir::Function f = linalg::common::makeFunction( module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off ValueHandle - M = dim(f->getArgument(0), 0), - N = dim(f->getArgument(2), 1), - K = dim(f->getArgument(0), 1), + M = dim(f.getArgument(0), 0), + N = dim(f.getArgument(2), 1), + K = dim(f.getArgument(0), 1), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), - vA = view(f->getArgument(0), {rM, rK}), - vB = view(f->getArgument(1), {rK, rN}), - vC = view(f->getArgument(2), {rM, rN}); + vA = view(f.getArgument(0), {rM, rK}), + vB = view(f.getArgument(1), {rK, rN}), + vC = view(f.getArgument(2), {rM, rN}); matmul(vA, vB, vC); ret(); // clang-format on @@ -65,11 +65,11 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { TEST_FUNC(matmul_tiled_loops) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_loops"); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_tiled_loops"); lowerToTiledLoops(f, {8, 9}); PassManager pm; pm.addPass(createLowerLinalgLoadStorePass()); - if (succeeded(pm.run(f->getModule()))) + if (succeeded(pm.run(f.getModule()))) cleanupAndPrintFunction(f); // clang-format off @@ -96,10 +96,10 @@ TEST_FUNC(matmul_tiled_loops) { TEST_FUNC(matmul_tiled_views) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views"); - OpBuilder b(f->getBody()); - lowerToTiledViews(f, {b.create<ConstantIndexOp>(f->getLoc(), 8), - b.create<ConstantIndexOp>(f->getLoc(), 9)}); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views"); + OpBuilder b(f.getBody()); + lowerToTiledViews(f, {b.create<ConstantIndexOp>(f.getLoc(), 8), + b.create<ConstantIndexOp>(f.getLoc(), 9)}); composeSliceOps(f); // clang-format off @@ -125,11 +125,11 @@ TEST_FUNC(matmul_tiled_views) { TEST_FUNC(matmul_tiled_views_as_loops) { MLIRContext context; Module module(&context); - mlir::Function *f = + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views_as_loops"); - OpBuilder b(f->getBody()); - lowerToTiledViews(f, {b.create<ConstantIndexOp>(f->getLoc(), 8), - b.create<ConstantIndexOp>(f->getLoc(), 9)}); + OpBuilder b(f.getBody()); + lowerToTiledViews(f, {b.create<ConstantIndexOp>(f.getLoc(), 8), + b.create<ConstantIndexOp>(f.getLoc(), 9)}); composeSliceOps(f); lowerToLoops(f); // This cannot lower below linalg.load and linalg.store due to lost |