Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,10 @@ def Vector_ScanOp :
// VectorStepOp
//===----------------------------------------------------------------------===//

def Vector_StepOp : Vector_Op<"step", [Pure]> {
def Vector_StepOp : Vector_Op<"step", [
Pure,
DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>
]> {
let summary = "A linear sequence of values from 0 to N";
let description = [{
A `step` operation produces an index vector, i.e. a 1-D vector of values of
Expand Down
17 changes: 17 additions & 0 deletions mlir/lib/Dialect/Vector/IR/VectorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7202,6 +7202,23 @@ Value mlir::vector::makeArithReduction(OpBuilder &b, Location loc,
return selectPassthru(b, mask, result, acc);
}

//===----------------------------------------------------------------------===//
// StepOp
//===----------------------------------------------------------------------===//

void StepOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRanges) {
auto resultType = cast<VectorType>(getType());
if (resultType.isScalable()) {
return;
}
unsigned bitwidth = ConstantIntRanges::getStorageBitwidth(resultType);
APInt zero(bitwidth, 0);
APInt high(bitwidth, resultType.getDimSize(0) - 1);
ConstantIntRanges result = {zero, high, zero, high};
setResultRanges(getResult(), result);
}

//===----------------------------------------------------------------------===//
// Vector Masking Utilities
//===----------------------------------------------------------------------===//
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Dialect/Vector/int-range-interface.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,11 @@ func.func @test_vector_extsi() -> vector<2xi32> {
%2 = test.reflect_bounds %1 : vector<2xi32>
func.return %2 : vector<2xi32>
}

// CHECK-LABEL: func @vector_step
// CHECK: test.reflect_bounds {smax = 7 : index, smin = 0 : index, umax = 7 : index, umin = 0 : index}
func.func @vector_step() -> vector<8xindex> {
%0 = vector.step : vector<8xindex>
%1 = test.reflect_bounds %0 : vector<8xindex>
func.return %1 : vector<8xindex>
}