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: 5 additions & 0 deletions src/relax/backend/vm/vm_shape_lower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@ class VMShapeLowerMutator
// the shape_func to indicate that this is a host function
// This could require us to attach target to the relax function here.
tir::PrimFunc shape_func(params, body, ret_type, buffer_map);
if (shape_func->attrs.GetAttr<tvm::Target>(tvm::attr::kTarget) == nullptr) {
// kTarget and kIsHostFunc are mutually exclusive
shape_func =
WithAttr<tir::PrimFunc>(std::move(shape_func), tvm::tir::attr::kIsHostFunc, Integer(1));
}
GlobalVar shape_func_var = builder_->AddFunction(shape_func, "shape_func");
builder_->Emit(Call(shape_func_var, {shape_heap_}), "_");
return to_compute.size();
Expand Down
1 change: 1 addition & 0 deletions tests/python/relax/test_backend_transform_shape_lower.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class Expected:
@T.prim_func
def shape_func(H: T.Buffer(T.int64(4), "int64")):
# generated compute function
T.func_attr({"tir.is_host_func": 1})
H[T.int64(sindex["k+1"])] = H[T.int64(sindex["k"])] + T.int64(1)

@R.function
Expand Down