Skip to content

Commit e32e844

Browse files
committed
fix
1 parent 98cd8a7 commit e32e844

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/tirx/transform/primfunc_utils.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ transform::Pass AnnotateEntryFunc() {
3434
// If only a single function exists, that function must be the entry
3535
if (mod->functions.size() == 1) {
3636
auto [gvar, base_func] = *mod->functions.begin();
37-
if (!base_func->HasNonzeroAttr(tirx::attr::kIsEntryFunc)) {
38-
if (auto ptr = base_func.as<PrimFuncNode>()) {
39-
mod->Update(gvar, WithAttr(ffi::GetRef<PrimFunc>(ptr), tirx::attr::kIsEntryFunc, true));
37+
if (auto ptr = base_func.as<PrimFuncNode>()) {
38+
PrimFunc func = ffi::GetRef<PrimFunc>(ptr);
39+
if (!func->HasNonzeroAttr(tirx::attr::kIsEntryFunc)) {
40+
func = WithAttr(std::move(func), tirx::attr::kIsEntryFunc, true);
41+
}
42+
if (!func->GetAttr<ffi::String>(tvm::attr::kGlobalSymbol).has_value()) {
43+
func = WithAttr(std::move(func), tvm::attr::kGlobalSymbol, gvar->name_hint);
44+
}
45+
if (!func.same_as(base_func)) {
46+
mod->Update(gvar, func);
4047
}
4148
}
4249
return mod;

0 commit comments

Comments
 (0)