@@ -95,10 +95,14 @@ def test_read_tensor_data_too_big_offset_throws(tmp_path: Path, mmap: bool) -> N
9595 file_size = path .stat ().st_size
9696 assert file_size == data .nbytes
9797
98- # offset + data_size > file_size
9998 with pytest .raises (RuntimeError ):
100- ov .read_tensor_data (path , element_type = ov .Type .f32 , shape = ov .PartialShape (list (shape )), offset_in_bytes = 1 , mmap = mmap )
101- # offset == file_size
99+ ov .read_tensor_data (
100+ path ,
101+ element_type = ov .Type .f32 ,
102+ shape = ov .PartialShape (list (shape )),
103+ offset_in_bytes = 1 ,
104+ mmap = mmap )
105+
102106 with pytest .raises (RuntimeError ):
103107 ov .read_tensor_data (
104108 path ,
@@ -107,7 +111,7 @@ def test_read_tensor_data_too_big_offset_throws(tmp_path: Path, mmap: bool) -> N
107111 offset_in_bytes = file_size ,
108112 mmap = mmap ,
109113 )
110- # offset > file_size
114+
111115 with pytest .raises (RuntimeError ):
112116 ov .read_tensor_data (
113117 path ,
@@ -118,6 +122,22 @@ def test_read_tensor_data_too_big_offset_throws(tmp_path: Path, mmap: bool) -> N
118122 )
119123
120124
125+ def test_read_tensor_data_default_all_args (tmp_path : Path ) -> None :
126+ """Test main use case: only path specified, all other args use defaults."""
127+ data = np .arange (24 , dtype = np .uint8 )
128+ path = tmp_path / "tensor.bin"
129+ data .tofile (path )
130+
131+ # Main use case - only specify path
132+ tensor = ov .read_tensor_data (path )
133+
134+ assert isinstance (tensor , ov .Tensor )
135+ assert tensor .get_element_type () == ov .Type .u8 # default element type
136+ assert tensor .get_shape () == [data .size ] # dynamic shape inferred from file
137+ assert not tensor .data .flags .writeable # read-only
138+ assert np .array_equal (tensor .data , data )
139+
140+
121141@pytest .mark .parametrize ("mmap" , [True , False ])
122142def test_read_tensor_data_dynamic_shape (tmp_path : Path , mmap : bool ) -> None :
123143 shape = (1 , 2 , 3 , 4 )
0 commit comments