! * \brief Get global function by name * \param name The function name * \return The global function. * \note This function will return std::nullopt if the function is not found. */
| 407 | * \note This function will return std::nullopt if the function is not found. |
| 408 | */ |
| 409 | static std::optional<Function> GetGlobal(std::string_view name) { |
| 410 | TVMFFIObjectHandle handle; |
| 411 | TVMFFIByteArray name_arr{name.data(), name.size()}; |
| 412 | TVM_FFI_CHECK_SAFE_CALL(TVMFFIFunctionGetGlobal(&name_arr, &handle)); |
| 413 | if (handle != nullptr) { |
| 414 | return Function( |
| 415 | details::ObjectUnsafe::ObjectPtrFromOwned<FunctionObj>(static_cast<Object*>(handle))); |
| 416 | } else { |
| 417 | return std::nullopt; |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | /*! |
| 422 | * \brief Get global function by name |
nothing calls this directly
no test coverage detected