-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TRITON_ANALYSIS_MASKANALYSIS_H | ||
#define TRITON_ANALYSIS_MASKANALYSIS_H | ||
|
||
#include "mlir/Dialect/Arith/IR/Arith.h" | ||
#include "mlir/Dialect/MemRef/IR/MemRef.h" | ||
#include "mlir/Dialect/Tensor/IR/Tensor.h" | ||
|
||
#include "triton/Dialect/Triton/IR/Dialect.h" | ||
|
||
#include <utility> | ||
|
||
namespace mlir { | ||
|
||
class PatternRewriter; | ||
|
||
namespace triton { | ||
|
||
struct MultiBufferState { | ||
SmallVector<int64_t> values; | ||
int64_t scalar = 0; | ||
|
||
int64_t getShape() const { return values.size(); } | ||
|
||
bool hasValue() const { return !values.empty(); } | ||
|
||
bool hasScalar() const { return scalar != 0; } | ||
|
||
bool isEmpty() const { return !hasValue() && !scalar; } | ||
|
||
bool hasSameShape(MultiBufferState other) const { | ||
return hasValue() && other.hasValue() && getShape() == other.getShape(); | ||
} | ||
|
||
// Recursively parse a Value; call the coresponding function based on the | ||
// defining operation and Value type | ||
LogicalResult parse(Value operand, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
private: | ||
// ------- | ||
// Utility functions to operate on MultiBufferState | ||
// ------- | ||
LogicalResult addStates(const MultiBufferState &lhsState, | ||
const MultiBufferState &rhsState, Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult mulStates(const MultiBufferState &lhsState, | ||
const MultiBufferState &rhsState, Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult divStates(const MultiBufferState &lhsState, | ||
const MultiBufferState &rhsState, Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult remStates(const MultiBufferState &lhsState, | ||
const MultiBufferState &rhsState, Location loc, | ||
PatternRewriter &rewriter); | ||
// ------- | ||
// Helper functions to parse values to populate MultiBufferState | ||
// ------- | ||
|
||
LogicalResult parseConstant(arith::ConstantOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseAdd(arith::AddIOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseMul(arith::MulIOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseRem(arith::RemSIOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseDiv(arith::DivSIOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseMakeRange(triton::MakeRangeOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseSplat(triton::SplatOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseGetProgramId(triton::GetProgramIdOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseStore(triton::StoreOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
|
||
LogicalResult parseAddPtr(triton::AddPtrOp op, const Location loc, | ||
PatternRewriter &rewriter); | ||
}; | ||
|
||
} // namespace triton | ||
|
||
} // namespace mlir | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.