MLIR  21.0.0git
Namespaces | Macros | Typedefs | Functions
XeGPUPropagateLayout.cpp File Reference
#include "mlir/Analysis/DataFlow/ConstantPropagationAnalysis.h"
#include "mlir/Analysis/DataFlow/DeadCodeAnalysis.h"
#include "mlir/Analysis/DataFlow/SparseAnalysis.h"
#include "mlir/Analysis/DataFlow/Utils.h"
#include "mlir/Analysis/DataFlowFramework.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/XeGPU/IR/XeGPU.h"
#include "mlir/Dialect/XeGPU/IR/XeGPUTargetInfo.h"
#include "mlir/Dialect/XeGPU/Transforms/Passes.h"
#include "mlir/Dialect/XeGPU/Utils/XeGPUUtils.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Value.h"
#include "mlir/IR/Visitors.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/InterleavedRange.h"
#include "llvm/Support/LogicalResult.h"
#include "llvm/Support/raw_ostream.h"
#include "mlir/Dialect/XeGPU/Transforms/Passes.h.inc"

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::xegpu
 

Macros

#define GEN_PASS_DEF_XEGPUPROPAGATELAYOUT
 
#define DEBUG_TYPE   "xegpu-propagate-layout"
 
#define DBGS()   (llvm::dbgs() << "[" DEBUG_TYPE "]: ")
 

Typedefs

using GetLayoutFnTy = function_ref< xegpu::LayoutAttr(Value)>
 

Functions

static LogicalResult updateOp (mlir::OpBuilder &builder, mlir::Operation *op, GetLayoutFnTy getLayoutOfValue)
 Update an operation with the layout of its results. More...
 
static LogicalResult updateControlFlowOps (mlir::OpBuilder &builder, mlir::RegionBranchTerminatorOpInterface terminator, GetLayoutFnTy getLayoutOfValue)
 Region ops like scf.for need special handling because they have blocks inside. More...
 
static LogicalResult updateFunctionOpInterface (mlir::OpBuilder &builder, mlir::FunctionOpInterface funcOp, GetLayoutFnTy getLayoutOfValue)
 Update the function arguments and results with the layouts. More...
 

Macro Definition Documentation

◆ DBGS

#define DBGS ( )    (llvm::dbgs() << "[" DEBUG_TYPE "]: ")

Definition at line 49 of file XeGPUPropagateLayout.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "xegpu-propagate-layout"

Definition at line 48 of file XeGPUPropagateLayout.cpp.

◆ GEN_PASS_DEF_XEGPUPROPAGATELAYOUT

#define GEN_PASS_DEF_XEGPUPROPAGATELAYOUT

Definition at line 43 of file XeGPUPropagateLayout.cpp.

Typedef Documentation

◆ GetLayoutFnTy

using GetLayoutFnTy = function_ref<xegpu::LayoutAttr(Value)>

Definition at line 687 of file XeGPUPropagateLayout.cpp.

Function Documentation

◆ updateControlFlowOps()

static LogicalResult updateControlFlowOps ( mlir::OpBuilder builder,
mlir::RegionBranchTerminatorOpInterface  terminator,
GetLayoutFnTy  getLayoutOfValue 
)
static

Region ops like scf.for need special handling because they have blocks inside.

If the blocks have tensor descriptor type as block arguments, thier types must be updated. Also region op can have results that may not have any users (e.g. A and B tiles). They are not assigned a layout by layout analysis because they have no users. However inside the region op corresponding block arguments for these results do have layouts. Therefore, in this case we still need to update the result types with the layout attribute. This function function updates the internal block arguments and the result types of the region op with the assigned layouts. clang-format off Example: scf.for ... iter_args(...) -> (out types) { ^bb0(block types): ... scf.yield ... : (yield types) } clang-format on In this example, at scf.yield, control-flow can transfer to two successor regions. One is the ^bb0 (for loop body) and the other is the scf.for op itself (yield the results). So we update both the block arguments of the successor region (i.e. block types) and the result types of the scf.for op (i.e. out types). Note that yield types are updated by respective producers inside bb0.

Definition at line 750 of file XeGPUPropagateLayout.cpp.

References DBGS, mlir::get(), and mlir::xegpu::setLayoutAttr().

◆ updateFunctionOpInterface()

static LogicalResult updateFunctionOpInterface ( mlir::OpBuilder builder,
mlir::FunctionOpInterface  funcOp,
GetLayoutFnTy  getLayoutOfValue 
)
static

Update the function arguments and results with the layouts.

Definition at line 811 of file XeGPUPropagateLayout.cpp.

References DBGS, and mlir::get().

◆ updateOp()

static LogicalResult updateOp ( mlir::OpBuilder builder,
mlir::Operation op,
GetLayoutFnTy  getLayoutOfValue 
)
static

Update an operation with the layout of its results.

If the result type is a vector type, a temporary layout attribute is added to the operation. If the result type is a tensor descriptor type, the type is updated with the layout attribute. The users of the result are also updated with the layout attribute.

Definition at line 693 of file XeGPUPropagateLayout.cpp.

References mlir::Operation::emitWarning(), mlir::get(), mlir::Operation::getResults(), and mlir::xegpu::setLayoutAttr().