Skip to content

Commit

Permalink
move inferResultRanges into ConvertToBufferOps.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Feb 5, 2025
1 parent 80e914f commit 961dc72
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 103 deletions.
11 changes: 3 additions & 8 deletions include/triton/Dialect/Triton/IR/TritonOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ include "mlir/Interfaces/SideEffectInterfaces.td" // Pure
include "mlir/Interfaces/ControlFlowInterfaces.td" // BranchOpInterface
include "mlir/Interfaces/InferTypeOpInterface.td" // SameOperandsAndResultType
include "mlir/Interfaces/CallInterfaces.td" // CallOpInterface
include "mlir/Interfaces/InferIntRangeInterface.td"
include "triton/Dialect/Triton/IR/TritonOpInterfaces.td"


Expand Down Expand Up @@ -418,8 +417,7 @@ def TT_AtomicCASOp : TT_Op<"atomic_cas", [MemoryEffects<[MemRead<GlobalMemory>]>
//
def TT_SplatOp : TT_Op<"splat", [Pure,
SameOperandsAndResultElementType,
SameOperandsAndResultEncoding,
DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>]> {
SameOperandsAndResultEncoding]> {
let summary = "splat";

let arguments = (ins TT_Type:$src);
Expand All @@ -433,7 +431,6 @@ def TT_SplatOp : TT_Op<"splat", [Pure,

def TT_ExpandDimsOp : TT_Op<"expand_dims", [Pure,
DeclareOpInterfaceMethods<InferTypeOpInterface>,
DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>,
SameOperandsAndResultElementType]> {
let summary = "expand_dims";

Expand Down Expand Up @@ -590,8 +587,7 @@ def TT_TransOp : TT_Op<"trans", [Pure,
//
// SPMD Ops
//
def TT_GetProgramIdOp : TT_Op<"get_program_id", [Pure,
DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>]> {
def TT_GetProgramIdOp : TT_Op<"get_program_id", [Pure]> {
let arguments = (ins TT_ProgramDim:$axis);

let results = (outs I32:$result);
Expand Down Expand Up @@ -806,8 +802,7 @@ def TT_ExternElementwiseOp : TT_Op<"extern_elementwise", [Elementwise,
//
// Make Range Op
//
def TT_MakeRangeOp : TT_Op<"make_range", [Pure,
DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>]> {
def TT_MakeRangeOp : TT_Op<"make_range", [Pure]> {
let summary = "make range";

let description = [{
Expand Down
24 changes: 0 additions & 24 deletions lib/Dialect/Triton/IR/Ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,6 @@ LogicalResult MakeRangeOp::verify() {
return success();
}

void MakeRangeOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRange) {
setResultRange(getResult(),
ConstantIntRanges::range({32, this->getStart(), true},
{32, this->getEnd(), true}, true));
}

//-- ReduceOp --
static LogicalResult
inferReduceReturnShape(RankedTensorType argTy, Type retEltTy, int axis,
Expand Down Expand Up @@ -574,11 +567,6 @@ OpFoldResult SplatOp::fold(FoldAdaptor adaptor) {
return ret;
}

void SplatOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRange) {
setResultRange(getResult(), argRanges[0]);
}

//-- ExpandDimsOp --
LogicalResult ExpandDimsOp::inferReturnTypes(
MLIRContext *context, std::optional<Location> loc, ValueRange operands,
Expand Down Expand Up @@ -609,11 +597,6 @@ LogicalResult ExpandDimsOp::inferReturnTypes(
return success();
}

void ExpandDimsOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRange) {
setResultRange(getResult(), argRanges[0]);
}

LogicalResult ExpandDimsOp::canonicalize(ExpandDimsOp op,
PatternRewriter &rewriter) {
auto definingOp = op.getSrc().getDefiningOp();
Expand Down Expand Up @@ -1261,12 +1244,5 @@ LogicalResult ExperimentalTensormapCreateOp::verify() {
return success();
}

// -- GetProgramIdOp --
void GetProgramIdOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRange) {
setResultRange(getResult(), ConstantIntRanges::range({32, 0, true},
{32, 2048, true}, true));
}

} // namespace triton
} // namespace mlir
Loading

0 comments on commit 961dc72

Please sign in to comment.