MLIR 24.0.0git
XeGPUTransformOps.cpp File Reference
#include "mlir/Dialect/XeGPU/TransformOps/XeGPUTransformOps.h"
#include "mlir/Analysis/SliceAnalysis.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/Transform/Utils/Utils.h"
#include "mlir/Dialect/XeGPU/IR/XeGPU.h"
#include "mlir/Dialect/XeGPU/Utils/XeGPUUtils.h"
#include "mlir/IR/Dominance.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "llvm/ADT/SmallVectorExtras.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.
static DiagnosedSilenceableFailure convertPackedValueToInt (transform::TransformState &state, TransformOpInterface transformOp, SmallVectorImpl< int32_t > &result, Value packedHandle)
 Convert a single packed handle, that is either a transform param associated with a variadic number of integer attributes or mapped to a variadic number of payload ops each defining a single constant index result, to a list of int values.
template<typename T>
static std::optional< T > findProducerOfType (Value val)
 It's assumed that producer ops are chained through their first operand.
static xegpu::LayoutAttr createLayoutAttr (MLIRContext *ctx, ArrayRef< int32_t > sgLayout, ArrayRef< int32_t > sgData, std::optional< ArrayRef< int32_t > > instData, ArrayRef< int32_t > order)
 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, Value packedSgLayout, Value packedSgData, Value packedInstData, ArrayRef< int32_t > order, xegpu::LayoutAttr &layoutAttr)
 Generate xegpu::LayoutAttr from op mixed layout values.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "xegpu-transforms"

Definition at line 24 of file XeGPUTransformOps.cpp.

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 727 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 32 of file XeGPUTransformOps.cpp.

References 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().

◆ convertPackedValueToInt()

DiagnosedSilenceableFailure convertPackedValueToInt ( transform::TransformState & state,
TransformOpInterface transformOp,
SmallVectorImpl< int32_t > & result,
Value packedHandle )
static

Convert a single packed handle, that is either a transform param associated with a variadic number of integer attributes or mapped to a variadic number of payload ops each defining a single constant index result, to a list of int values.

Definition at line 94 of file XeGPUTransformOps.cpp.

References mlir::transform::TransformState::getParams(), mlir::transform::TransformState::getPayloadOps(), mlir::Value::getType(), 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,
ArrayRef< int32_t > order )
static

Create a layout attribute from the given parameters.

Definition at line 171 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

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 135 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,
Value packedSgLayout,
Value packedSgData,
Value packedInstData,
ArrayRef< int32_t > order,
xegpu::LayoutAttr & layoutAttr )

Generate xegpu::LayoutAttr from op mixed layout values.

Definition at line 185 of file XeGPUTransformOps.cpp.

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