Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tvm-graph-rt uses wrong type of BackendPackedCFunc #8534

Closed
ya0guang opened this issue Jul 23, 2021 · 0 comments
Closed

tvm-graph-rt uses wrong type of BackendPackedCFunc #8534

ya0guang opened this issue Jul 23, 2021 · 0 comments

Comments

@ya0guang
Copy link
Member

As some people and I mentioned in #6816, the currently TVM cannot support wasm32 target well using Rust APIs. It can run into this error: wasm trap: indirect call type mismatch.

This error originates in the incorrect extern function definition in rust/tvm-sys/src/lib.rs:

    pub type BackendPackedCFunc = extern "C" fn(
        args: *const TVMValue,
        type_codes: *const c_int,
        num_args: c_int,
        out_ret_value: *mut TVMValue,
        out_ret_tcode: *mut u32,
    ) -> c_int;

However, the correct definition in C is from include/tvm/runtime/c_backend_api.h:

/*!
 * \brief Signature for backend functions exported as DLL.
 *
 * \param args The arguments
 * \param type_codes The type codes of the arguments
 * \param num_args Number of arguments.
 * \param out_ret_value The output value of the the return value.
 * \param out_ret_tcode The output type code of the return value.
 * \param resource_handle Pointer to associated resource.
 *
 * \return 0 if success, -1 if failure happens, set error via TVMAPISetLastError.
 */
typedef int (*TVMBackendPackedCFunc)(TVMValue* args, int* type_codes, int num_args,
                                     TVMValue* out_ret_value, int* out_ret_tcode,
                                     void* resource_handle);

Here is an additional parameter, void* resource_handle. It seems people forgot to update the Rust interface. My previous issue(#8439) is also related to this error.

@mssun and @m4sterchain are also interested in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant