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
4 changes: 3 additions & 1 deletion src/te/operation/create_primfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ Stmt GenerateStmtFromCompute(const te::ComputeOp& compute_op, CreateFuncInfo* in
axes.insert(axes.end(), compute_op->reduce_axis.begin(), compute_op->reduce_axis.end());
Array<PrimExpr> bindings;
for (size_t i = 0; i < axes.size(); ++i) {
bindings.push_back(Var("i" + std::to_string(i)));
const IterVar& axis = axes[i];
int bits = std::max(axis->dom->min.dtype().bits(), axis->dom->extent.dtype().bits());
bindings.push_back(Var("i" + std::to_string(i), runtime::DataType::Int(bits)));
}
// Step 2. Generate block bodies.
Array<Stmt> seq_stmt;
Expand Down
18 changes: 15 additions & 3 deletions tests/python/unittest/test_te_create_primfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# specific language governing permissions and limitations
# under the License.
# pylint: disable=missing-function-docstring,missing-module-docstring
import tvm
from tvm.script import tir as T
from tvm import te, tir, topi
import numpy as np
import tvm
import tvm.testing
from tvm import te, tir, topi
from tvm.script import tir as T


def test_unique_name_complete_block():
Expand Down Expand Up @@ -473,6 +473,17 @@ def test_argmax_val_idx():
_check_workload(te_argmax_val_idx, tir_argmax_val_idx)


def test_int64_indices():
n = te.var("n", "int64")
A = te.placeholder((n,), name="A")
B = te.compute(A.shape, lambda *i: A(*i) + 1, name="B")
prim_func = te.create_prim_func([A, B])
loop = prim_func.body.block.body
assert loop.loop_var.dtype == "int64"
assert loop.min.dtype == "int64"
assert loop.extent.dtype == "int64"


if __name__ == "__main__":
test_unique_name_complete_block()
test_unique_name_reduction_block()
Expand All @@ -488,3 +499,4 @@ def test_argmax_val_idx():
test_tensor_attr()
test_argmax_idx_val()
test_argmax_val_idx()
test_int64_indices()