
    '}h3                        d Z ddlZddlmZmZ ddlZddlmZ ddlmZm	Z	m
Z
 ddlmZmZmZ ddgZ ej                   ej"                  d	
      Z ed       e
j&                  dddddd      dej(                  dej*                  dee   dej*                  dej*                  dedefd              Zd Z ed       e
j&                  dddddddd      ej6                  	 	 	 	 	 	 d%dej(                  dej*                  dedee   dee   deej*                     d ed!ee   d"ee   d#ej*                  fd$                     Zy)&a  This file exports ONNX ops for opset 17.

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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
https://github.com/onnx/onnx/blob/main/docs/Changelog.md#version-17-of-the-default-onnx-operator-set
New operators:
    BlackmanWindow
    DFT
    HammingWindow
    HannWindow
    LayerNormalization
    MelWeightMatrix
    STFT
    SequenceMap
    N)OptionalSequence)_C)_type_utilserrorssymbolic_helper)	_beartype	jit_utilsregistration
layer_normstft   )opsetzaten::layer_normvisfnoneginputnormalized_shapeweightbiasepscudnn_enablec                    t        |       }t        j                  j                  |t        j                  j                        }|j                         }	t        j                  |      r*t        j                  ||	      }
| j                  d|
      }t        j                  |      r*t        j                  ||	      }| j                  d|      }| j                  d|||||      S )NdtypeConstantvalue_tLayerNormalization)	epsilon_faxis_i)lenr   JitScalarType
from_valueFLOATr   r   _is_nonetorchonesopzeros)r   r   r   r   r   r   r   axisscalar_typer   weight_value
bias_values               Z/var/www/html/test/engine/venv/lib/python3.12/site-packages/torch/onnx/symbolic_opset17.pyr   r   "   s      !!D++66{((..K E'zz"2%@j,7%[[!1?
ttJ
t344       c                 *    | |z
  dz  }| |z
  |z
  }||fS )zuHelper function to compute the sizes of the edges (left and right)
    of a given window centered within an FFT size.    )n_fftwindow_sizeleftrights       r1   _compute_edge_sizesr:   F   s+     KA%DDL;&E;r2   z
aten::stftibr6   
hop_length
win_lengthwindow
normalizedonesidedreturn_complexreturnc	                 |   |rt        j                  d|      ||n|dz  }	| j                  dt        j                  |	t        j
                              }
| j                  dt        j                  |t        j
                              }|}t        j                  |      }|dk(  rI| j                  d|| j                  dt        j                  d	gt        j
                                    }n |d
kD  rt        j                  d| d|      t        j                  |d	      }||r|n|}||k(  sJ d| df       ||k  rqt        ||      \  }}| j                  dt        j                  |            }| j                  dt        j                  |            }| j                  d|||d	      }t        j                  |      r|r||kD  rt        j                  d| d| d|      t        ||      \  }}t        j                  t        j                  |      t        j                  |      t        j                  |      f      }nt        j                  |      }|j                  d	   |k(  sJ | j                  d|      }| j                  d|t        j                   j#                  |      j%                               }| j                  d||
||||rdnd	      }| j                  d|g d      }|dk(  rH| j                  d|| j                  dt        j                  d	gt        j
                                    }|rjt        j&                  t        j                  ||j)                         j+                                     }| j                  d|| j                  d|            }|S )a  Associates `torch.stft` with the `STFT` ONNX operator.
    Note that torch.stft calls _VF.stft, without centering or padding options.
    Hence, this function does not contain these two arguments.
    See torch.stft source code for more info.

    Args:
        g: Graph to write the ONNX representation into
        input: Input tensor for the transformation
        n_fft: FFT size
        hop_length: Size of the hop. Defaults to `floot(n_fft // 4)`
        win_length: Size of the analysis window. Defaults to `n_fft`
        window: Analysis window. Defaults to a window of all ones
        normalized: Whether to return a normalized STFT
        onesided: Whether to return only half (+1) of the results, given the
            symmetry of the STFT
        return_complex: Whether to return the complex value (Note: Must be
            `False` or `None`)

    Returns:
        op: Operator for torch.stft associated with STFT (ONNX)
    z-STFT does not currently support complex types)msgvalue   r   r   r      	Unsqueezer   r4   zcSTFT can only take inputs of 1 [signal] or 2 [batch, signal] dimensions. Current rank of signal is z, please reduce it.)dimzuAnalysis window size must equal `win_length` or `n_fft`. Please, set `win_length` or `n_fft` to match `window` size ()Concat)r#   zWThe analysis window can't be longer than the size of the FFT. Please set `win_length` (z) to `n_fft` (z
) or less.Cast)to_iSTFT)
onesided_i	Transpose)r   r4   rH      )perm_iSqueezeDiv)r   SymbolicValueErrorr+   r)   tensorint64r   _get_tensor_rank_get_tensor_dim_sizer:   r,   r(   hstackr*   shaper   r%   r&   	onnx_typesqrttyper   )r   r   r6   r=   r>   r?   r@   rA   rB   frame_step_valueframe_step_constframe_length_constsignalsignal_rankn_winwin_length_defaultr8   r9   left_win	right_wintorch_windowresult	sqrt_nffts                          r1   r   r   N   s   H ''?u
 	

 &0%;z!ttELL)9M   ELLekkB  
 F!226:KaDDU\\1#U[[%IDJ

 
q''))45HJ
 	
 00Q?E+5Z5** 	
KKP'QRT-
 	
* 5=-eU;KD%ttJD0AtBHZU1CDITT(HfiTJF 'E!//00:|>%PZ\  .eZ@KD% <<T"EJJz$:EKK<NOL
 !::e,L!!!$---j,7TT[66AA&ISSU  F
 TT (H1!  F TT+vlT;F aDDU\\1#U[[%IDJ
 JJu||E9L9L9NOP	eVQTT*iT%HIMr2   )NNNFTF)__doc__	functoolstypingr   r   r)   r   
torch.onnxr   r   r   torch.onnx._internalr	   r
   r   __all__partialonnx_symbolic_onnx_symbolic
parse_argsGraphContextValueintfloatboolr   r:   beartyper   r5   r2   r1   <module>r|      s  "  %   ; ; C C
 
 """<#=#=RH "#CsCf=88 sm HH	
 (( 
  > $D Cc3S#sC

 !% $!%#%*BB88B B 	B
 B RXXB B tnB TNB XXB  D Br2   