@@ -96,10 +96,54 @@ def test_pytorch_decoder_get_input_type_none():
96
96
assert isinstance (nc_decoder .get_input_type (2 ).value , DecoderType .PyNone )
97
97
98
98
99
+ @pytest .mark .precommit
100
+ def test_pytorch_decoder_can_convert_f8_e4m3_tensor ():
101
+ from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
102
+ from openvino import PartialShape , Type
103
+
104
+ class SomeTensor (torch .nn .Module ):
105
+ def forward (self ):
106
+ return torch .tensor ([1 , 2 ], dtype = torch .float8_e4m3fn )
107
+
108
+ model = get_scripted_model (SomeTensor ())
109
+ consts = [n for n in model .inlined_graph .nodes () if n .kind () ==
110
+ "prim::Constant" ]
111
+ assert len (consts ) > 0
112
+ some_const = consts [0 ]
113
+ nc_decoder = TorchScriptPythonDecoder (model , some_const )
114
+ ov_const = nc_decoder .as_constant ()
115
+ assert ov_const is not None
116
+ assert len (ov_const ) == 1
117
+ assert ov_const [0 ].get_element_type () == Type .f8e4m3
118
+ assert ov_const [0 ].get_partial_shape () == PartialShape ([2 ])
119
+
120
+
121
+ @pytest .mark .precommit
122
+ def test_pytorch_decoder_can_convert_f8_e5m2_tensor ():
123
+ from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
124
+ from openvino import PartialShape , Type
125
+
126
+ class SomeTensor (torch .nn .Module ):
127
+ def forward (self ):
128
+ return torch .tensor ([1 , 2 ], dtype = torch .float8_e5m2 )
129
+
130
+ model = get_scripted_model (SomeTensor ())
131
+ consts = [n for n in model .inlined_graph .nodes () if n .kind () ==
132
+ "prim::Constant" ]
133
+ assert len (consts ) > 0
134
+ some_const = consts [0 ]
135
+ nc_decoder = TorchScriptPythonDecoder (model , some_const )
136
+ ov_const = nc_decoder .as_constant ()
137
+ assert ov_const is not None
138
+ assert len (ov_const ) == 1
139
+ assert ov_const [0 ].get_element_type () == Type .f8e5m2
140
+ assert ov_const [0 ].get_partial_shape () == PartialShape ([2 ])
141
+
142
+
99
143
@pytest .mark .precommit
100
144
def test_pytorch_decoder_can_convert_fp16_tensor ():
101
145
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
102
- from openvino . runtime import PartialShape , Type
146
+ from openvino import PartialShape , Type
103
147
104
148
class SomeTensor (torch .nn .Module ):
105
149
def forward (self ):
@@ -121,7 +165,7 @@ def forward(self):
121
165
@pytest .mark .precommit
122
166
def test_pytorch_decoder_can_convert_bf16_tensor ():
123
167
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
124
- from openvino . runtime import PartialShape , Type
168
+ from openvino import PartialShape , Type
125
169
126
170
class SomeTensor (torch .nn .Module ):
127
171
def forward (self ):
@@ -143,7 +187,7 @@ def forward(self):
143
187
@pytest .mark .precommit
144
188
def test_pytorch_decoder_can_convert_fp32_tensor ():
145
189
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
146
- from openvino . runtime import PartialShape , Type
190
+ from openvino import PartialShape , Type
147
191
148
192
class SomeTensor (torch .nn .Module ):
149
193
def forward (self ):
@@ -165,7 +209,7 @@ def forward(self):
165
209
@pytest .mark .precommit
166
210
def test_pytorch_decoder_can_convert_fp64_tensor ():
167
211
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
168
- from openvino . runtime import PartialShape , Type
212
+ from openvino import PartialShape , Type
169
213
170
214
class SomeTensor (torch .nn .Module ):
171
215
def forward (self ):
@@ -187,7 +231,7 @@ def forward(self):
187
231
@pytest .mark .precommit
188
232
def test_pytorch_decoder_can_convert_bool_tensor ():
189
233
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
190
- from openvino . runtime import PartialShape , Type
234
+ from openvino import PartialShape , Type
191
235
192
236
class SomeTensor (torch .nn .Module ):
193
237
def forward (self ):
@@ -209,7 +253,7 @@ def forward(self):
209
253
@pytest .mark .precommit
210
254
def test_pytorch_decoder_can_convert_u8_tensor ():
211
255
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
212
- from openvino . runtime import PartialShape , Type
256
+ from openvino import PartialShape , Type
213
257
214
258
class SomeTensor (torch .nn .Module ):
215
259
def forward (self ):
@@ -231,7 +275,7 @@ def forward(self):
231
275
@pytest .mark .precommit
232
276
def test_pytorch_decoder_can_convert_i8_tensor ():
233
277
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
234
- from openvino . runtime import PartialShape , Type
278
+ from openvino import PartialShape , Type
235
279
236
280
class SomeTensor (torch .nn .Module ):
237
281
def forward (self ):
@@ -253,7 +297,7 @@ def forward(self):
253
297
@pytest .mark .precommit
254
298
def test_pytorch_decoder_can_convert_i16_tensor ():
255
299
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
256
- from openvino . runtime import PartialShape , Type
300
+ from openvino import PartialShape , Type
257
301
258
302
class SomeTensor (torch .nn .Module ):
259
303
def forward (self ):
@@ -275,7 +319,7 @@ def forward(self):
275
319
@pytest .mark .precommit
276
320
def test_pytorch_decoder_can_convert_i32_tensor ():
277
321
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
278
- from openvino . runtime import PartialShape , Type
322
+ from openvino import PartialShape , Type
279
323
280
324
class SomeTensor (torch .nn .Module ):
281
325
def forward (self ):
@@ -297,7 +341,7 @@ def forward(self):
297
341
@pytest .mark .precommit
298
342
def test_pytorch_decoder_can_convert_i64_tensor ():
299
343
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
300
- from openvino . runtime import PartialShape , Type
344
+ from openvino import PartialShape , Type
301
345
302
346
class SomeTensor (torch .nn .Module ):
303
347
def forward (self ):
@@ -337,7 +381,7 @@ def forward(self):
337
381
@pytest .mark .precommit
338
382
def test_pytorch_decoder_can_convert_int_list ():
339
383
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
340
- from openvino . runtime import PartialShape , Type
384
+ from openvino import PartialShape , Type
341
385
342
386
class ListConst (torch .nn .Module ):
343
387
def forward (self ):
@@ -360,7 +404,7 @@ def forward(self):
360
404
@pytest .mark .precommit
361
405
def test_pytorch_decoder_can_convert_float_list ():
362
406
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
363
- from openvino . runtime import PartialShape , Type
407
+ from openvino import PartialShape , Type
364
408
365
409
class ListConst (torch .nn .Module ):
366
410
def forward (self ):
@@ -383,7 +427,7 @@ def forward(self):
383
427
@pytest .mark .precommit
384
428
def test_pytorch_decoder_can_convert_bool_list ():
385
429
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
386
- from openvino . runtime import PartialShape , Type
430
+ from openvino import PartialShape , Type
387
431
388
432
class ListConst (torch .nn .Module ):
389
433
def forward (self ):
@@ -406,7 +450,7 @@ def forward(self):
406
450
@pytest .mark .precommit
407
451
def test_pytorch_decoder_can_convert_int_tuple ():
408
452
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
409
- from openvino . runtime import PartialShape , Type
453
+ from openvino import PartialShape , Type
410
454
411
455
class ListConst (torch .nn .Module ):
412
456
def forward (self ):
@@ -429,7 +473,7 @@ def forward(self):
429
473
@pytest .mark .precommit
430
474
def test_pytorch_decoder_can_convert_float_tuple ():
431
475
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
432
- from openvino . runtime import PartialShape , Type
476
+ from openvino import PartialShape , Type
433
477
434
478
class ListConst (torch .nn .Module ):
435
479
def forward (self ):
@@ -452,7 +496,7 @@ def forward(self):
452
496
@pytest .mark .precommit
453
497
def test_pytorch_decoder_can_convert_bool_tuple ():
454
498
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
455
- from openvino . runtime import PartialShape , Type
499
+ from openvino import PartialShape , Type
456
500
457
501
class ListConst (torch .nn .Module ):
458
502
def forward (self ):
@@ -475,7 +519,7 @@ def forward(self):
475
519
@pytest .mark .precommit
476
520
def test_pytorch_decoder_can_convert_empty_list ():
477
521
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
478
- from openvino . runtime import PartialShape , Type
522
+ from openvino import PartialShape , Type
479
523
480
524
class aten_roll (torch .nn .Module ):
481
525
def __init__ (self , shifts ):
@@ -503,7 +547,7 @@ def forward(self, x):
503
547
@pytest .mark .precommit
504
548
def test_pytorch_decoder_can_convert_int_scalar_tensor ():
505
549
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
506
- from openvino . runtime import PartialShape , Type
550
+ from openvino import PartialShape , Type
507
551
508
552
class SomeTensor (torch .nn .Module ):
509
553
def __init__ (self ) -> None :
@@ -534,7 +578,7 @@ def forward(self):
534
578
@pytest .mark .precommit
535
579
def test_pytorch_decoder_can_convert_float_scalar_tensor ():
536
580
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
537
- from openvino . runtime import PartialShape , Type
581
+ from openvino import PartialShape , Type
538
582
539
583
class SomeTensor (torch .nn .Module ):
540
584
def __init__ (self ) -> None :
@@ -565,7 +609,7 @@ def forward(self):
565
609
@pytest .mark .precommit
566
610
def test_pytorch_decoder_can_convert_tensor_list ():
567
611
from openvino .frontend .pytorch .ts_decoder import TorchScriptPythonDecoder
568
- from openvino . runtime import PartialShape , Type
612
+ from openvino import PartialShape , Type
569
613
from typing import List , Optional
570
614
571
615
class SomeTensor (torch .nn .Module ):
0 commit comments