File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 2
2
mod fixtures;
3
3
4
4
use fixtures:: alexnet:: Fixture ;
5
- use openvino:: Core ;
5
+ use openvino:: { Core , Shape , Tensor } ;
6
+
7
+ use std:: fs;
6
8
7
9
#[ test]
8
10
fn read_network ( ) {
@@ -18,3 +20,23 @@ fn read_network() {
18
20
assert_eq ! ( read_model. get_inputs_len( ) , Ok ( 1 ) ) ;
19
21
assert_eq ! ( read_model. get_outputs_len( ) , Ok ( 1 ) ) ;
20
22
}
23
+
24
+ #[ test]
25
+ fn read_network_from_buffers ( ) {
26
+ let mut core = Core :: new ( ) . unwrap ( ) ;
27
+ let graph = fs:: read ( & Fixture :: graph ( ) ) . unwrap ( ) ;
28
+ let weights = {
29
+ let weights = fs:: read ( & Fixture :: weights ( ) ) . unwrap ( ) ;
30
+ let shape = Shape :: new ( & [ 1 , weights. len ( ) as i64 ] ) . unwrap ( ) ;
31
+ let mut tensor = Tensor :: new ( openvino:: ElementType :: U8 , & shape) . unwrap ( ) ;
32
+ let buffer = tensor. get_raw_data_mut ( ) . unwrap ( ) ;
33
+ buffer. copy_from_slice ( & weights) ;
34
+ tensor
35
+ } ;
36
+
37
+ let read_model = core. read_model_from_buffer ( & graph, Some ( & weights) ) . unwrap ( ) ;
38
+
39
+ // Check the number of inputs and outputs.
40
+ assert_eq ! ( read_model. get_inputs_len( ) , Ok ( 1 ) ) ;
41
+ assert_eq ! ( read_model. get_outputs_len( ) , Ok ( 1 ) ) ;
42
+ }
You can’t perform that action at this time.
0 commit comments