@@ -4,14 +4,14 @@ use wasmedge_wasi_nn::{
44 self , ExecutionTarget , GraphBuilder , GraphEncoding , GraphExecutionContext , TensorType ,
55} ;
66
7- fn get_data_from_context ( context : & GraphExecutionContext , index : usize , limit : usize ) -> Vec < u8 > {
7+ fn get_data_from_context ( context : & GraphExecutionContext , index : usize ) -> Vec < u8 > {
88 const MAX_OUTPUT_BUFFER_SIZE : usize = 4096 * 4096 ;
99 let mut output_buffer = vec ! [ 0u8 ; MAX_OUTPUT_BUFFER_SIZE ] ;
10- let _ = context
10+ let bytes_written = context
1111 . get_output ( index, & mut output_buffer)
1212 . expect ( "Failed to get output" ) ;
1313
14- return output_buffer[ ..limit ] . to_vec ( ) ;
14+ return output_buffer[ ..bytes_written ] . to_vec ( ) ;
1515}
1616
1717fn main ( ) {
@@ -35,9 +35,7 @@ fn main() {
3535 . set_input ( 1 , TensorType :: U8 , & [ 1 ] , & config_data)
3636 . expect ( "Failed to set input" ) ;
3737 context. compute ( ) . expect ( "Failed to compute" ) ;
38- let bytes_written = get_data_from_context ( & context, 1 , 4 ) ;
39- let bytes_written = usize:: from_le_bytes ( bytes_written. as_slice ( ) . try_into ( ) . unwrap ( ) ) ;
40- let output_bytes = get_data_from_context ( & context, 0 , bytes_written) ;
38+ let output_bytes = get_data_from_context ( & context, 0 ) ;
4139 let spec = hound:: WavSpec {
4240 channels : 1 ,
4341 sample_rate : 24000 ,
0 commit comments