From 190f385b7d194804d75f59ce01aa3a2b7b8d5e68 Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Wed, 16 Mar 2022 22:26:26 +0900 Subject: [PATCH] [mlir][linalg] Implement RegionBranchOpInterface and fix memory effects * Implement RegionBranchOpInterface: The op has a region, but it is conceptually not entered. The region just describes the semantics of the (monolithic) op. * Linalg structured ops do not allocate memory. Differential Revision: https://reviews.llvm.org/D121798 --- mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td | 9 +++++++++ mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td index d980036..25b8247 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -16,6 +16,7 @@ include "mlir/Dialect/Linalg/IR/LinalgBase.td" include "mlir/Dialect/Linalg/IR/LinalgInterfaces.td" +include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" @@ -28,6 +29,7 @@ class LinalgStructuredBase_Op props> SingleBlockImplicitTerminator<"YieldOp">, DeclareOpInterfaceMethods, LinalgStructuredInterface, + RegionBranchOpInterface, ReifyRankedShapedTypeOpInterface], props)> { code structuredOpsBaseDecls = [{ // Return whether the op accesses the iteration indices. @@ -40,6 +42,13 @@ class LinalgStructuredBase_Op props> return llvm::cast(getOperation()).reifyResultShapes(b, reifiedReturnShapes); } + + void getSuccessorRegions( + Optional index, ArrayRef operands, + SmallVectorImpl ®ions) { + // Op has a region, but conceptually the control flow does not enter the + // region. + } }]; } diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 2c9b1e0..34f264b 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -661,10 +661,6 @@ static void getGenericEffectsImpl( SmallVectorImpl> &effects, ValueRange results, ValueRange inputBuffers, ValueRange outputs) { - for (Value value : results) { - effects.emplace_back(MemoryEffects::Allocate::get(), value, - SideEffects::DefaultResource::get()); - } for (Value value : inputBuffers) { effects.emplace_back(MemoryEffects::Read::get(), value, SideEffects::DefaultResource::get()); -- 2.7.4