MLIR 22.0.0git
XeGPUTransformOps.cpp File Reference
#include "mlir/Dialect/XeGPU/TransformOps/XeGPUTransformOps.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Utils/Utils.h"
#include "mlir/Dialect/XeGPU/IR/XeGPU.h"
#include "mlir/Dialect/XeGPU/Utils/XeGPUUtils.h"
#include <optional>
#include "llvm/Support/DebugLog.h"
#include "mlir/Dialect/XeGPU/TransformOps/XeGPUTransformOps.cpp.inc"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "xegpu-transforms"
#define GET_OP_LIST
#define GET_OP_CLASSES

Functions

static DiagnosedSilenceableFailure convertMixedValuesToInt (transform::TransformState &state, TransformOpInterface transformOp, SmallVectorImpl< int32_t > &result, ArrayRef< OpFoldResult > ofrs)
 Assuming that ofr is an index attr or a param of index type or a transform dialect handle mapped to exactly one op with one index result, get that value and cast it to int type.
template<typename T>
static std::optional< T > findProducerOfType (Value val)
 Find producer operation of type T for the given value.
static xegpu::LayoutAttr createLayoutAttr (MLIRContext *ctx, ArrayRef< int32_t > sgLayout, ArrayRef< int32_t > sgData, std::optional< ArrayRef< int32_t > > instData)
 Create a layout attribute from the given parameters.
DiagnosedSilenceableFailure getLayoutAttrFromOperands (MLIRContext *ctx, transform::TransformState &state, TransformOpInterface transformOp, ArrayRef<::mlir::OpFoldResult > mixedSgLayout, ArrayRef<::mlir::OpFoldResult > mixedSgData, ArrayRef<::mlir::OpFoldResult > mixedInstData, xegpu::LayoutAttr &layoutAttr)
 Generate xegpu::LayoutAttr from op mixed layout values.
static xegpu::CreateNdDescOp setDescLayout (transform::TransformRewriter &rewriter, xegpu::CreateNdDescOp descOp, xegpu::DistributeLayoutAttr layout)
 Replace xegpu.create_nd_desc op with a new one with the given layout.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "xegpu-transforms"

Definition at line 19 of file XeGPUTransformOps.cpp.

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 689 of file XeGPUTransformOps.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Function Documentation

◆ convertMixedValuesToInt()

DiagnosedSilenceableFailure convertMixedValuesToInt ( transform::TransformState & state,
TransformOpInterface transformOp,
SmallVectorImpl< int32_t > & result,
ArrayRef< OpFoldResult > ofrs )
static

Assuming that ofr is an index attr or a param of index type or a transform dialect handle mapped to exactly one op with one index result, get that value and cast it to int type.

Definition at line 27 of file XeGPUTransformOps.cpp.

References diag(), mlir::Operation::getLoc(), mlir::Value::getLoc(), mlir::Operation::getNumResults(), mlir::transform::TransformState::getParams(), mlir::transform::TransformState::getPayloadOps(), mlir::Operation::getResult(), mlir::Value::getType(), mlir::Type::isIndex(), mlir::m_Constant(), mlir::matchPattern(), result, and mlir::DiagnosedSilenceableFailure::success().

Referenced by getLayoutAttrFromOperands().

◆ createLayoutAttr()

xegpu::LayoutAttr createLayoutAttr ( MLIRContext * ctx,
ArrayRef< int32_t > sgLayout,
ArrayRef< int32_t > sgData,
std::optional< ArrayRef< int32_t > > instData )
static

Create a layout attribute from the given parameters.

Definition at line 125 of file XeGPUTransformOps.cpp.

References mlir::detail::DenseArrayAttrImpl< int32_t >::get().

Referenced by getLayoutAttrFromOperands().

◆ findProducerOfType()

template<typename T>
std::optional< T > findProducerOfType ( Value val)
static

Find producer operation of type T for the given value.

It's assumed that producer ops are chained through their first operand. Producer chain is traced trough loop block arguments (init values).

Definition at line 88 of file XeGPUTransformOps.cpp.

References findProducerOfType(), mlir::Value::getDefiningOp(), mlir::Operation::getNumOperands(), mlir::Value::getNumUses(), mlir::Operation::getOperand(), and mlir::Value::getUsers().

Referenced by findProducerOfType().

◆ getLayoutAttrFromOperands()

DiagnosedSilenceableFailure getLayoutAttrFromOperands ( MLIRContext * ctx,
transform::TransformState & state,
TransformOpInterface transformOp,
ArrayRef<::mlir::OpFoldResult > mixedSgLayout,
ArrayRef<::mlir::OpFoldResult > mixedSgData,
ArrayRef<::mlir::OpFoldResult > mixedInstData,
xegpu::LayoutAttr & layoutAttr )

Generate xegpu::LayoutAttr from op mixed layout values.

Definition at line 139 of file XeGPUTransformOps.cpp.

References convertMixedValuesToInt(), createLayoutAttr(), and mlir::DiagnosedSilenceableFailure::success().

◆ setDescLayout()

xegpu::CreateNdDescOp setDescLayout ( transform::TransformRewriter & rewriter,
xegpu::CreateNdDescOp descOp,
xegpu::DistributeLayoutAttr layout )
static

Replace xegpu.create_nd_desc op with a new one with the given layout.

Definition at line 169 of file XeGPUTransformOps.cpp.

References mlir::RewriterBase::replaceOpWithNewOp(), and mlir::OpBuilder::setInsertionPointAfter().