U
    q±Ëhº  ã                   @  sT   d dl mZ d dlZd dlm  mZ dddddœdd„Zddd	ddd
œdd„ZdS )é    )ÚannotationsNFzonnx.ModelProtoÚbool)ÚmodelÚconvert_versionÚreturnc                 C  s&   t  |  ¡ |¡}t ¡ }| |¡ |S )ab  Inline model-local functions in given model.

    Arguments:
        model: an ONNX ModelProto
        convert_version: if true, try to apply automatic version-conversion to functions requiring a
            different (ONNX) opset version from the model.

    Returns:
        ModelProto with all calls to model-local functions inlined (recursively)
    )ÚCÚinline_local_functionsÚSerializeToStringÚonnxÚ
ModelProtoÚParseFromString)r   r   ÚresultÚinlined_model© r   ú0/tmp/pip-unpacked-wheel-xnis5xre/onnx/inliner.pyr      s    
r   zlist[tuple[str, str]])r   Úfunction_idsÚexcluder   c                 C  s(   t  |  ¡ ||¡}t ¡ }| |¡ |S )aü  Inline selected model-local functions in given model.

    Arguments:
        model: an ONNX ModelProto
        function_ids: list of functions to include/exclude when inlining. Each
            element is a tuple of (function domain, function name).
        exclude: if true, inlines all functions except those specified in function_ids.
           if false, inlines all functions specified in function_ids.

    Returns:
        ModelProto with all calls to model-local functions inlined (recursively)
    )r   Úinline_selected_functionsr	   r
   r   r   )r   r   r   r   r   r   r   r   r      s      ÿ
r   )F)F)	Ú
__future__r   r
   Zonnx.onnx_cpp2py_export.inlinerZonnx_cpp2py_exportZinlinerr   r   r   r   r   r   r   Ú<module>   s    ÿ ÿ