MLIR
17.0.0git
|
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/IR/BuiltinTypes.h"
#include "llvm/Support/Debug.h"
#include <optional>
Go to the source code of this file.
Namespaces | |
mlir | |
This header declares functions that assit transformations in the MemRef dialect. | |
Macros | |
#define | DEBUG_TYPE "memref-to-spirv-pattern" |
#define | ATOMIC_CASE(kind, spirvOp) |
Functions | |
static Value | getOffsetForBitwidth (Location loc, Value srcIdx, int sourceBits, int targetBits, OpBuilder &builder) |
Returns the offset of the value in targetBits representation. More... | |
static Value | adjustAccessChainForBitwidth (SPIRVTypeConverter &typeConverter, spirv::AccessChainOp op, int sourceBits, int targetBits, OpBuilder &builder) |
Returns an adjusted spirv::AccessChainOp. More... | |
static Value | shiftValue (Location loc, Value value, Value offset, Value mask, int targetBits, OpBuilder &builder) |
Returns the shifted targetBits -bit value with the given offset. More... | |
static bool | isAllocationSupported (Operation *allocOp, MemRefType type) |
Returns true if the allocations of memref type generated from allocOp can be lowered to SPIR-V. More... | |
static std::optional< spirv::Scope > | getAtomicOpScope (MemRefType type) |
Returns the scope to use for atomic operations use for emulating store operations of unsupported integer bitwidths, based on the memref type. More... | |
static Value | castIntNToBool (Location loc, Value srcInt, OpBuilder &builder) |
Casts the given srcInt into a boolean value. More... | |
static Value | castBoolToIntN (Location loc, Value srcBool, Type dstType, OpBuilder &builder) |
Casts the given srcBool into an integer of dstType . More... | |
void | mlir::populateMemRefToSPIRVPatterns (SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns) |
Appends to a pattern list additional patterns for translating MemRef ops to SPIR-V ops. More... | |
#define ATOMIC_CASE | ( | kind, | |
spirvOp | |||
) |
#define DEBUG_TYPE "memref-to-spirv-pattern" |
Definition at line 23 of file MemRefToSPIRV.cpp.
|
static |
Returns an adjusted spirv::AccessChainOp.
Based on the extension/capabilities, certain integer bitwidths sourceBits
might not be supported. During conversion if a memref of an unsupported type is used, load/stores to this memref need to be modified to use a supported higher bitwidth targetBits
and extracting the required bits. For an accessing a 1D array (spirv.array or spirv.rt_array), the last index is modified to load the bits needed. The extraction of the actual bits needed are handled separately. Note that this only works for a 1-D tensor.
Definition at line 64 of file MemRefToSPIRV.cpp.
|
static |
Casts the given srcBool
into an integer of dstType
.
Definition at line 144 of file MemRefToSPIRV.cpp.
References mlir::OpBuilder::create(), mlir::Value::getType(), getZero(), and mlir::Type::isInteger().
Casts the given srcInt
into a boolean value.
Definition at line 135 of file MemRefToSPIRV.cpp.
References mlir::OpBuilder::create(), mlir::Value::getType(), and mlir::Type::isInteger().
|
static |
Returns the scope to use for atomic operations use for emulating store operations of unsupported integer bitwidths, based on the memref type.
Returns std::nullopt on failure.
Definition at line 121 of file MemRefToSPIRV.cpp.
|
static |
Returns the offset of the value in targetBits
representation.
srcIdx
is an index into a 1-D array with each element having sourceBits
. It's assumed to be non-negative.
When accessing an element in the array treating as having elements of targetBits
, multiple values are loaded in the same time. The method returns the offset where the srcIdx
locates in the value. For example, if sourceBits
equals to 8 and targetBits
equals to 32, the x-th element is located at (x % 4) * 8. Because there are four elements in one i32, and one element has 8 bits.
Definition at line 42 of file MemRefToSPIRV.cpp.
References mlir::OpBuilder::create(), mlir::Builder::getIntegerAttr(), and mlir::Builder::getIntegerType().
|
static |
Returns true if the allocations of memref type
generated from allocOp
can be lowered to SPIR-V.
Definition at line 94 of file MemRefToSPIRV.cpp.
References mlir::Type::isIntOrFloat().
|
static |
Returns the shifted targetBits
-bit value with the given offset.
Definition at line 84 of file MemRefToSPIRV.cpp.
References mlir::OpBuilder::create(), and mlir::Builder::getIntegerType().