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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

9 statements  

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)