Coverage for mlprodict/__init__.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

16 statements  

1# -*- encoding: utf-8 -*- 

2""" 

3@file 

4@brief Python runtime for ONNX and others tools to help 

5converting investigate issues with ONNX models. 

6""" 

7 

8__version__ = "0.8.1762" 

9__author__ = "Xavier Dupré" 

10__max_supported_opset__ = 15 # Converters are tested up to this version. 

11__max_supported_opsets__ = { 

12 '': __max_supported_opset__, 

13 'ai.onnx.ml': 2} 

14# Converters are tested up to this version. 

15__max_supported_opset_experimental__ = 16 

16__max_supported_opsets_experimental__ = { 

17 '': __max_supported_opset_experimental__, 

18 'ai.onnx.ml': 3} 

19 

20 

21def get_ir_version(opv): 

22 """ 

23 Returns the corresponding `IR_VERSION` based on the selected opset. 

24 See :epkg:`ONNX Version`. 

25 

26 :param opv: opset 

27 :return: runtime version 

28 """ 

29 if isinstance(opv, dict): 

30 opv = opv[''] 

31 if opv is None or opv >= 15: 

32 return 8 

33 if opv >= 12: 

34 return 7 

35 if opv >= 11: # pragma no cover 

36 return 6 

37 if opv >= 10: # pragma no cover 

38 return 5 

39 if opv >= 9: # pragma no cover 

40 return 4 

41 if opv >= 8: # pragma no cover 

42 return 4 

43 return 3 # pragma no cover 

44 

45 

46def check(log=False): 

47 """ 

48 Checks the library is working. 

49 It raises an exception. 

50 If you want to disable the logs: 

51 

52 @param log if True, display information, otherwise 

53 @return 0 or exception 

54 """ 

55 return True 

56 

57 

58def load_ipython_extension(ip): # pragma: no cover 

59 """ 

60 To allow the call ``%load_ext mlprodict`` 

61 

62 @param ip from ``get_ipython()`` 

63 """ 

64 from .nb_helper import register_onnx_magics as freg 

65 freg(ip)