extern crate tvm_macros;
extern crate tvm_sys;
pub use tvm_macros::import_module;
pub use tvm_sys::call_packed;
use lazy_static::lazy_static;
mod allocator;
mod array;
pub mod errors;
mod graph;
mod module;
mod threading;
mod workspace;
pub use tvm_sys::{
errors::*,
ffi::{self, DLTensor},
packed_func::{self, *},
ArgValue, RetValue,
};
pub use self::{array::*, errors::*, graph::*, module::*, threading::*, workspace::*};
lazy_static! {
static ref LAST_ERROR: std::sync::RwLock<Option<&'static std::ffi::CStr>> =
std::sync::RwLock::new(None);
}
#[no_mangle]
pub unsafe extern "C" fn TVMAPISetLastError(cmsg: *const i8) {
*LAST_ERROR.write().unwrap() = Some(std::ffi::CStr::from_ptr(cmsg));
}
#[no_mangle]
pub extern "C" fn TVMGetLastError() -> *const std::os::raw::c_char {
match *LAST_ERROR.read().unwrap() {
Some(err) => err.as_ptr(),
None => std::ptr::null(),
}
}