Ë
    f^(h{X  ã                   ó  — d dl Z d dlmZmZ d dlmZmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZ e	r
d dlZd dlmZ g d¢Ze j&                   G d	„ d
«      «       Ze j&                   G d„ d«      «       Ze j&                   G d„ d«      «       Ze j&                   G d„ d«      «       Ze j&                   G d„ d«      «       Ze j&                   G d„ d«      «       Ze j&                   G d„ d«      «       Ze
eeeeeeef   Z G d„ de«      Ze j&                   G d„ d«      «       Z G d„ de«      Ze j&                   G d„ d«      «       Ze j&                   G d„ d «      «       Z e j&                   G d!„ d"«      «       Z!d#„ Z"d$efd%„Z#d&d'd(d)d*e$e%   d$d"fd+„Z&y),é    N)Ú
CollectionÚMapping)ÚautoÚEnum)ÚOptionalÚTYPE_CHECKINGÚUnion©ÚFakeScriptObject)Úis_fake)ÚGraphSignature)ÚConstantArgumentÚCustomObjArgumentÚExportBackwardSignatureÚExportGraphSignatureÚ	InputKindÚ	InputSpecÚ
OutputKindÚ
OutputSpecÚSymIntArgumentÚSymFloatArgumentÚSymBoolArgumentÚTensorArgumentc                   ó   — e Zd ZU eed<   y)r   ÚnameN©Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__© ó    úZ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/export/graph_signature.pyr   r      ó   … à
„Ir#   r   c                   ó   — e Zd ZU eed<   y)ÚTokenArgumentr   Nr   r"   r#   r$   r'   r'   $   r%   r#   r'   c                   ó   — e Zd ZU eed<   y)r   r   Nr   r"   r#   r$   r   r   )   r%   r#   r   c                   ó   — e Zd ZU eed<   y)r   r   Nr   r"   r#   r$   r   r   .   r%   r#   r   c                   ó   — e Zd ZU eed<   y)r   r   Nr   r"   r#   r$   r   r   3   r%   r#   r   c                   ó6   — e Zd ZU eed<   eed<   dZee   ed<   y)r   r   Ú	class_fqnNÚfake_val)r   r   r   r    r!   r-   r   r   r"   r#   r$   r   r   8   s   … à
ƒIØƒNØ+/€HˆhÐ'Ñ(Ô/r#   r   c                   ó2   — e Zd ZU eed<   eeeeedf   ed<   y)r   r   NÚvalue)	r   r   r   r    r!   r	   ÚintÚfloatÚboolr"   r#   r$   r   r   ?   s   … à
ƒIØ��e˜T 3¨Ð,Ñ-Ô-r#   r   c                   ó`   — e Zd Z e«       Z e«       Z e«       Z e«       Z e«       Z e«       Z	y)r   N)
r   r   r   r   Ú
USER_INPUTÚ	PARAMETERÚBUFFERÚCONSTANT_TENSORÚ
CUSTOM_OBJÚTOKENr"   r#   r$   r   r   P   s,   „ Ù“€JÙ“€IÙ‹V€FÙ“f€OÙ“€JÙ‹F�Er#   r   c                   óL   — e Zd ZU eed<   eed<   ee   ed<   dZee	   ed<   d„ Z
y)r   ÚkindÚargÚtargetNÚ
persistentc           
      ó  — | j                   t        j                  k(  r| j                  €J d«       ‚t	        | j
                  t        t        t        t        t        t        t        f«      sJ dt        | j
                  «      › �«       ‚y )Nz,Failed to specify persistent flag on BUFFER.zgot )r;   r   r6   r>   Ú
isinstancer<   r   r   r   r   r   r   r'   Útype©Úselfs    r$   Ú__post_init__zInputSpec.__post_init__`   s{   € Ø�9‰9œ	×(Ñ(Ò(à—‘Ð+ð>à=ó>Ø+äØ�H‰HäÜÜ ÜÜ Ü!Üðô
ð 	#ð ”$�t—x‘x“.Ð!Ð"ó	#ñ 
r#   )r   r   r   r   r!   ÚArgumentSpecr   r    r>   r2   rD   r"   r#   r$   r   r   Y   s*   … à
ƒOØ	ÓØ�S‰MÓØ!%€J�˜‘Ó%ó#r#   r   c                   ón   — e Zd Z e«       Z e«       Z e«       Z e«       Z e«       Z e«       Z	 e«       Z
y)r   N)r   r   r   r   ÚUSER_OUTPUTÚLOSS_OUTPUTÚBUFFER_MUTATIONÚGRADIENT_TO_PARAMETERÚGRADIENT_TO_USER_INPUTÚUSER_INPUT_MUTATIONr9   r"   r#   r$   r   r   s   s6   „ Ù“&€KÙ“&€KÙ“f€OÙ ›FÐÙ!›VÐÙ›&ÐÙ‹F�Er#   r   c                   ó8   — e Zd ZU eed<   eed<   ee   ed<   d„ Zy)r   r;   r<   r=   c           
      ó˜   — t        | j                  t        t        t        t
        t        t        t        f«      sJ | j                  «       ‚y ©N)	r@   r<   r   r   r   r   r   r'   r   rB   s    r$   rD   zOutputSpec.__post_init__ƒ   sC   € ÜØ�H‰HäÜÜ ÜÜ ÜÜ!ðô
ð 	ð �8‰8ó	ñ 
r#   N)	r   r   r   r   r!   rE   r   r    rD   r"   r#   r$   r   r   }   s   … à
ÓØ	ÓØ�S‰MÓór#   r   c                   ó@   — e Zd ZU eeef   ed<   eeef   ed<   eed<   y)r   Úgradients_to_parametersÚgradients_to_user_inputsÚloss_outputN)r   r   r   Údictr    r!   r"   r#   r$   r   r   ’   s$   … à! # s (™^Ó+Ø" 3¨ 8™nÓ,ØÔr#   r   c            	       óp  — e Zd ZU dZee   ed<   ee   ed<   ede	e
   fd„«       Zede	e
   fd„«       Zede	e
   fd„«       Zede	e
   fd„«       Zede	e
   fd	„«       Zede	eeeed
e
f      fd„«       Zede	eeeed
e
f      fd„«       Zedee
e
f   fd„«       Zedee
e
f   fd„«       Zedee
e
f   fd„«       Zedee
e
f   fd„«       Zedee
e
f   fd„«       Zedee
e
f   fd„«       Zedee   fd„«       Zedeeee
f      fd„«       Z ede	e
   fd„«       Z!ede	e
   fd„«       Z"dd„Z#de
de
fd„Z$dd„Z%y
)r   a·  
    :class:`ExportGraphSignature` models the input/output signature of Export Graph,
    which is a fx.Graph with stronger invariants gurantees.

    Export Graph is functional and does not access "states" like parameters
    or buffers within the graph via ``getattr`` nodes. Instead, :func:`export`
    gurantees that parameters, buffers, and constant tensors are lifted out of
    the graph as inputs.  Similarly, any mutations to buffers are not included
    in the graph either, instead the updated values of mutated buffers are
    modeled as additional outputs of Export Graph.

    The ordering of all inputs and outputs are::

        Inputs = [*parameters_buffers_constant_tensors, *flattened_user_inputs]
        Outputs = [*mutated_inputs, *flattened_user_outputs]

    e.g. If following module is exported::

        class CustomModule(nn.Module):
            def __init__(self) -> None:
                super(CustomModule, self).__init__()

                # Define a parameter
                self.my_parameter = nn.Parameter(torch.tensor(2.0))

                # Define two buffers
                self.register_buffer('my_buffer1', torch.tensor(3.0))
                self.register_buffer('my_buffer2', torch.tensor(4.0))

            def forward(self, x1, x2):
                # Use the parameter, buffers, and both inputs in the forward method
                output = (x1 + self.my_parameter) * self.my_buffer1 + x2 * self.my_buffer2

                # Mutate one of the buffers (e.g., increment it by 1)
                self.my_buffer2.add_(1.0) # In-place addition

                return output

    Resulting Graph would be::

        graph():
            %arg0_1 := placeholder[target=arg0_1]
            %arg1_1 := placeholder[target=arg1_1]
            %arg2_1 := placeholder[target=arg2_1]
            %arg3_1 := placeholder[target=arg3_1]
            %arg4_1 := placeholder[target=arg4_1]
            %add_tensor := call_function[target=torch.ops.aten.add.Tensor](args = (%arg3_1, %arg0_1), kwargs = {})
            %mul_tensor := call_function[target=torch.ops.aten.mul.Tensor](args = (%add_tensor, %arg1_1), kwargs = {})
            %mul_tensor_1 := call_function[target=torch.ops.aten.mul.Tensor](args = (%arg4_1, %arg2_1), kwargs = {})
            %add_tensor_1 := call_function[target=torch.ops.aten.add.Tensor](args = (%mul_tensor, %mul_tensor_1), kwargs = {})
            %add_tensor_2 := call_function[target=torch.ops.aten.add.Tensor](args = (%arg2_1, 1.0), kwargs = {})
            return (add_tensor_2, add_tensor_1)

    Resulting ExportGraphSignature would be::

        ExportGraphSignature(
            input_specs=[
                InputSpec(kind=<InputKind.PARAMETER: 2>, arg=TensorArgument(name='arg0_1'), target='my_parameter'),
                InputSpec(kind=<InputKind.BUFFER: 3>, arg=TensorArgument(name='arg1_1'), target='my_buffer1'),
                InputSpec(kind=<InputKind.BUFFER: 3>, arg=TensorArgument(name='arg2_1'), target='my_buffer2'),
                InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg3_1'), target=None),
                InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg4_1'), target=None)
            ],
            output_specs=[
                OutputSpec(kind=<OutputKind.BUFFER_MUTATION: 3>, arg=TensorArgument(name='add_2'), target='my_buffer2'),
                OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='add_1'), target=None)
            ]
        )
    Úinput_specsÚoutput_specsÚreturnc                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó¢   K  — | ]G  }|j                   t        j                  k(  r(t        |j                  t
        «      r|j                  –— ŒI y ­wrO   )r;   r   r5   r@   r=   r    ©Ú.0Úss     r$   ú	<genexpr>z2ExportGraphSignature.parameters.<locals>.<genexpr>ç   s<   è ø€ ò 
àØ�v‰vœ×,Ñ,Ò,Ü˜!Ÿ(™(¤CÔ(ð �H�Hñ
ùó   ‚AA©ÚtuplerV   rB   s    r$   Ú
parameterszExportGraphSignature.parameterså   ó"   € äñ 
à×%Ñ%ô
ó 
ð 	
r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó¢   K  — | ]G  }|j                   t        j                  k(  r(t        |j                  t
        «      r|j                  –— ŒI y ­wrO   )r;   r   r6   r@   r=   r    r[   s     r$   r^   z/ExportGraphSignature.buffers.<locals>.<genexpr>ñ   s<   è ø€ ò 
àØ�v‰vœ×)Ñ)Ò)Ü˜!Ÿ(™(¤CÔ(ð �H�Hñ
ùr_   r`   rB   s    r$   ÚbufferszExportGraphSignature.buffersï   rc   r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó¾   K  — | ]U  }|j                   t        j                  k(  r6|j                  d u r(t	        |j
                  t        «      r|j
                  –— ŒW y­w)FN)r;   r   r6   r>   r@   r=   r    r[   s     r$   r^   z>ExportGraphSignature.non_persistent_buffers.<locals>.<genexpr>ú   sH   è ø€ ò 
àØ�v‰vœ×)Ñ)Ò)Ø�|‰|˜uÑ$Ü˜!Ÿ(™(¤CÔ(ð	 �H�Hñ
ùs   ‚AAr`   rB   s    r$   Únon_persistent_buffersz+ExportGraphSignature.non_persistent_buffersø   s"   € äñ 
à×%Ñ%ô
ó 
ð 	
r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó¢   K  — | ]G  }|j                   t        j                  k(  r(t        |j                  t
        «      r|j                  –— ŒI y ­wrO   )r;   r   r7   r@   r=   r    r[   s     r$   r^   z?ExportGraphSignature.lifted_tensor_constants.<locals>.<genexpr>  s<   è ø€ ò 
àØ�v‰vœ×2Ñ2Ò2Ü˜!Ÿ(™(¤CÔ(ð �H�Hñ
ùr_   r`   rB   s    r$   Úlifted_tensor_constantsz,ExportGraphSignature.lifted_tensor_constants  rc   r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó¢   K  — | ]G  }|j                   t        j                  k(  r(t        |j                  t
        «      r|j                  –— ŒI y ­wrO   )r;   r   r8   r@   r=   r    r[   s     r$   r^   z:ExportGraphSignature.lifted_custom_objs.<locals>.<genexpr>  s<   è ø€ ò 
àØ�v‰vœ×-Ñ-Ò-Ü˜!Ÿ(™(¤CÔ(ð �H�Hñ
ùr_   r`   rB   s    r$   Úlifted_custom_objsz'ExportGraphSignature.lifted_custom_objs  rc   r#   Nc           	      óÒ  — g }| j                   D ]Ì  }|j                  t        j                  k7  rŒ!t	        |j
                  t        t        t        t        t        f«      r&|j                  |j
                  j                  «       Œvt	        |j
                  t        «      r&|j                  |j
                  j                  «       Œ¶t        |j
                  › d�«      ‚ t!        |«      S )Nz is not a valid user inputs)rV   r;   r   r4   r@   r<   r   r   r   r   r   Úappendr   r   r/   ÚRuntimeErrorra   )rC   Úuser_inputsr]   s      r$   rs   z ExportGraphSignature.user_inputs  s·   € à@BˆØ×!Ñ!ò 	JˆAØ�v‰vœ×-Ñ-Ò-ØäØ—‘ä"Ü"Ü$Ü#Ü%ðô	ð ×"Ñ" 1§5¡5§:¡:Õ.Ü˜AŸE™EÔ#3Ô4Ø×"Ñ" 1§5¡5§;¡;Õ/ä" a§e¡e WÐ,GÐ#HÓIÐIð%	Jô& �[Ó!Ð!r#   c                 ój  — g }| j                   D �]  }|j                  t        j                  t        j                  fvrŒ1t        |j                  t        t        t        t        f«      r&|j                  |j                  j                  «       Œ�t        |j                  t        «      r&|j                  |j                  j                  «       ŒÁt        |j                  t        «      r'|j                  |j                  j                  «       �Œt!        |j                  › d�«      ‚ t#        |«      S )Nz is not a valid user output)rW   r;   r   rG   rH   r@   r<   r   r   r   r   rq   r   r   r/   r   rr   ra   )rC   Úuser_outputsr]   s      r$   ru   z!ExportGraphSignature.user_outputs0  sè   € àACˆØ×"Ñ"ó 	JˆAØ�v‰vÜ×&Ñ&Ü×&Ñ&ðñ ð äØ—‘Ü¤Ô1AÄ?ÐSôð ×#Ñ# A§E¡E§J¡JÕ/Ü˜AŸE™EÔ#3Ô4Ø×#Ñ# A§E¡E§K¡KÕ0Ü˜AŸE™EÔ#4Ô5Ø×#Ñ# A§E¡E§J¡JÖ/ä" a§e¡e WÐ,GÐ#HÓIÐIð#	Jô$ �\Ó"Ð"r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó  K  — | ]w  }|j                   t        j                  k(  rXt        |j                  t
        «      r>t        |j                  t        «      r$|j                  j                  |j                  f–— Œy y ­wrO   )	r;   r   r5   r@   r<   r   r=   r    r   r[   s     r$   r^   z<ExportGraphSignature.inputs_to_parameters.<locals>.<genexpr>K  sW   è ø€ ò 
àØ�v‰vœ×,Ñ,Ò,Ü˜1Ÿ5™5¤.Ô1Ü˜1Ÿ8™8¤SÔ)ð	 �U‰U�Z‰Z˜Ÿ™Ô"ñ
ùó   ‚A=A?©Ú_immutable_dictrV   rB   s    r$   Úinputs_to_parametersz)ExportGraphSignature.inputs_to_parametersI  ó"   € äñ 
à×%Ñ%ô
ó 
ð 	
r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó  K  — | ]w  }|j                   t        j                  k(  rXt        |j                  t
        «      r>t        |j                  t        «      r$|j                  j                  |j                  f–— Œy y ­wrO   )	r;   r   r6   r@   r<   r   r=   r    r   r[   s     r$   r^   z9ExportGraphSignature.inputs_to_buffers.<locals>.<genexpr>W  sW   è ø€ ò 
àØ�v‰vœ×)Ñ)Ò)Ü˜1Ÿ5™5¤.Ô1Ü˜1Ÿ8™8¤SÔ)ð	 �U‰U�Z‰Z˜Ÿ™Ô"ñ
ùrx   ry   rB   s    r$   Úinputs_to_buffersz&ExportGraphSignature.inputs_to_buffersU  r|   r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó  K  — | ]w  }|j                   t        j                  k(  rXt        |j                  t
        «      r>t        |j                  t        «      r$|j                  j                  |j                  f–— Œy y ­wrO   )	r;   r   rI   r@   r<   r   r=   r    r   r[   s     r$   r^   z9ExportGraphSignature.buffers_to_mutate.<locals>.<genexpr>c  sW   è ø€ ò 
àØ�v‰vœ×3Ñ3Ò3Ü˜1Ÿ5™5¤.Ô1Ü˜1Ÿ8™8¤SÔ)ð	 �U‰U�Z‰Z˜Ÿ™Ô"ñ
ùrx   ©rz   rW   rB   s    r$   Úbuffers_to_mutatez&ExportGraphSignature.buffers_to_mutatea  ó"   € äñ 
à×&Ñ&ô
ó 
ð 	
r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó  K  — | ]w  }|j                   t        j                  k(  rXt        |j                  t
        «      r>t        |j                  t        «      r$|j                  j                  |j                  f–— Œy y ­wrO   )	r;   r   rL   r@   r<   r   r=   r    r   r[   s     r$   r^   z=ExportGraphSignature.user_inputs_to_mutate.<locals>.<genexpr>m  sW   è ø€ ò 
àØ�v‰vœ×7Ñ7Ò7Ü˜1Ÿ5™5¤.Ô1Ü˜1Ÿ8™8¤SÔ)ð	 �U‰U�Z‰Z˜Ÿ™Ô"ñ
ùrx   r‚   rB   s    r$   Úuser_inputs_to_mutatez*ExportGraphSignature.user_inputs_to_mutatek  r„   r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó  K  — | ]w  }|j                   t        j                  k(  rXt        |j                  t
        «      r>t        |j                  t        «      r$|j                  j                  |j                  f–— Œy y ­wrO   )	r;   r   r7   r@   r<   r   r=   r    r   r[   s     r$   r^   zIExportGraphSignature.inputs_to_lifted_tensor_constants.<locals>.<genexpr>x  sW   è ø€ ò 
àØ�v‰vœ×2Ñ2Ò2Ü˜1Ÿ5™5¤.Ô1Ü˜1Ÿ8™8¤SÔ)ð	 �U‰U�Z‰Z˜Ÿ™Ô"ñ
ùrx   ry   rB   s    r$   Ú!inputs_to_lifted_tensor_constantsz6ExportGraphSignature.inputs_to_lifted_tensor_constantsv  r|   r#   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó  K  — | ]w  }|j                   t        j                  k(  rXt        |j                  t
        «      r>t        |j                  t        «      r$|j                  j                  |j                  f–— Œy y ­wrO   )	r;   r   r8   r@   r<   r   r=   r    r   r[   s     r$   r^   zDExportGraphSignature.inputs_to_lifted_custom_objs.<locals>.<genexpr>‚  sX   è ø€ ò 
àØ�v‰vœ×-Ñ-Ò-Ü˜1Ÿ5™5Ô"3Ô4Ü˜1Ÿ8™8¤SÔ)ð	 �U‰U�Z‰Z˜Ÿ™Ô"ñ
ùrx   ry   rB   s    r$   Úinputs_to_lifted_custom_objsz1ExportGraphSignature.inputs_to_lifted_custom_objs€  r|   r#   c                 óâ  — d }i }i }| j                   D �]I  }|j                  t        j                  k(  r7|�J ‚t	        |j
                  t        «      sJ ‚|j
                  j                  }ŒX|j                  t        j                  k(  r\t	        |j                  t        «      sJ ‚t	        |j
                  t        «      sJ ‚|j                  ||j
                  j                  <   ŒÑ|j                  t        j                  k(  sŒït	        |j                  t        «      sJ ‚t	        |j
                  t        «      sJ ‚|j                  ||j
                  j                  <   �ŒL |€y t        |||¬«      S )N)rS   rQ   rR   )rW   r;   r   rH   r@   r<   r   r   rJ   r=   r    rK   r   )rC   rS   rQ   rR   Úspecs        r$   Úbackward_signaturez'ExportGraphSignature.backward_signatureŠ  s,  € àˆØ24ÐØ35Ð Ø×%Ñ%ó 	FˆDØ�y‰yœJ×2Ñ2Ò2Ø"Ð*Ð*Ð*Ü! $§(¡(¬NÔ;Ð;Ð;Ø"Ÿh™hŸm™m‘Ø—‘œj×>Ñ>Ò>Ü! $§+¡+¬sÔ3Ð3Ð3Ü! $§(¡(¬NÔ;Ð;Ð;Ø9=¿¹Ð'¨¯©¯©Ò6Ø—‘œj×?Ñ?Ó?Ü! $§+¡+¬sÔ3Ð3Ð3Ü! $§(¡(¬NÔ;Ð;Ð;Ø:>¿+¹+Ð(¨¯©¯©Ó7ð	Fð ÐØä&Ø#Ø$;Ø%=ô
ð 	
r#   c                  ó   — y rO   r"   rB   s    r$   Úassertion_dep_tokenz(ExportGraphSignature.assertion_dep_token©  s   € àr#   c                 óü   — g }| j                   D ]a  }|j                  t        j                  k(  sŒ!t	        |j
                  t        «      sJ ‚|j                  |j
                  j                  «       Œc t        |«      S rO   )
rV   r;   r   r9   r@   r<   r'   rq   r   ra   )rC   Úinput_tokensr]   s      r$   r”   z!ExportGraphSignature.input_tokens­  sc   € àˆØ×!Ñ!ò 	0ˆAØ�v‰vœŸ™Ó(Ü! !§%¡%¬Ô7Ð7Ð7Ø×#Ñ# A§E¡E§J¡JÕ/ð	0ô �\Ó"Ð"r#   c                 óü   — g }| j                   D ]a  }|j                  t        j                  k(  sŒ!t	        |j
                  t        «      sJ ‚|j                  |j
                  j                  «       Œc t        |«      S rO   )
rW   r;   r   r9   r@   r<   r'   rq   r   ra   )rC   Úoutput_tokensr]   s      r$   r–   z"ExportGraphSignature.output_tokens¶  se   € àˆØ×"Ñ"ò 	1ˆAØ�v‰vœ×)Ñ)Ó)Ü! !§%¡%¬Ô7Ð7Ð7Ø×$Ñ$ Q§U¡U§Z¡ZÕ0ð	1ô �]Ó#Ð#r#   c                 óæ   — | j                   }|€y t        |«      dk(  sJ ‚t        t        |j	                  «       «      «      }t        | j
                  «      t        | j                  «      z   |k(  sJ ‚y )Né   )r’   ÚlenÚnextÚiterÚkeysru   rƒ   )rC   r’   Úassertion_dep_token_indexs      r$   rD   z"ExportGraphSignature.__post_init__¿  su   € Ø"×6Ñ6ÐØÐ&ØÜÐ&Ó'¨1Ò,Ð,Ð,Ü$(¬Ð.A×.FÑ.FÓ.HÓ)IÓ$JÐ!ä�×!Ñ!Ó"¤S¨×)?Ñ)?Ó%@Ñ@Ø(ò)ð	
ñ)r#   ÚoldÚnewc                 óØ  — t        |t        «      sJ ‚t        |t        «      sJ ‚t        t        t        t
        t        t        f}| j                  D ]D  }t        |j                  |«      sŒ|j                  j                  |k(  sŒ4||j                  _
        ŒF | j                  D ]D  }t        |j                  |«      sŒ|j                  j                  |k(  sŒ4||j                  _
        ŒF y)zR
        Replace all uses of the old name with new name in the signature.
        N)r@   r    r   r   r   r   r   r'   rW   r<   r   rV   )rC   rž   rŸ   Ú	arg_typesÚoÚis         r$   Úreplace_all_usesz%ExportGraphSignature.replace_all_usesÊ  s½   € ô ˜#œsÔ#Ð#Ð#Ü˜#œsÔ#Ð#Ð#äÜÜÜÜÜð
ˆ	ð ×"Ñ"ò 	%ˆAÜ˜!Ÿ%™% Õ+Ø—5‘5—:‘: Ó$Ø!$�A—E‘E•Jð	%ð ×!Ñ!ò 	%ˆAÜ˜!Ÿ%™% Õ+Ø—5‘5—:‘: Ó$Ø!$�A—E‘E•Jñ	%r#   c                 ó   ‡ ‡— ˆˆ fd„}|S )Nc                 óº   •— |j                   dk(  r‰j                  | j                  |«       ‰r-| j                   dk(  r‰j                  | j                  |«       y y y )NÚoutputÚplaceholder)Úopr¤   r   )rž   rŸ   ÚuserÚreplace_inputsrC   s      €€r$   Ú_z0ExportGraphSignature.get_replace_hook.<locals>._â  sL   ø€ Ø�w‰w˜(Ò"Ø×%Ñ% c§h¡h°Ô4Ù #§&¡&¨MÒ"9Ø×%Ñ% c§h¡h°Õ4ð #:ˆ~r#   r"   )rC   r«   r¬   s   `` r$   Úget_replace_hookz%ExportGraphSignature.get_replace_hooká  s   ù€ õ	5ð ˆr#   )rX   N)F)&r   r   r   Ú__doc__Úlistr   r!   r   Úpropertyr   r    rb   rf   ri   rl   ro   r	   r0   r1   r2   rs   ru   r   r{   r   rƒ   r‡   rŠ   r�   r   r   r�   r’   r”   r–   rD   r¤   r­   r"   r#   r$   r   r   ™   s˜  … ñDðL �i‘Ó Ø�zÑ"Ó"ð ð
˜J s™Oò 
ó ð
ð ð
˜ C™ò 
ó ð
ð ð
¨
°3©ò 
ó ð
ð ð
¨°C©ò 
ó ð
ð ð
 J¨s¡Oò 
ó ð
ð ð"˜Z¨¨c°5¸$ÀÀcÐ.IÑ(JÑKò "ó ð"ð2 ð#˜j¨¨s°E¸4ÀÀsÐ/JÑ)KÑLò #ó ð#ð0 ð
 g¨c°3¨hÑ&7ò 
ó ð
ð ð
 7¨3°¨8Ñ#4ò 
ó ð
ð ð
 7¨3°¨8Ñ#4ò 
ó ð
ð ð
 w¨s°C¨xÑ'8ò 
ó ð
ð ð
°7¸3À¸8Ñ3Dò 
ó ð
ð ð
¨g°c¸3°hÑ.?ò 
ó ð
ð ð
 HÐ-DÑ$Eò 
ó ð
ð< ð X¨g°c¸3°hÑ.?Ñ%@ò ó ðð ð#˜j¨™oò #ó ð#ð ð$˜z¨#™ò $ó ð$ó	
ð% Cð %¨có %ô.r#   r   c                 ó0   — ddl m}  |t        | «      «      S )zœ
    Creates a mapping where items cannot be added, deleted, or updated.
    NOTE: The immutability is shallow (like tuple is an immutable collection).
    r   )ÚMappingProxyType)Útypesr²   rT   )Úitemsr²   s     r$   rz   rz   ë  s   € õ
 'áœD ›KÓ(Ð(r#   rX   c           
      óÄ  — ddl m}m}m}m} ddlm} t        | t        t        t        t        d «      t        f«      rt        d| ¬«      S d| j                  v s
J | › d�«       ‚| j                  d   }| j                  |v rt!        | j                  ¬«      S t#        |«      rt%        | j                  ¬«      S t        ||«      rt'        | j                  ¬«      S t        ||«      rt)        | j                  ¬«      S t        ||«      rt+        | j                  ¬«      S t        ||«      r3t-        | j                  |j/                  «       j1                  «       ¬	«      S t        ||«      r"t-        | j                  |j2                  |¬
«      S t        |t        t        t        t        t        d «      f«      rt        | j                  |¬«      S t5        dt        |«      › d�«      ‚)Nr   )ÚScriptObjectÚSymBoolÚSymFloatÚSymIntr
   Ú )r   r/   Úvalz8 is not a constant or a node with a 'val' metadata field)r   )r   r,   )r   r,   r-   z*Encountered an unsupported object of type z0 while writing the metadata for exported program)Útorchr¶   r·   r¸   r¹   Ú"torch._library.fake_class_registryr   r@   r0   r2   r1   rA   r    r   Úmetar   r'   r   r   r   r   r   r   Ú_typeÚqualified_nameÚscript_class_nameÚAssertionError)ÚnodeÚtoken_namesr¶   r·   r¸   r¹   r   r»   s           r$   Ú_make_argument_specrÅ   õ  s…  € ß=Ó=ÝCä�$œœd¤E¬4°«:´sÐ;Ô<ä R¨tÔ4Ð4ð 	�—‘ÑðIà
ˆÐGÐHóIØà
�)‰)�EÑ
€CØ‡y�y�KÑÜ $§)¡)Ô,Ð,Ü	�ŒÜ 4§9¡9Ô-Ð-Ü	�C˜Ô	 Ü 4§9¡9Ô-Ð-Ü	�C˜Ô	"Ü T§Y¡YÔ/Ð/Ü	�C˜Ô	!Ü D§I¡IÔ.Ð.Ü	�C˜Ô	&Ü  d§i¡i¸3¿9¹9»;×;UÑ;UÓ;WÔXÐXÜ	�CÐ)Ô	*Ü Ø—‘ c×&;Ñ&;Àcô
ð 	
ô 
�Cœ#œt¤S¬%´°d³Ð<Ô	=Ü T§Y¡Y°cÔ:Ð:äØ8¼¸c»¸ð D>ð ?ó
ð 	
r#   Úgraph_signaturer   Úgmztorch.fx.GraphModuleri   c           	      ó  ‡‡‡‡‡‡‡‡‡‡‡— ddl m} | j                  d u}t        | j                  «      Š| j
                  Š| j                  Št        | j                  «      Š| j                  Š| j                  Š|r| j                  j                  ni Š|r| j                  j                  ni Š|r| j                  j                  nd Š| j                  }| j                  Š|j                  j                   D �cg c]  }|j"                  dk(  rt%        ||«      ‘Œ }}|j'                  t)        t+        t-        |j                  j                   «      «      «      j.                  «      D �cg c]  }t%        |‰«      ‘Œ }}dt0        dt2        fˆˆˆˆfd„}	dt4        dt0        dt6        fˆˆˆˆˆˆˆfd	„}
|D �cg c]
  } |	|«      ‘Œ }}t9        |«      D ��cg c]  \  }} |
||«      ‘Œ }}}t;        ||¬
«      S c c}w c c}w c c}w c c}}w )Nr   )Ú_pytreer¨   ÚinprX   c                 óÀ  •— t        | t        «      rt        t        j                  | d ¬«      S t        | t
        «      st        t        j                  | d ¬«      S | j                  }|‰v rt        t        j                  | d ¬«      S |‰v rt        t        j                  | ‰|   ¬«      S |‰v r%t        t        j                  | ‰|   ‰|   ‰v¬«      S t        d|› �«      ‚)N©r;   r<   r=   )r;   r<   r=   r>   zUnknown tensor input kind: )r@   r'   r   r   r9   r   r4   r   r5   r6   rÂ   )rÊ   r   r   r{   ri   rs   s     €€€€r$   Úto_input_specz9_convert_to_export_graph_signature.<locals>.to_input_spec:  sÞ   ø€ Ü�cœ=Ô)Ü¤)§/¡/°sÀ4ÔHÐHä˜#œ~Ô.Ü¤)×"6Ñ"6¸CÈÔMÐMØ�x‰xˆØ�;ÑÜ¤)×"6Ñ"6¸CÈÔMÐMØÐ)Ñ)ÜÜ×(Ñ(ØØ+¨DÑ1ôð ð
 Ð&Ñ&ÜÜ×%Ñ%ØØ(¨Ñ.Ø-¨dÑ3Ð;QÐQô	ð ô !Ð#>¸t¸fÐ!EÓFÐFr#   Úidxr¢   c                 óê  •— t        |t        «      rt        t        j                  |d ¬«      S t        |t
        «      st        t        j                  |d ¬«      S |j                  }| t        ‰«      t        ‰«      z   t        ‰«      z   k  rT|‰v rt        t        j                  |‰|   ¬«      S |‰v rt        t        j                  |‰|   ¬«      S t        d|› �«      ‚|‰	v rt        t        j                  |d ¬«      S |‰v rt        t        j                  |‰|   ¬«      S |‰v rt        t        j                  |‰|   ¬«      S |‰k(  rt        t        j                  |d ¬«      S t        d|› �«      ‚)NrÌ   zUnknown tensor mutation kind: zUnknown tensor output kind: )r@   r'   r   r   r9   r   rG   r   r™   rI   rL   rÂ   rJ   rK   rH   )
rÎ   r¢   r   Úbuffer_mutationsÚgrad_paramsÚgrad_user_inputsrS   r–   Úuser_input_mutationsru   s
      €€€€€€€r$   Úto_output_specz:_convert_to_export_graph_signature.<locals>.to_output_specS  s~  ø€ Ü�aœÔ'Ü¤:×#3Ñ#3¸À4ÔHÐHä˜!œ^Ô,Ü¤:×#9Ñ#9¸qÈÔNÐNØ�v‰vˆØ”Ð%Ó&¬Ð-AÓ)BÑBÄSÈÓEWÑWÒWØÐ'Ñ'Ü!Ü#×3Ñ3ØØ+¨DÑ1ôð ð
 Ð-Ñ-Ü!Ü#×7Ñ7ØØ/°Ñ5ôð ô %Ð'EÀdÀVÐ%LÓMÐMà�|Ñ#Ü!¤z×'=Ñ'=À1ÈTÔRÐRà˜Ñ$Ü!Ü#×9Ñ9ØØ& tÑ,ôð ð
 Ð)Ñ)Ü!Ü#×:Ñ:ØØ+¨DÑ1ôð ð
 ˜Ò$Ü!¤z×'=Ñ'=À1ÈTÔRÐRô %Ð'CÀDÀ6Ð%JÓKÐKr#   )rV   rW   )Útorch.utilsrÉ   r�   Úsetrs   r{   r   ru   rƒ   r‡   Úgradients_to_parameterrR   rS   r”   r–   ÚgraphÚnodesr©   rÅ   Útree_leavesrš   r›   ÚreversedÚargsrE   r   r0   r   Ú	enumerater   )rÆ   rÇ   ri   ÚpytreeÚis_jointr”   rÃ   ÚinputsÚoutputsrÍ   rÔ   rÊ   rV   rÎ   r¢   rW   rÐ   rÑ   rÒ   r   r{   rS   r–   rÓ   rs   ru   s     `             @@@@@@@@@@r$   Ú"_convert_to_export_graph_signaturerâ     së  ÿú€ õ
 .à×1Ñ1¸Ð=€Hô �o×1Ñ1Ó2€KØ*×?Ñ?ÐØ'×9Ñ9ÐÜ�×3Ñ3Ó4€LØ&×8Ñ8ÐØ*×@Ñ@ÐÙOW�/×4Ñ4×KÒKÐ]_€KÙV^�×9Ñ9×RÒRÐdfÐÙDL�/×4Ñ4×@Ò@ÐRV€KØ"×/Ñ/€LØ#×1Ñ1€Mð —H‘H—N‘NöàØ�7‰7�mÒ#ô 	˜D ,Õ/ð€Fð ð ×&Ñ&¤t¬D´¸"¿(¹(¿.¹.Ó1IÓ,JÓ'K×'PÑ'PÓQöàô 	˜D -Õ0ð€Gð ð
Gœ<ð G¬I÷ Gð Gð2*LœCð *L¤Lð *L´Z÷ *Ló *LðX 28Ö8¨#‘= Õ%Ð8€KÐ8Ü9BÀ7Ó9K×L©v¨s°A‘N 3¨Õ*ÐL€LÑLÜ¨KÀlÔSÐSùòcùò
ùòT 9ùÛLs   Ã8"G6Å(G;Æ4H ÇH)'ÚdataclassesÚcollections.abcr   r   Úenumr   r   Útypingr   r   r	   r½   r   Útorch._subclasses.fake_tensorr   r¼   Ú&torch._functorch._aot_autograd.schemasr   Ú__all__Ú	dataclassr   r'   r   r   r   r   r   rE   r   r   r   r   r   r   rz   rÅ   rÖ   r    râ   r"   r#   r$   ú<module>rë      s  ðã ß /ß ß 1Ñ 1å ?Ý 1ñ ÛÝEò€ð  ×Ñ÷ð ó ðð ×Ñ÷ð ó ðð ×Ñ÷ð ó ðð ×Ñ÷ð ó ðð ×Ñ÷ð ó ðð ×Ñ÷0ð 0ó ð0ð ×Ñ÷.ð .ó ð.ð
 ØØØØØØØðñ€ô�ô ð ×Ñ÷#ð #ó ð#ô2�ô ð ×Ñ÷ð ó ðð( ×Ñ÷ð ó ðð ×Ñ÷Nð Nó ðNòb
)ð"
¨ló "
ðJgTØ%ðgTàðgTð   ™HðgTð ô	gTr#   