summaryrefslogtreecommitdiffstats
path: root/mlir/examples/Linalg/Linalg4/Example.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/examples/Linalg/Linalg4/Example.cpp')
-rw-r--r--mlir/examples/Linalg/Linalg4/Example.cpp40
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
OpenPOWER on IntegriCloud