diff --git a/examples/hello_world_add/src/main.rs b/examples/hello_world_add/src/main.rs index 1b4b2e3..8b2fb9d 100644 --- a/examples/hello_world_add/src/main.rs +++ b/examples/hello_world_add/src/main.rs @@ -6,28 +6,45 @@ use executorch::tensor::{Array, Tensor}; use ndarray::array; fn main() { + println!("{}:{:3.}", file!(), line!()); env_logger::Builder::new() .filter_level(log::LevelFilter::Debug) .init(); + println!("{}:{:3.}", file!(), line!()); executorch::platform::pal_init(); + println!("{}:{:3.}", file!(), line!()); let mut module = Module::new("model.pte", None); + println!("{}:{:3.}", file!(), line!()); let input_array1 = Array::new(array![1.0_f32]); + println!("{}:{:3.}", file!(), line!()); let input_tensor1 = input_array1.to_tensor_impl(); + println!("{}:{:3.}", file!(), line!()); let input_evalue1 = EValue::from_tensor(Tensor::new(&input_tensor1)); + println!("{}:{:3.}", file!(), line!()); let input_array2 = Array::new(array![1.0_f32]); + println!("{}:{:3.}", file!(), line!()); let input_tensor2 = input_array2.to_tensor_impl(); + println!("{}:{:3.}", file!(), line!()); let input_evalue2 = EValue::from_tensor(Tensor::new(&input_tensor2)); + println!("{}:{:3.}", file!(), line!()); let outputs = module.forward(&[input_evalue1, input_evalue2]).unwrap(); + println!("{}:{:3.}", file!(), line!()); assert_eq!(outputs.len(), 1); + println!("{}:{:3.}", file!(), line!()); let output = outputs.into_iter().next().unwrap(); + println!("{}:{:3.}", file!(), line!()); assert_eq!(output.tag(), Some(Tag::Tensor)); + println!("{}:{:3.}", file!(), line!()); let output = output.as_tensor(); + println!("{}:{:3.}", file!(), line!()); println!("Output tensor computed: {:?}", output); + println!("{}:{:3.}", file!(), line!()); assert_eq!(array![2.0_f32], output.as_array()); + println!("{}:{:3.}", file!(), line!()); } diff --git a/src/module.rs b/src/module.rs index 5c3900e..c4f6a06 100644 --- a/src/module.rs +++ b/src/module.rs @@ -164,16 +164,22 @@ impl Module { method_name: &str, inputs: &[EValue], ) -> Result>> { + println!("{}:{:3.}", file!(), line!()); let method_name = ArrayRef::from_slice(util::str2chars(method_name).unwrap()); + println!("{}:{:3.}", file!(), line!()); // Safety: The transmute is safe because the memory layout of EValue and et_c::EValue is the same. let inputs = unsafe { std::mem::transmute::<&[EValue], &[et_c::EValue]>(inputs) }; + println!("{}:{:3.}", file!(), line!()); let inputs = ArrayRef::from_slice(inputs); + println!("{}:{:3.}", file!(), line!()); let outputs = unsafe { et_rs_c::Module_execute(&mut self.0, method_name.0, inputs.0) }.rs()?; + println!("{}:{:3.}", file!(), line!()); // Safety: The transmute is safe because the memory layout of EValue and et_c::EValue is the same. let outputs = unsafe { std::mem::transmute::, et_rs_c::Vec>>(outputs) }; + println!("{}:{:3.}", file!(), line!()); Ok(outputs.rs().to_vec()) }