
    JTh
                     T   S r SSKrSSKrSSKJrJr  SSKJrJrJ	r	J
r
  SSKJrJr  \R                  " \R                  SS9r\" S5      \	R"                  " S	S	S
S
S5      S\R$                  4S j5       5       r\" S5      \	R"                  " S	S
S	S	5      S\R$                  4S j5       5       r\" S5      \	R"                  " S	S
S	S	SS5      S\R$                  S\R*                  R,                  S\S\R*                  R,                  S\R*                  R,                  S\S\4S j5       5       rg)a  This file exports ONNX ops for opset 16.

Note [ONNX Operators that are added/updated in opset 16]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
https://github.com/onnx/onnx/blob/main/docs/Changelog.md#version-16-of-the-default-onnx-operator-set
New operators:
    GridSample https://github.com/onnx/onnx/pull/3557

Updated operators:
    Identity
    If
    LeakyRelu
    Loop
    PRelu
    RoiAlign
    Scan
    ScatterElements
    ScatterND
    Where
    GreaterOrEqual
    LessOrEqual
    N)GRID_SAMPLE_INTERPOLATION_MODESGRID_SAMPLE_PADDING_MODES)_type_utilserrorssymbolic_helperutils)	jit_utilsregistration   )opsetzaten::grid_samplervibgc           	      h   [         R                  " U5      S:X  a  [         R                  " S5      $ [        R                  " 5        VVs0 s H  u  pgXv_M	     snnU   n[
        R                  " 5        VVs0 s H  u  pgXv_M	     snnU   n	U R                  SUU[        U5      UU	S9$ s  snnf s  snnf )N   z#GridSample with 5D volumetric input
GridSample)align_corners_imode_spadding_mode_s)r   _get_tensor_rank_onnx_unsupportedr   itemsr   opint)
r   inputgrid	mode_enumpadding_mode_enumalign_cornerskr   r   r   s
             S/var/www/auris/envauris/lib/python3.13/site-packages/torch/onnx/symbolic_opset16.pygrid_samplerr#   -   s     ''.!3001VWW>DDFGFtqadFG	RF'@'F'F'HI'Htqad'HIN 44M*%   	 HIs   	B(6B.zaten::scatter_addc           	      d   [         R                  R                  U[         R                  R                  5      n[        R
                  " U5      n[        R
                  " U5      n[        U5      [        U5      :w  a  [        R                  " SSU SU S35      $ Xg:w  d  S U;   aV  U R                  SU5      nU R                  S[        R                  " S/[        U5      -  5      S9n	U R                  S	XIU5      n[        R                  " U5      n[        R                  " U5      (       a  U R                  S
XXBSS9$ [         R                  R                  U5      U:w  a<  U R                  SU[         R                  R                  U5      R                  5       S9nU R                  S
UUUUSS9$ )Nscatter_addz	`index` (z0) should have the same dimensionality as `src` ()ShapeConstantr   value_tSliceScatterElementsaddaxis_ireduction_sCast)to_i)r   JitScalarType
from_value	UNDEFINEDr   _get_tensor_sizeslen_unimplementedr   torchtensor_maybe_get_scalar	_is_value	onnx_type)
r   selfdimindexsrcsrc_type	src_sizesindex_sizesadjusted_shapestartss
             r"   r%   r%   H   s    ((33[&&00H  11#6I!33E:K
9~[))--}$TU^T__`a
 	
 4;#6gu-j%,,sS=M7M*NOdd7C8

+
+C
0C  %%tt%tCQVtWW $$//5A$$ ..99$?IIK  C tt  
 	
    zaten::scatter_reducesr>   r?   r@   rA   reduceinclude_selfc                    US:X  a  [         R                  " S5      eU(       d  [         R                  " S5      eSSSSSS	.nXu   nU R                  S
U R                  SU5      5      n	U R                  SXR                  S[        R                  " S[        R
                  S9S95      n
[        R                  " U SU
SSS9u  nu  pnUR                  S[        R                  " S/[        R
                  S9S9nUR                  SX5      n[        R                  " UR                  U5        UR                  SX?5      n[        R                  " UR                  U5        UR                  SXO5      n[        R                  " UR                  U5        UR                  SU5      n[        R                  " UR                  U5        UR                  SU5      n[        R                  " UR                  U5        UR                  SU5      n[        R                  " UR                  U5        U R                  " S/UQ7X(S.6n[        R                  " U SU
SSS9u  nu  pnUR                  SU5      n[        R                  " UR                  U5        UR                  SU5      n[        R                  " UR                  U5        UR                  5       R                  5       nU$ )Nmeanz7ONNX does not support mean reduction for scatter_reducez;ONNX does not support include_self=False for scatter_reducenoner-   mulminmax)rL   sumprodaminamaxSizer'   Equalr(   r   )dtyper)   If      )n_blocksoutputsReshapeIdentityr,   r.      Squeeze)r   OnnxExporterErrorr   r9   r:   int64r	   add_op_with_blocksr   _add_output_to_blockblocknodeoutput)r   r>   r?   r@   rA   rI   rJ   reduce_modeonnx_reduce	self_rankself_rank_is_zeroif_op
if_contextelse_context_neg_1self_reshapeindex_reshapesrc_reshapeself_identityindex_identityesrc_identityresultresult_squeezedresult_identityresult_finals                             r"   scatter_reducer|   w   s    &&E
 	
 &&I
 	

 K %KVQTT'401I DDU\\!5;;5WDX ,5+G+G	4"Q,(E%Jq MM*ellB4u{{.SMTE==D8L	z//>MM)U:M	z//?--	36K	z//= OOJ5M	|11=A"ooj%8O	|11?C??:s3L	|11<@TT#QeQCQF ,5+G+G	4"Q,(E%Jq !mmIv6O	z//A"ooj&9O	|11?C::<&&(LrG   )__doc__	functoolsr9   torch.nn.functionalr   r   
torch.onnxr   r   r   r   torch.onnx._internalr	   r
   partialonnx_symbolic_onnx_symbolic
parse_argsGraphContextr#   r%   _CValuer   strboolr|    rG   r"   <module>r      sa  6   C B 8 ""<#=#=RH
 $%Cc34 5 &2 #$Cc3/*
9)) *
 0 %*
Z &'Cc3S9@@
((..@ 
@ 88>>	@
 
@ @ @ : (@rG   