From: 韩朴宇 Date: Wed, 5 Aug 2020 02:32:26 +0000 (+0800) Subject: [Rust] fix #6205 (#6207) X-Git-Tag: upstream/0.7.0~309 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f03c8003687789b305075ece876be241db0944f0;p=platform%2Fupstream%2Ftvm.git [Rust] fix #6205 (#6207) --- diff --git a/rust/tvm-sys/src/byte_array.rs b/rust/tvm-sys/src/byte_array.rs index ea2feeb..0f02771 100644 --- a/rust/tvm-sys/src/byte_array.rs +++ b/rust/tvm-sys/src/byte_array.rs @@ -72,10 +72,9 @@ impl> From for ByteArray { } } -impl From for ArgValue<'static> { - fn from(val: ByteArray) -> ArgValue<'static> { - // TODO(@jroesch): brorowed ArgValue are not sound - ArgValue::Bytes(unsafe { std::mem::transmute(&val.array) }) +impl<'a> From<&'a ByteArray> for ArgValue<'a> { + fn from(val: &'a ByteArray) -> ArgValue<'a> { + ArgValue::Bytes(&val.array) } } diff --git a/rust/tvm-sys/src/packed_func.rs b/rust/tvm-sys/src/packed_func.rs index b1e2af9..3121deb 100644 --- a/rust/tvm-sys/src/packed_func.rs +++ b/rust/tvm-sys/src/packed_func.rs @@ -161,7 +161,7 @@ TVMPODValue! { }, match &self { Bytes(val) => { - (TVMValue { v_handle: val as *const _ as *mut c_void }, TVMArgTypeCode_kTVMBytes) + (TVMValue { v_handle: *val as *const _ as *mut c_void }, TVMArgTypeCode_kTVMBytes) } Str(val) => { (TVMValue { v_handle: val.as_ptr() as *mut c_void }, TVMArgTypeCode_kTVMStr) } } diff --git a/rust/tvm/examples/resnet/src/main.rs b/rust/tvm/examples/resnet/src/main.rs index c81087d..16ca8c7 100644 --- a/rust/tvm/examples/resnet/src/main.rs +++ b/rust/tvm/examples/resnet/src/main.rs @@ -91,7 +91,7 @@ fn main() { fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/deploy_param.params")).unwrap(); let barr = ByteArray::from(¶ms); // load the parameters - load_param_fn.invoke(vec![barr.into()]).unwrap(); + load_param_fn.invoke(vec![(&barr).into()]).unwrap(); // get the set_input function let ref set_input_fn = graph_runtime_module .get_function("set_input", false)