MLIR 24.0.0git
XeGPUPropagateLayout.cpp File Reference
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/XeGPU/IR/XeGPU.h"
#include "mlir/Dialect/XeGPU/Transforms/Passes.h"
#include "mlir/Dialect/XeGPU/Transforms/XeGPULayoutImpl.h"
#include "mlir/Dialect/XeGPU/Utils/XeGPUUtils.h"
#include "mlir/Dialect/XeGPU/uArch/uArchCommon.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/RegionGraphTraits.h"
#include "mlir/IR/Value.h"
#include "mlir/IR/Visitors.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/LogicalResult.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "mlir/Dialect/XeGPU/Transforms/Passes.h.inc"

Go to the source code of this file.

Classes

class  mlir::xegpu::impl::XeGPUPropagateLayoutBase< DerivedT >

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::xegpu
namespace  mlir::xegpu::impl

Macros

#define GEN_PASS_DEF_XEGPUPROPAGATELAYOUT
#define DEBUG_TYPE   "xegpu-propagate-layout"
#define DBGS()

Typedefs

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

Functions

std::unique_ptr<::mlir::Pass > mlir::xegpu::impl::createXeGPUPropagateLayout ()
std::unique_ptr<::mlir::Pass > mlir::xegpu::impl::createXeGPUPropagateLayout (XeGPUPropagateLayoutOptions options)
std::unique_ptr<::mlir::Pass > mlir::xegpu::createXeGPUPropagateLayout ()
std::unique_ptr<::mlir::Pass > mlir::xegpu::createXeGPUPropagateLayout (XeGPUPropagateLayoutOptions options)
static LogicalResult forwardFillRegularOp (mlir::OpBuilder &builder, mlir::Operation *op, GetLayoutFnTy getLayoutOfValue)
 Update an operation with the layout of its results.
static void forwardInitsToRegionArgs (RegionBranchOpInterface regionOp, GetLayoutFnTy getLayoutOfValue)
 Give each init operand of a loop without a layout decided for it the layout of its init value: the region argument it feeds is bound to that value.
static LogicalResult forwardYieldOperandsToRegionResults (RegionBranchTerminatorOpInterface terminator, GetLayoutFnTy getLayoutOfValue)
 Assign each region result the layout of the terminator operand forwarded to it.
static LogicalResult updateFunctionOpInterface (mlir::OpBuilder &builder, mlir::FunctionOpInterface funcOp, GetLayoutFnTy getLayoutOfValue)
static LogicalResult forwardFillUnassignedLayouts (OpBuilder &builder, Operation *target, GetLayoutFnTy getLayoutOfValue)
 Fill the layouts the backward scan leaves to the forward pass, in program order: the results of an op from its operand layouts, the region results from the terminator operands forwarded to them, and the function signatures.

Macro Definition Documentation

◆ DBGS

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

Definition at line 55 of file XeGPUPropagateLayout.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "xegpu-propagate-layout"

Definition at line 54 of file XeGPUPropagateLayout.cpp.

◆ GEN_PASS_DEF_XEGPUPROPAGATELAYOUT

#define GEN_PASS_DEF_XEGPUPROPAGATELAYOUT

Definition at line 49 of file XeGPUPropagateLayout.cpp.

Typedef Documentation

◆ GetLayoutFnTy

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

Definition at line 1728 of file XeGPUPropagateLayout.cpp.

Function Documentation

◆ forwardFillRegularOp()

LogicalResult forwardFillRegularOp ( mlir::OpBuilder & builder,
mlir::Operation * op,
GetLayoutFnTy getLayoutOfValue )
static

Update an operation with the layout of its results.

For a vector result a temporary layout attribute is added to the op; for a tensor descriptor result the layout is written into its type.

If the global propagation left a result without a layout, forward-fill it locally from the operand layouts.

Definition at line 1736 of file XeGPUPropagateLayout.cpp.

References mlir::Operation::emitWarning(), mlir::xegpu::getDistributeLayoutAttr(), mlir::Operation::getNumOperands(), mlir::Operation::getOperands(), mlir::Operation::getResults(), mlir::xegpu::inferResultLayoutFromSourceForNonAnchorOp(), mlir::xegpu::isLayoutCarrierType(), result, mlir::xegpu::setDistributeLayoutAttr(), mlir::xegpu::setTensorDescLayout(), and success().

Referenced by forwardFillUnassignedLayouts().

◆ forwardFillUnassignedLayouts()

LogicalResult forwardFillUnassignedLayouts ( OpBuilder & builder,
Operation * target,
GetLayoutFnTy getLayoutOfValue )
static

Fill the layouts the backward scan leaves to the forward pass, in program order: the results of an op from its operand layouts, the region results from the terminator operands forwarded to them, and the function signatures.

Definition at line 2031 of file XeGPUPropagateLayout.cpp.

References mlir::WalkResult::advance(), mlir::Operation::emitError(), forwardFillRegularOp(), forwardInitsToRegionArgs(), forwardYieldOperandsToRegionResults(), mlir::WalkResult::interrupt(), mlir::PreOrder, success(), target, updateFunctionOpInterface(), and mlir::WalkResult::wasInterrupted().

Referenced by mlir::xegpu::propagateLayouts().

◆ forwardInitsToRegionArgs()

void forwardInitsToRegionArgs ( RegionBranchOpInterface regionOp,
GetLayoutFnTy getLayoutOfValue )
static

Give each init operand of a loop without a layout decided for it the layout of its init value: the region argument it feeds is bound to that value.

Definition at line 1943 of file XeGPUPropagateLayout.cpp.

References mlir::xegpu::getTemporaryLayout(), and mlir::xegpu::setTemporaryLayout().

Referenced by forwardFillUnassignedLayouts().

◆ forwardYieldOperandsToRegionResults()

LogicalResult forwardYieldOperandsToRegionResults ( RegionBranchTerminatorOpInterface terminator,
GetLayoutFnTy getLayoutOfValue )
static

Assign each region result the layout of the terminator operand forwarded to it.

Fails if a forwarded vector operand has no layout.

Definition at line 1959 of file XeGPUPropagateLayout.cpp.

References mlir::xegpu::getTemporaryLayout(), result, mlir::xegpu::setDistributeLayoutAttr(), and success().

Referenced by forwardFillUnassignedLayouts().

◆ updateFunctionOpInterface()

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