tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [incubator-tvm] leonwanghui opened a new issue #5771: How to test wasm32 target on Rust runtime binding
Date Thu, 11 Jun 2020 03:27:42 GMT

leonwanghui opened a new issue #5771:

   Hi @tqchen @jroesch , I was working for embedding Rust runtime for WASM target, but came
across some problems when building test-wasm32 crate.
   ## Error elaboration
   Firstly I need to clarify that I can build and run the [test-wasm32](
package successfully, but what I wanted is to build the `lib` rather than `bin` type of package,
so I changed several lines in original `` and copy it to ``:
   extern "C" {
       static __tvm_module_ctx: i32;
   unsafe fn __get_tvm_module_ctx() -> i32 {
       // Refer a symbol in the libtest_wasm32.a to make sure that the link of the
       // library is not optimized out.
   extern crate ndarray;
   extern crate tvm_runtime;
   use ndarray::Array;
   use tvm_runtime::{DLTensor, Module as _, SystemLibModule};
   pub extern "C" fn run() {
       // try static
       let mut a = Array::from_vec(vec![1f32, 2., 3., 4.]);
       let mut b = Array::from_vec(vec![1f32, 0., 1., 0.]);
       let mut c = Array::from_vec(vec![0f32; 4]);
       let e = Array::from_vec(vec![2f32, 2., 4., 4.]);
       let mut a_dl: DLTensor = (&mut a).into();
       let mut b_dl: DLTensor = (&mut b).into();
       let mut c_dl: DLTensor = (&mut c).into();
       let syslib = SystemLibModule::default();
       let add = syslib
           .expect("main function not found");
       call_packed!(add, &mut a_dl, &mut b_dl, &mut c_dl).unwrap();
       assert!(c.all_close(&e, 1e-8f32));
   But when I tried to compile the library, some errors occurred:
   undefined symbol: __tvm_module_ctx
   I was guessing something required to modified when changing the type from `bin` to `lib`,
but I have no idea what to do about it because of missing the context, would be appreciated
it if anyone could take a look.

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message