MLIR 24.0.0git
VectorDistribute.cpp File Reference
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/GPU/Utils/DistributionUtils.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/Vector/Transforms/VectorDistribution.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallVectorExtras.h"
#include "llvm/Support/FormatVariadic.h"
#include <utility>

Go to the source code of this file.

Functions

static AffineMap calculateImplicitMap (VectorType sequentialType, VectorType distributedType)
 Currently the distribution map is implicit based on the vector shape.
static int getDistributedDim (VectorType sequentialType, VectorType distributedType)
 Given a sequential and distributed vector type, returns the distributed dimension.
static Operation * cloneOpWithOperandsAndTypes (RewriterBase &rewriter, Location loc, Operation *op, ArrayRef< Value > operands, ArrayRef< Type > resultTypes)
static Value tryReuseArgBuffer (SmallVectorImpl< std::pair< Value, bool > > &buffers, Type targetType, Location loc, RewriterBase &rewriter)
 Reuse an args buffer from buffers to transit a value of targetType, or return null if none fits.
static bool isBlockInCFGLoop (Block *block)
 Return true if block is part of a CFG cycle, which LoopLikeOpInterface does not cover.
static bool isInCFGLoop (Block *block)
 Return true if block or any of its ancestor blocks is part of a CFG cycle, which LoopLikeOpInterface does not cover.
static bool canBeHoisted (Operation *op, function_ref< bool(Value)> definedOutside)
 Helper to know if an op can be hoisted out of the region.

Function Documentation

◆ calculateImplicitMap()

AffineMap calculateImplicitMap ( VectorType sequentialType,
VectorType distributedType )
static

Currently the distribution map is implicit based on the vector shape.

In the future it will be part of the op. Example:

%0 = gpu.warp_execute_on_lane_0(%arg0) -> (vector<1x16x2xf32>) {
...
}

Would have an implicit map of: (d0, d1, d2) -> (d0, d2)

Definition at line 45 of file VectorDistribute.cpp.

References mlir::AffineMap::get(), and mlir::getAffineDimExpr().

◆ canBeHoisted()

bool canBeHoisted ( Operation * op,
function_ref< bool(Value)> definedOutside )
static

Helper to know if an op can be hoisted out of the region.

Definition at line 2528 of file VectorDistribute.cpp.

References mlir::Operation::getNumRegions(), mlir::Operation::getOperands(), and mlir::isMemoryEffectFree().

Referenced by hoistSubsetAtIterArg().

◆ cloneOpWithOperandsAndTypes()

◆ getDistributedDim()

int getDistributedDim ( VectorType sequentialType,
VectorType distributedType )
static

Given a sequential and distributed vector type, returns the distributed dimension.

This function expects that only a single dimension is distributed.

Definition at line 64 of file VectorDistribute.cpp.

◆ isBlockInCFGLoop()

bool isBlockInCFGLoop ( Block * block)
static

Return true if block is part of a CFG cycle, which LoopLikeOpInterface does not cover.

Definition at line 258 of file VectorDistribute.cpp.

References mlir::Block::getSuccessors().

Referenced by isInCFGLoop().

◆ isInCFGLoop()

bool isInCFGLoop ( Block * block)
static

Return true if block or any of its ancestor blocks is part of a CFG cycle, which LoopLikeOpInterface does not cover.

Definition at line 276 of file VectorDistribute.cpp.

References mlir::Operation::getBlock(), mlir::Block::getParentOp(), and isBlockInCFGLoop().

◆ tryReuseArgBuffer()

Value tryReuseArgBuffer ( SmallVectorImpl< std::pair< Value, bool > > & buffers,
Type targetType,
Location loc,
RewriterBase & rewriter )
static

Reuse an args buffer from buffers to transit a value of targetType, or return null if none fits.

Definition at line 205 of file VectorDistribute.cpp.

References mlir::Builder::getIndexAttr(), and mlir::Value::getType().