
    [ThK                         S SK r S SKrS SKrS SKJr  S SKJrJrJr  S SK	r	S SK
JrJr  S SKJr  S SKJrJrJrJrJrJrJr  S SKJr  \(       a  S SKJr   " S	 S
\5      rS\S\4S jrS\	R>                  R@                  SS4S jr!S\	R>                  R@                  SS4S jr"S\	R>                  R@                  SS4S jr# " S S\$5      r%S\S\&S\4S jr' " S S\%S9r( " S S\(5      r)S S jr*S S jr+S\&S\$\(   4S jr,g)!    N)Iterable)AnyfinalTYPE_CHECKING)HigherOrderOperator
OpOverload)
FakeTensor)CustomObjArgument	InputKindSymIntArgumentSymFloatArgumentSymBoolArgumentTensorArgumentTokenArgument)GraphModule)ExportedProgramc                       \ rS rSrSrg)SpecViolationError    N)__name__
__module____qualname____firstlineno____static_attributes__r       N/var/www/auris/envauris/lib/python3.13/site-packages/torch/_export/verifier.pyr   r      s    r   r   opreturnc                 8    U R                   R                  (       + $ N)_schema
is_mutabler   s    r   is_functionalr%      s    zz$$$$r   nodec                     [        U 5      $ r!   )
_check_val)r&   s    r   _check_has_fake_tensorr)   !   s    dr   c                 H  ^^^^ SSK JmJmJm  UUUU4S jmS nSU R                  ;  aA  U R
                  S:X  a  U" U R                  5      (       a  g [        SU R                   S35      eU R                  S   nT" U5      (       d  [        SU R                   S	U 35      eg )
Nr   )SymBoolSymFloatSymIntc                   > U c  g[        U [        [        [        [        45      (       a  g[        U [
        R                  [
        R                  [
        R                  [
        R                  45      (       a  g[        U [        [
        R                  45      (       a  g[        U TTT45      (       a  g[        U [        5      (       a  g[        U [        5      (       a  [        U4S jU  5       5      $ g)NTc              3   4   >#    U  H  nT" U5      v   M     g 7fr!   r   ).0x_check_correct_vals     r   	<genexpr>9_check_val.<locals>._check_correct_val.<locals>.<genexpr>7   s     :c)!,,cs   F)
isinstanceintboolstrfloattorchmemory_formatdtypedevicelayoutr	   Tensorr
   r   all)valr+   r,   r-   r2   s    r   r2   &_check_val.<locals>._check_correct_val)   s    ;c4e455e115;;ell[\\j%,,788fh899.//X&&:c:::r   c                 r    [        U [        5      (       d  g[        U R                  R                  5      S:H  $ )NFr   )r5   r   lenr"   returnsr$   s    r   _no_returns_check_val.<locals>._no_returns:   s,    "j))2::%%&!++r   rA   call_function
Node.meta z is missing val field.z has invalid val field )	%torch.fx.experimental.symbolic_shapesr+   r,   r-   metar   targetr   name)r&   rF   rA   r+   r,   r-   r2   s      @@@@r   r(   r(   &   s    OO ",
 DII77o%+dkk*B*B :dii[8N!OPP
))E
Cc"" :dii[8OPSu!UVV #r   c                 4   U R                   R                  S5      nUc  [        SU R                   35      e[	        U[
        5      (       dM  [	        US   [        5      (       a4  [	        US   [        5      (       a  [        SU R                   SU 35      eg g g )Ntorch_fnz*Unable to find torch_fn metadata for node r      rI   z has invalid torch_fn field )rK   getr   rM   r5   tupler8   )r&   rO   s     r   _check_torch_fnrS   I   s    yy}}Z(H #Mdii[!YZZx''8A;$$8A;$$ :dii[8TU]T^!_`` 	% 	% (r   c                   :    \ rS rSr% 0 r\\\S   4   \S'   S r	Sr
g)_VerifierMetaT   Verifier	_registryc                    U(       a)  SU;   d  SU;   a  [        S5      eSU;   a	  US   S:w  d   eOSU;   d   eSU;   d   eUS   S:X  d   e[        US   [        5      (       d   e[        R	                  XX#5      nX@R
                  US   '   U$ )Ncheck_check_graph_modulez'Overriding method check is not allowed.dialectATEN)SyntaxErrorr5   r8   type__new__rX   )metaclsrM   basesattrsrets        r   r`   _VerifierMeta.__new__W   s    %#8E#A!"KLL%%	*:f*DDD*De###(E111#v---%	*C0000ll7%7.1%	*+
r   r   N)r   r   r   r   rX   dictr8   r_   __annotations__r`   r   r   r   r   rU   rU   T   s     -/ItCj))*/r   rU   objrL   c           	          UR                  S5      nU n[        U5       H@  u  pE[        X55      (       d   [        SSR	                  US U 5       35      e[        X55      nMB     U$ )N.z#Node referenced nonexistent target )split	enumeratehasattrRuntimeErrorjoingetattr)rh   rL   target_atomsattr_itriatoms         r   getattr_recursiveru   f   sh    <<$LH\*x&&!DSXXl[]\]N^E_D`abb8* + Or   c                       \ rS rSrSrS\4S jrS\\\	   S4   4S jr
S\\\	   S4   4S jrS\\\	   S4   4S jrS	 rS
\SS4S jr\SS j5       r\S
\R&                  R                  SS4S j5       rSrg)rW   p   r]   r   c                    [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                   [         R"                  [         R$                  [         R&                  [         R(                  [         R*                  [,        R.                  [,        R0                  [,        R2                  [4        /$ r!   )operatorgetitemaddmulsubtruedivgelegtlteqnefloordivmodand_or_not_pownegabslshiftrshiftmathceilfloortruncroundselfs    r   allowed_builtin_opsVerifier.allowed_builtin_opss   s    LLLLLLKKKKKKKKKKKKLLMMLLMMLLLLLLOOOOIIJJJJ3
 	
r   .c                     [         [        4$ r!   )r   r   r   s    r   allowed_op_typesVerifier.allowed_op_types   s    /00r   c                 8    [         R                  R                  4$ r!   )r:   fxr   r   s    r   allowed_getattr_typesVerifier.allowed_getattr_types   s    $$&&r   c                 ~    [         R                  R                  [         R                  R                  R
                  4$ r!   )r:   r   r   nn	parameter	Parameterr   s    r   allowed_getattr_types_for_subgm(Verifier.allowed_getattr_types_for_subgm   s'    $$ehh&8&8&B&BCCr   c                     g r!   r   )r   r   s     r   check_valid_opVerifier.check_valid_op   s    r   gmNc                     g)z7
Additional checks that are specific to some dialects.
Nr   )r   r   s     r   check_additionalVerifier.check_additional   s    r   c                 f    U R                  UR                  5        [        U5        [        U5        g r!   )r[   graph_module*_verify_exported_program_module_call_graph"_verify_exported_program_signature)r   eps     r   rZ   Verifier.check   s$      1226*2.r   c                   ^ ^ S[         [        [           S4   4U 4S jjnSU 4S jjnUR                  5        GH  nXAL n[	        U[
        R                  R                  5      (       d  M2  UR                  R                  5         UR                  R                   GH*  nUR                  S;   a  [        SUR                   S35      eUR                  S:X  a  [        U5        U" UR                  5        M\  UR                  S	:X  Ga  [	        UR                  [        5      (       d!  [        S
[        UR                  5       35      e[!        XFR                  5      m[	        T[
        R"                  R$                  5      (       a  U4S jn[        T5      R&                  S:X  a  U" S[        5      (       a8  U" S[(        5      (       a&  U" S[*        5      (       a  [-        TS5      (       a  GMT  [/        TSS 5      n[/        TSS 5      n	[/        TSS 5      n
[        S[        T5       S[        U5       S[        U	5       S[        U
5       35      e[        T5      R&                  S:X  a  GM  [	        TU" U5      5      (       d   [        S[        T5       SU" U5       35      eGM  UR                  S:X  d  GM  [        U5        GM-     GM     T R1                  U5        g )Nr   .c                    > U (       a  TR                  5       nOTR                  5       n[        S U 5       5      (       a   eU$ )Nc              3   0   #    U  H  o[         L v   M     g 7fr!   objectr0   ts     r   r3   OVerifier._check_graph_module.<locals>._allowed_getattr_types.<locals>.<genexpr>   s     41;   )r   r   any)is_toplevel_gmrd   r   s     r   _allowed_getattr_types<Verifier._check_graph_module.<locals>._allowed_getattr_types   s>    002::<444444Jr   c                   > S[         4U4S jjnS[        [        [           S4   4U4S jjn[        R
                  R                  R                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                  R                   [        R"                  R$                  R&                  [        R"                  R$                  R(                  [        R*                  R,                  R.                  R0                  4n[3        X" 5       5      (       d0  X" 5       ;  a&  X;  a!  [5        SU  SU" 5        SU" 5        SU 35      e[3        U [6        5      (       a/  TR8                  S	:w  a  [;        U 5      (       d  [5        S
U  S35      eTR=                  U 5        g )Nr   c                  Z   > TR                  5       n [        S U  5       5      (       d   eU $ )Nc              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr!   )inspect	isbuiltin)r0   r   s     r   r3   fVerifier._check_graph_module.<locals>._check_valid_op.<locals>._allowed_builtin_ops.<locals>.<genexpr>   s     ?3R7,,R003s   #%)r   r@   rd   r   s    r   _allowed_builtin_opsSVerifier._check_graph_module.<locals>._check_valid_op.<locals>._allowed_builtin_ops   s-    ..0?3?????
r   .c                  Z   > TR                  5       n [        S U  5       5      (       a   eU $ )Nc              3   0   #    U  H  o[         L v   M     g 7fr!   r   r   s     r   r3   cVerifier._check_graph_module.<locals>._check_valid_op.<locals>._allowed_op_types.<locals>.<genexpr>   s     8CqF{Cr   )r   r   r   s    r   _allowed_op_typesPVerifier._check_graph_module.<locals>._check_valid_op.<locals>._allowed_op_types   s-    ++-8C88888
r   z
Operator 'z#' is not an allowed operator type: z
Valid builtin ops: zValid torch functions: TRAININGz
operator 'z' is not functional)listrR   r_   r   r:   autograd	grad_modeset_grad_enabledsym_int	sym_floatsym_itesym_maxsym_minsym_notsym_sqrt_C_set_grad_enabledampautocast_mode_enter_autocast_exit_autocastr   experimentalsymbolic_shapes cast_symbool_to_symint_guardlessr5   r   r   r\   r%   r   )r   r   r   _allowed_torch_functionsr   s       r   _check_valid_op5Verifier._check_graph_module.<locals>._check_valid_op   sw   $ 
uT#Y^'<  ((99 **		''77		''66%%55VV($$ b"3"5661338Z,$RD(KL]L_K` a..B.D-E12J1KM  "j)) <<:-mB6G6G,$RD(;<  #r   >   call_methodcall_modulez'call_module is not valid: got a class 'z' rH   get_attrz/Expected get_attr target to be string, but got c                 2   > [        [        TU S 5      U5      $ r!   )r5   rp   )rM   tyattrs     r   _is_type.Verifier._check_graph_module.<locals>._is_type   s    #-gdD$.G#LLr   LoweredBackendModule
backend_idprocessed_bytescompile_specsoriginal_modulezInvalid get_attr type z2. 
LoweredBackendModule fields: backend_id(str) : z, processed_bytes(bytes) : z, compile_specs(list) : AOTInductorEPModulez. 
Valid get_attr types: placeholderr   N)rR   r_   r   modulesr5   r:   r   r   graphlintnodesr   r   rL   r(   r8   ru   r   Moduler   bytesr   rm   rp   r   )r   r   r   r   r   r   r&   r   r   r   r   r   s   `          @r   r[   Verifier._check_graph_module   s   	eDIsN6K 	-	$^ ::<C YNc588#7#788IINN		77<<,A$++bQ  WW/t$#DKK0WW
*%dkk3770MdSWS^S^N_M`a  -S++>D!$88M:..2HH'c::(01BE(J(J(0$(G(G(/6G(H(H (-4T<-N
29$@QSW2X07ot0T&8&<T$ZL I99=j9I8J K@@D_@U?V W==A-=P<Q	%S'" !" "$Z004II$ &d,B>,RSS04T$ZL A55KN5[4\^  T WW-t$g (  ~ 	b!r   r   )r   r   r   N)r   r   r   r   r\   r   r   rR   r_   r   r   r   r   r   r   r   r   rZ   r:   r   r[   r   r   r   r   rW   rW   p   s    G
T 
:1%S	3"7 1'uT#Y^'< 'DtCy#~1F D; 4 
 / /
 w"ehh&:&: w"t w" w"r   rW   )	metaclassc                       \ rS rSrSrSrg)TrainingIRVerifieri#  r   r   N)r   r   r   r   r\   r   r   r   r   r   r   #  s    Gr   r   c                    U R                   nU R                  R                   Vs1 s H  o"R                  iM     nnU H  nUR                  c  M  UR                  R
                   H?  nUR                  (       d  M  UR                  U;  d  M(  [        SUR                   S35      e   UR                  R                   H?  nUR                  (       d  M  UR                  U;  d  M(  [        SUR                   S35      e   M     g s  snf )NzInput z does not exist in the graph.zOutput )module_call_graphr   r   rM   	signatureinputsr   outputs)exported_programr   r&   r   entryargs         r   r   r   '  s    (::.44:::d		: 
  #??&--888 5, 
*GH  .
 ..888 5,!#((+HI  / #s   Dc           
      v   U R                   nU R                  R                   Vs/ s H   o"R                  S:X  d  M  UR                  PM"     nn[        U5      [        UR                  5      :w  a.  [        S[        U5       S[        UR                  5       S35      e[        UR                  U5       GH  u  pB[        UR                  [        [        [        [        45      (       a?  UR                  R                  U:w  a%  [        SUR                  R                   SU 35      eUR                  [         R"                  :X  a  M  UR                  [         R$                  :X  a  [        UR                  [        5      (       d&  [        SUR                   SUR                   S	35      eUR&                  c  [        S
UR                   S35      eUR&                  nXPR(                  ;  a  [        SU S35      e[        U R(                  U   [*        R,                  R.                  5      (       d  [        SU S35      eGM  UR                  [         R0                  :X  a  [        UR                  [        5      (       d&  [        SUR                   SUR                   S	35      eUR&                  c  [        S
UR                   S35      eUR&                  nUR2                  c  [        SU S35      eUR2                  SL a  X`R(                  ;  a  [        SU S35      eUR2                  SL a!  X`R(                  ;   a  [        SU S35      eGM  GM  UR                  [         R4                  :X  a  [        UR                  [        5      (       d&  [        SUR                   SUR                   S	35      eUR&                  c  [        S
UR                   S35      eUR&                  nXpR6                  ;  a  [        SU S35      eGMV  UR                  [         R8                  :X  a  [        UR                  [:        5      (       d&  [        SUR                   SUR                   S	35      eUR&                  c  [        S
UR                   S35      eUR&                  nXR6                  ;  a  [        SU S35      eGM  UR                  [         R<                  :X  aH  [        UR                  [>        5      (       d&  [        SUR                   SUR                   S	35      eGMr  [        SUR                   S35      e   [A        U R                  R                  5      S   n	U	R                  S:X  d   eU	RB                  S    V
s/ s H:  n
[        U
[*        RD                  RF                  5      (       a  U
R                  OU
PM<     nn
[        U5      [        URH                  5      :w  aD  [        S[        U5       S[        URJ                  5       S [        URL                  5       S!35      e[        URN                  5      n[        URJ                  5      [        URP                  5      -   U-   nXU nXU[        URL                  5      -    nU H  nUURJ                  ;   aH  URJ                  U   URR                  ;  a)  [        S"U S#URJ                   S$URR                   S%35      eM[  UURP                  ;   aH  URP                  U   URT                  ;  a)  [        S&U S'URP                   S(URT                   S%35      eM  [        S)U S*URJ                   S+URP                   35      e   [        XRL                  5       H(  u  nnUU:w  d  M  [        S,U S-URL                   S.35      e   g s  snf s  sn
f )/Nr   zNumber of graph inputs (z:) does not match number of inputs in the graph signature ()zInput spec name z does not match node name z
Parameter z! is not a tensor argument. Found z	 instead.zInputSpec for z has no target.z is not in the state dict.zState dict entry for parameter z* is not an instance of torch.nn.Parameter.zBuffer z is missing a persistence flagTFzNon-persistent buffer z( is in the state dict, it should not be.zConstant tensor z$ is not in the constants dictionary.zCustom object z( is not a custom object argument. Found zUnknown InputKind rj   outputr   zNumber of output nodes zg is different Than the number of outputs specified by the graph signature: 
Number of mutated buffers: z. 
Number of user outputs: z. 
zBuffer output zV does not point to a buffer that exists. 
Dict of buffers that are mutated, in order: z 
Buffer nodes available: z 
zUser input output z^ does not point to a user input that exists. 
Dict of user inputs that are mutated, in order: z 
User input nodes available: zMutation node z: is neither a buffer nor a user input. Buffers to mutate: z, User inputs to mutate: zUser output zY is not in the correct order or is not found in the exported program's user_output list: z. )+graph_signaturer   r   r   rM   rD   input_specsr   zipr5   r  r   r   r   r   kindr   
USER_INPUT	PARAMETERrL   
state_dictr:   r   r   BUFFER
persistentCONSTANT_TENSOR	constants
CUSTOM_OBJr
   TOKENr   r   argsr   Nodeoutput_specsbuffers_to_mutateuser_outputsoutput_tokensuser_inputs_to_mutatebuffersuser_inputs)r  gsr&   input_node_names
input_specparambuffertensor_const
custom_objoutput_noder  output_nodes
num_tokensendmutate_nodesuser_output_nodesmutation_nodeuser_output_nodeuser_output_names                      r   r   r   :  s   		)	)B /?.D.D.J.Jg.JdggYfNf			.Jg
BNN 33 &s+;'<&= >GGJ2>>GZF[[\^
 	

  0@A
jnn~~GWYh&ijj~~""d*(&z~~':':&;;UVZU[\  ??i222__	 3 33jnnn==(  11RS]SaSaRbbkl    (($Z__$5_E  %%E777( 'AB  .99%@%((BTBTUU(5eW<fg  V
 __	 0 00jnnn==(joo..OPZP^P^O__hi    (($Z__$5_E   &&F$$,(fX%CD  $$,?Z?Z1Z(fX%?@  $$-&<W<W2W(,VH4\]  3X- __	 9 99jnnn==(&z&77XYcYgYgXhhqr    (($Z__$5_E  &,,L#=#==(&|n4XY  > __	 4 44jnn.?@@($Z__$55]^h^l^l]mmvw    (($Z__$5_E  $**J!;!;;($ZL0TU  < __	/jnnm<<(&z&77XYcYgYgXhhqr  =
 %$Z__$5Q7 y BB '--334R8K>>X%%% ##A&&C sEHHMM22;&  
 <C00 %c,&7%8 9**-b.B.B*C)D E''*2??';&<DB
 	
 R%%&J
b""
#c"*B*B&C
Cj
PC*c:L$s2??/C)CD%B000##M2"**D($]O 4CCECWCWBX Y//1zzl#?  E b666''6bnnL(( 8GGIG_G_F` a335>>2B#GH H M %  0&&(&:&:%;;TUWUmUmTnp  &( /22C__.U**//$/0 188:7HL  /Vc hVs   ^1^1A^6r\   c                     U S:X  d  U S:X  a$  [         R                  R                  U [        5      $ [         R                  U    $ )Nr]    )rU   rX   rQ   rW   )r\   s    r   load_verifierr3    s:    &GrM&&**7H==""7++r   r   )-r   r   ry   collections.abcr   typingr   r   r   r:   
torch._opsr   r   torch._subclasses.fake_tensorr	   torch.export.graph_signaturer
   r   r   r   r   r   r   torch.fxr   torch.export.exported_programr   	Exceptionr   r7   r%   r   r  r)   r(   rS   r_   rU   r8   ru   rW   r   r   r   r3  r   r   r   <module>r<     s      $ , ,  6 4   !=	 	%j %T % 4 
 WUXX]]  Wt  WF	a%((-- 	aD 	aD $3   p" p"f &\~,3 ,4> ,r   