## Features - Allow taking a block of tensor slice, as long as each dimension is contiguous (unit stride). - Fix some problems in `insert_slice_async`'s semantic. - More general verification for ops that return shared layout encoding. ## Known Limitations - `insert_slice_async` still uses the old semantic. May submit another PR later to support similar semantic like `tensor.extract_slice`. - No encoding verification for `tensor.extract_slice`. - 3d tensor ops are broken. - Strided accesses are not allowed. - May cause a little performance slowdown since we are passing strides as values but not constants (e.g., int). It would be difficult to pass strides as attributes when we have control flows. A block argument is possible to accept tensors with different strides.
67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
#include "triton/Analysis/Alias.h"
|
|
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
|
#include "triton/Analysis/Utility.h"
|
|
#include "triton/Dialect/TritonGPU/IR/Dialect.h"
|
|
|
|
namespace mlir {
|
|
|
|
AliasInfo AliasInfo::join(const AliasInfo &lhs, const AliasInfo &rhs) {
|
|
if (lhs == rhs)
|
|
return lhs;
|
|
AliasInfo ret;
|
|
for (auto value : lhs.allocs) {
|
|
ret.insert(value);
|
|
}
|
|
for (auto value : rhs.allocs) {
|
|
ret.insert(value);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
ChangeResult SharedMemoryAliasAnalysis::visitOperation(
|
|
Operation *op, ArrayRef<LatticeElement<AliasInfo> *> operands) {
|
|
AliasInfo aliasInfo;
|
|
bool pessimistic = true;
|
|
if (maybeSharedAllocationOp(op)) {
|
|
// These ops may allocate a new shared memory buffer.
|
|
auto result = op->getResult(0);
|
|
// FIXME(Keren): extract and insert are always alias for now
|
|
if (auto extractSliceOp = dyn_cast<tensor::ExtractSliceOp>(op)) {
|
|
// extract_slice %src
|
|
aliasInfo = AliasInfo(operands[0]->getValue());
|
|
pessimistic = false;
|
|
} else if (auto insertSliceOp =
|
|
dyn_cast<triton::gpu::InsertSliceAsyncOp>(op)) {
|
|
// insert_slice_async %src, %dst, %index
|
|
aliasInfo = AliasInfo(operands[1]->getValue());
|
|
pessimistic = false;
|
|
} else if (isSharedEncoding(result)) {
|
|
aliasInfo.insert(result);
|
|
pessimistic = false;
|
|
}
|
|
}
|
|
|
|
if (pessimistic) {
|
|
return markAllPessimisticFixpoint(op->getResults());
|
|
}
|
|
// Join all latice elements
|
|
ChangeResult result = ChangeResult::NoChange;
|
|
for (Value value : op->getResults()) {
|
|
result |= getLatticeElement(value).join(aliasInfo);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
AliasResult SharedMemoryAliasAnalysis::alias(Value lhs, Value rhs) {
|
|
// TODO: implement
|
|
return AliasResult::MayAlias;
|
|
}
|
|
|
|
ModRefResult SharedMemoryAliasAnalysis::getModRef(Operation *op,
|
|
Value location) {
|
|
// TODO: implement
|
|
return ModRefResult::getModAndRef();
|
|
}
|
|
|
|
} // namespace mlir
|