This is an automated email from the ASF dual-hosted git repository.
junrushao pushed a commit to branch unity
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/unity by this push:
new e9aef6a479 [Unity] Add `has_function` to RelaxVM (#15674)
e9aef6a479 is described below
commit e9aef6a479e998374a26ee8bae81d5774122e146
Author: Hongyi Jin <[email protected]>
AuthorDate: Thu Sep 7 23:40:48 2023 -0700
[Unity] Add `has_function` to RelaxVM (#15674)
add a "has_function" function in executable
Co-authored-by: Junru Shao <[email protected]>
---
src/runtime/relax_vm/executable.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/runtime/relax_vm/executable.cc
b/src/runtime/relax_vm/executable.cc
index 0a77140469..f472a2974e 100644
--- a/src/runtime/relax_vm/executable.cc
+++ b/src/runtime/relax_vm/executable.cc
@@ -75,6 +75,10 @@ PackedFunc Executable::GetFunction(const String& name, const
ObjectPtr<Object>&
vm->LoadExecutable(GetObjectPtr<Executable>(this));
*rv = Module(vm);
});
+ } else if (name == "has_function") {
+ return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
+ *rv = static_cast<bool>(this->func_map.count(args[0]));
+ });
}
return nullptr;
}