This is an automated email from the ASF dual-hosted git repository. jroesch pushed a commit to branch rust-tvm in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
commit caa6904a4d070abf1f957a51c23ba7d553e364be Author: Jared Roesch <jroe...@octoml.ai> AuthorDate: Mon Jun 8 14:01:09 2020 -0700 All tests pass --- rust/tvm-rt/Cargo.toml | 3 +++ rust/tvm-rt/src/function.rs | 6 +++--- rust/tvm-rt/src/lib.rs | 6 +++--- rust/tvm-rt/src/ndarray.rs | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/rust/tvm-rt/Cargo.toml b/rust/tvm-rt/Cargo.toml index b234da1..00e225f 100644 --- a/rust/tvm-rt/Cargo.toml +++ b/rust/tvm-rt/Cargo.toml @@ -39,5 +39,8 @@ paste = "0.1" mashup = "0.1" once_cell = "^1.3.1" +[dev-dependencies] +anyhow = "^1.0" + [features] blas = ["ndarray/blas"] diff --git a/rust/tvm-rt/src/function.rs b/rust/tvm-rt/src/function.rs index cca918a..ef659b7 100644 --- a/rust/tvm-rt/src/function.rs +++ b/rust/tvm-rt/src/function.rs @@ -251,8 +251,7 @@ impl<'a> TryFrom<&ArgValue<'a>> for Function { /// /// ``` /// # use tvm_rt::{ArgValue, RetValue}; -/// # use tvm_rt::function::{Function, register}; -/// # use anyhow::{Result}; +/// # use tvm_rt::function::{Function, Result, register}; /// /// fn sum(x: i64, y: i64, z: i64) -> i64 { /// x + y + z @@ -317,6 +316,7 @@ mod tests { #[test] fn register_and_call_closure0() { use crate::function; + use function::Result; fn constfn() -> i64 { return 10; @@ -324,7 +324,7 @@ mod tests { function::register_override(constfn, "constfn".to_owned(), true).unwrap(); let func = Function::get("constfn").unwrap(); - let func = func.to_boxed_fn::<dyn Fn() -> Result<i32, Error>>(); + let func = func.to_boxed_fn::<dyn Fn() -> Result<i32>>(); let ret = func().unwrap(); assert_eq!(ret, 10); } diff --git a/rust/tvm-rt/src/lib.rs b/rust/tvm-rt/src/lib.rs index 70a8efd..e21b5b7 100644 --- a/rust/tvm-rt/src/lib.rs +++ b/rust/tvm-rt/src/lib.rs @@ -115,8 +115,8 @@ mod tests { #[test] fn set_error() { - let err = errors::EmptyArrayError; - set_last_error(&err.into()); - assert_eq!(get_last_error().trim(), errors::EmptyArrayError.to_string()); + let err = errors::NDArrayError::EmptyArray; + set_last_error(&err); + assert_eq!(get_last_error().trim(), errors::NDArrayError::EmptyArray.to_string()); } } diff --git a/rust/tvm-rt/src/ndarray.rs b/rust/tvm-rt/src/ndarray.rs index 9a17502..6e1dcbf 100644 --- a/rust/tvm-rt/src/ndarray.rs +++ b/rust/tvm-rt/src/ndarray.rs @@ -190,7 +190,7 @@ impl NDArray { /// assert_eq!(ndarray.to_vec::<i32>().unwrap(), data); /// ``` pub fn to_vec<T>(&self) -> Result<Vec<T>, NDArrayError> { - if self.shape().is_some() { + if !self.shape().is_some() { return Err(NDArrayError::EmptyArray); } let earr = NDArray::empty( @@ -308,7 +308,7 @@ macro_rules! impl_from_ndarray_rustndarray { type Error = NDArrayError; fn try_from(nd: &NDArray) -> Result<ArrayD<$type>, Self::Error> { - if nd.shape().is_some() { + if !nd.shape().is_some() { return Err(NDArrayError::MissingShape); } assert_eq!(nd.dtype(), DataType::from_str($type_name)?, "Type mismatch"); @@ -323,7 +323,7 @@ macro_rules! impl_from_ndarray_rustndarray { type Error = NDArrayError; fn try_from(nd: &mut NDArray) -> Result<ArrayD<$type>, Self::Error> { - if nd.shape().is_some() { + if !nd.shape().is_some() { return Err(NDArrayError::MissingShape); }; assert_eq!(nd.dtype(), DataType::from_str($type_name)?, "Type mismatch");