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
6 changes: 5 additions & 1 deletion src/tir/usmp/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ Map<String, PoolAllocation> GetIOPoolAllocations(
}

static Integer CalculateExtentsSize(const DataType& dtype, const Array<PrimExpr>& extents) {
size_t element_size_bytes = dtype.bytes();
if (dtype.is_scalable_vector()) {
// We cannot statically calculate workspace for scalable types
return Integer();
}
size_t element_size_bytes = dtype.bytes() * dtype.lanes();
size_t num_elements = 1;
for (const auto& ext : extents) {
if (ext->IsInstance<IntImmNode>()) {
Expand Down
20 changes: 18 additions & 2 deletions tests/python/tir-analysis/test_tir_analysis_calculate_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ def primfunc_local_allocates(placeholder_162: T.handle, placeholder_163: T.handl
# fmt: on


@T.prim_func
def prim_func_decl_vector_type(a: T.handle, b: T.handle):
T.func_attr({"tir.noalias": True})
A = T.match_buffer(a, (4,), "float32x4")
B = T.match_buffer(b, (4,), "float32x4")
C = T.decl_buffer((4,), "float32x4")
for i in range(3):
with T.block("block"):
vi = T.axis.remap("S", [i])
B[vi] = A[vi] + C[vi]


@pytest.mark.parametrize("alignment,size,consts", [(1, 663552, 0), (10, 663560, 0)])
def test_global_allocates(alignment, size, consts):
primfunc = primfunc_global_allocates
Expand All @@ -105,6 +117,10 @@ def test_local_allocates(alignment, size, consts):
assert tvm.tir.analysis.calculate_workspace_bytes(primfunc, alignment) == size


def test_vector_type():
primfunc = prim_func_decl_vector_type
assert tvm.tir.analysis.calculate_workspace_bytes(primfunc, 1) == 64


if __name__ == "__main__":
test_global_allocates()
test_local_allocates()
tvm.testing.main()