
    IЦiD                        S SK r S SKrS SKrS SKJr  S SKrS SKJr  S SKJ	r	  S SK
JrJrJr  S SKJrJr  S SKJr  \R&                  " \5      r " S S	5      rS
\4S jrS rS rS
\R4                  4S jrS
\R8                  4S jrg)    N)patchdisable)TensorifyScalarRestartAnalysis)countersdefakeflatten_graph_inputs)aot_module_simplifiedSerializableAOTDispatchCompiler)_disable_current_modesc                   T    \ rS rSrSS jrS\R                  R                  4S jrSr	g)AotAutograd   Nc                     SU l         Xl        g )Ncompiler_fn__name__kwargs)selfr   s     \/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torch/_dynamo/backends/common.py__init__AotAutograd.__init__   s    %    gmc                    U(       a  [         R                  SU5        [        S U 5       5      (       a  [        UUU 5      $ [	        U R
                  R                  S5      5      (       a!  U R
                  S   " 5       U R
                  S'   [        S   S==   S-  ss'   SnU(       a+  [         R                  S5        [        S   S	==   S-  ss'   U$ S
 nU R
                  R                  S5      =(       d    U R
                  S   n[        U[        5      (       a  U" UR                  5      Ul        OU" U5      nX`R
                  S'   U R
                  R                  S5      =(       d    U R
                  S   U R
                  S'   SSKJn  SSKJn  U R
                  R                  SS 5      U:X  a  [!        SS5      n	O["        R$                  " 5       n	 U" 5          U	   ['        X40 U R
                  D6n
[        S   S==   S-  ss'   [)        U
5      sS S S 5        sS S S 5        $ ! , (       d  f       O= fS S S 5        g ! , (       d  f       g = f! [*         a    e [,         a    [        S   S	==   S-  ss'   e f = f)Nz3aot_autograd-based backend ignoring extra kwargs %sc              3   X   #    U  H   n[        U[        [        [        45      v   M"     g 7fN)
isinstancelisttupledict).0xs     r   	<genexpr>'AotAutograd.__call__.<locals>.<genexpr>   s!     J>az!dE4011>s   (*decompositionsaot_autogradtotal   Fz5Unable to use AOT Autograd because graph has mutationnot_okc                    ^  U 4S jnU$ )Nc                  8   > [        [        T5      " U 0 UD65      $ r   r   )argsr   bw_compiler_fns     r   _wrapped_bw_compilerLAotAutograd.__call__.<locals>.wrap_bw_compiler.<locals>._wrapped_bw_compiler4   s    w~6GGHHr    )r.   r/   s   ` r   wrap_bw_compiler.AotAutograd.__call__.<locals>.wrap_bw_compiler3   s    I ('r   bw_compilerfw_compilerinference_compilerr   )nop)enable_aot_loggingz%functorch.compile.config.debug_assertTok)logwarninganyr	   callabler   getr   debugr   r   r   functorch.compiler7   torch._inductor.debugr8   r   
contextlibnullcontextr
   r   r   	Exception)r   r   example_inputsr   use_fallbackr2   r4   r7   r8   patch_configcgs              r   __call__AotAutograd.__call__   s   KKMvVJ>JJJ'  DKKOO$4566,0KK8H,I,KDKK() 	 )Q.)IIMN^$X.!3.I	( kkoom4RM8Rk#BCC&6{7N7N&OK#*;7K%0M"KKOO01OT[[5O 	() 	*< ;;??=$/36 !H$OL%113L
	#%|*2MM(.!3.r{ (4|%%||%%% . 	 	^$X.!3.	sH   I I"5H*	I 	I *
H8	4I;I 
II I *I?r   )returnN)
r   
__module____qualname____firstlineno__r   torchfxGraphModulerI   __static_attributes__r1   r   r   r   r      s    ?588// ?r   r   rK   c                      [        S0 U D6$ )Nr1   )r   )r   s    r   r'   r'   ]   s       r   c                 <    SSK JnJnJn  UUUS.nU (       a  XS'   U$ )Nr   )default_decompositions#min_cut_rematerialization_partition
ts_compile)r5   r4   partition_fnr&   )r@   rU   rV   rW   )use_decompsrU   rV   rW   r   s        r   mem_efficient_fusion_kwargsrZ   a   s1      "!;	F #9 Mr   c                 F   ^  [         R                  " T 5      U 4S j5       nU$ )z[
Decorator for backends that need real inputs.  We swap out fake
tensors for zero tensors.
c                    > [        5          [        [        [        U5      5      nT" X40 UD6sS S S 5        $ ! , (       d  f       g = fr   )r   r   mapr   )modelinputsr   fns      r   wrapper(fake_tensor_unsupported.<locals>.wrapper{   s3    #%#ff-.Fe.v. &%%s	   "8
A)	functoolswraps)r`   ra   s   ` r   fake_tensor_unsupportedre   u   s'     __R/ /
 Nr   c                 T    U  H"  n[        US5      (       d  M  UR                  s  $    g )Ndevice)hasattrrg   rE   r#   s     r   device_from_inputsrj      s"    1h88O r   c                 T    U  H"  n[        US5      (       d  M  UR                  s  $    g )Ndtype)rh   rl   ri   s     r   dtype_from_inputsrm      s"    1g77N r   )rB   rc   loggingunittest.mockr   rO   torch._dynamor   torch._dynamo.excr   torch._dynamo.utilsr   r   r	   torch._functorch.aot_autogradr
   r   torch.utils._python_dispatchr   	getLoggerr   r:   r   r'   rZ   re   rg   rj   rl   rm   r1   r   r   <module>rv      s         ! < F F @ !D DN!k !(%,,  r   