Coverage for onnxcustom/utils/print_helper.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.0.5, created at 2023-01-17 01:42 +0100

1""" 

2@file 

3@brief Helpers to display internal structures. 

4""" 

5 

6 

7def str_ortvalue(ov): 

8 """ 

9 Displays the content of an :epkg:`C_OrtValue`. 

10 

11 :param ov: :epkg:`OrtValue` or :epkg:`C_OrtValue` 

12 :return: str 

13 """ 

14 if hasattr(ov, '_ortvalue'): 

15 return str_ortvalue(ov._ortvalue) 

16 device = ov.device_name() 

17 value = ov.numpy() 

18 values = value.ravel().tolist() 

19 if len(values) > 10: 

20 values = values[:5] + ["..."] + values[-5:] 

21 return "device=%s dtype=%r shape=%r value=%r" % ( 

22 device, value.dtype, value.shape, values)