You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by JC Li via Apache TVM Discuss <no...@discuss.tvm.ai> on 2020/11/09 06:08:46 UTC

[Apache TVM Discuss] [Questions] How to create PackedFunc manually?


I'm trying to create PackedFunc manually for my baremetal app. Following the way calling below macro:

example.c
```
#include<tvm/runtime/packed_func.h>
int A_wrapper(blahblah);
TVM_DLL_EXPORT_TYPED_FUNC(A, A_wrapper_);
```
Linking the program complains**:  undefined reference to `__dso_handle'.** **I wonder where does it call dso_handle in stdlib?**

The macro expands into:
```
#define TVM_DLL_EXPORT_TYPED_FUNC(ExportName, Function)                                     \
  extern "C" {                                                                              \
  TVM_DLL int ExportName(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, \
                         int* out_type_code) {                                              \
    try {                                                                                   \
      auto f = Function;                                                                    \
      using FType = ::tvm::runtime::detail::function_signature<decltype(f)>::FType;         \
      ::tvm::runtime::TVMRetValue rv;                                                       \
      ::tvm::runtime::detail::unpack_call_by_signature<FType>::run(                         \
          f, ::tvm::runtime::TVMArgs(args, type_code, num_args), &rv);                      \
      rv.MoveToCHost(out_value, out_type_code);                                             \
      return 0;                                                                             \
    } catch (const ::std::runtime_error& _except_) {                                        \
      TVMAPISetLastError(_except_.what());                                                  \
      return -1;                                                                            \
    }                                                                                       \
  }                                                                                         \
  }
```





---
[Visit Topic](https://discuss.tvm.apache.org/t/how-to-create-packedfunc-manually/8410/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/fc09c314631ebe905aa909f7901e36e6b7d3a4a4e35cd20bb119e9a32aed88c3).