MCPcopy Create free account
hub / github.com/apache/tvm-ffi / GetFunction

Method GetFunction

src/ffi/extra/library_module.cc:45–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 int GetPropertyMask() const final { return Module::kBinarySerializable | Module::kRunnable; };
44
45 Optional<ffi::Function> GetFunction(const String& name) final {
46 TVMFFISafeCallType faddr;
47 faddr = reinterpret_cast<TVMFFISafeCallType>(lib_->GetSymbolWithSymbolPrefix(name));
48 // ensure the function keeps the Library Module alive
49 Module self_strong_ref = GetRef<Module>(this);
50 if (faddr != nullptr) {
51 return ffi::Function::FromPacked([faddr, self_strong_ref](ffi::PackedArgs args,
52 ffi::Any* rv) {
53 TVM_FFI_ICHECK_LT(rv->type_index(), ffi::TypeIndex::kTVMFFIStaticObjectBegin);
54 TVM_FFI_CHECK_SAFE_CALL((*faddr)(nullptr, reinterpret_cast<const TVMFFIAny*>(args.data()),
55 args.size(), reinterpret_cast<TVMFFIAny*>(rv)));
56 });
57 }
58 return std::nullopt;
59 }
60
61 Optional<String> GetFunctionMetadata(const String& name) final {
62 // Look for __tvm_ffi__metadata_<name> symbol

Callers

nothing calls this directly

Calls 4

type_indexMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected