
    ёi                        S SK Jr  S SKrS SKJr  S SKJr  \(       a$  S SKJr  S SK	J
r
  S SKJr  S SKJr  S S	KJr  S S
KJr  / r  S           SS jjrg)    )annotationsN)TYPE_CHECKING)
try_import)Sequence)Unpack)Tensor)_SaveOptions)Layer)	InputSpecc                    [        S5      n[        R                  R                  U5      nUS:X  a  [	        SU 35      eUS-   nUR
                  " U U4UUS.UD6  g)aR  
Export Layer to ONNX format, which can use for inference via onnxruntime or other backends.
For more details, Please refer to `paddle2onnx <https://github.com/PaddlePaddle/paddle2onnx>`_ .

Args:
    layer (Layer): The Layer to be exported.
    path (str): The path prefix to export model. The format is ``dirname/file_prefix`` or ``file_prefix`` ,
        and the exported ONNX file suffix is ``.onnx`` .
    input_spec (list[InputSpec|Tensor]|None, optional): Describes the input of the exported model's forward
        method, which can be described by InputSpec or example Tensor. If None, all input variables of
        the original Layer's forward method would be the inputs of the exported ``ONNX`` model. Default: None.
    opset_version(int, optional): Opset version of exported ONNX model.
        Now, stable supported opset version include 9, 10, 11. Default: 9.
    **configs (dict, optional): Other export configuration options for compatibility. We do not
        recommend using these configurations, they may be removed in the future. If not necessary,
        DO NOT use them. Default None.
        The following options are currently supported:
        (1) output_spec (list[Tensor]): Selects the output targets of the exported model.
        By default, all return variables of original Layer's forward method are kept as the
        output of the exported model. If the provided ``output_spec`` list is not all output variables,
        the exported model will be pruned according to the given ``output_spec`` list.
Returns:
    None
Examples:
    .. code-block:: python

        >>> import paddle

        >>> class LinearNet(paddle.nn.Layer):
        ...     def __init__(self):
        ...         super().__init__()
        ...         self._linear = paddle.nn.Linear(128, 10)
        ...
        ...     def forward(self, x):
        ...         return self._linear(x)
        ...
        >>> # Export model with 'InputSpec' to support dynamic input shape.
        >>> def export_linear_net():
        ...     model = LinearNet()
        ...     x_spec = paddle.static.InputSpec(shape=[None, 128], dtype='float32')
        ...     paddle.onnx.export(model, 'linear_net', input_spec=[x_spec])
        ...
        >>> # doctest: +SKIP('Need install Paddle2ONNX')
        >>> export_linear_net()

        >>> class Logic(paddle.nn.Layer):
        ...     def __init__(self):
        ...         super().__init__()
        ...
        ...     def forward(self, x, y, z):
        ...         if z:
        ...             return x
        ...         else:
        ...             return y
        ...
        >>> # Export model with 'Tensor' to support pruned model by set 'output_spec'.
        >>> def export_logic():
        ...     model = Logic()
        ...     x = paddle.to_tensor([1])
        ...     y = paddle.to_tensor([2])
        ...     # Static and run model.
        ...     paddle.jit.to_static(model)
        ...     out = model(x, y, z=True)
        ...     paddle.onnx.export(model, 'pruned', input_spec=[x, y, True], output_spec=[out], input_names_after_prune=[x.name])
        ...
        >>> export_logic()
paddle2onnx zThe input path MUST be format of dirname/file_prefix [dirname\file_prefix in Windows system], but the file_prefix is empty in received path: z.onnx)
input_specopset_versionN)r   ospathbasename
ValueErrordygraph2onnx)layerr   r   r   configsp2ofile_prefix	save_files           R/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/onnx/export.pyexportr   #   s~    V ]
#C''""4(Kb::>A
 	

 wI #	
     )N	   )r   r
   r   strr   z,Sequence[InputSpec | Tensor | object] | Noner   intr   zUnpack[_SaveOptions]returnNone)
__future__r   r   typingr   paddle.utilsr   collections.abcr   typing_extensionsr   paddler   paddle.jit.apir	   	paddle.nnr
   paddle.staticr   __all__r    r   r   <module>r.      s}    # 	   #((+'  @D	\\
\ =\ 	\
 $\ 
\r   