
    9ic                         S SK r S SKJrJr  S SKJrJr  S SKJrJ	r	J
r
  S SKJr  S SKJr  \	(       a
  S SKrS SKJr  / SQr\ R&                   " S	 S
5      5       r\ R&                   " S S5      5       r\ R&                   " S S5      5       r\ R&                   " S S5      5       r\ R&                   " S S5      5       r\ R&                   " S S5      5       r\ R&                   " S S5      5       r\
\\\\\\\4   r " S S\5      r\ R&                   " S S5      5       r " S S\5      r\ R&                   " S S5      5       r\ R&                   " S S 5      5       r \ R&                   " S! S"5      5       r!S# r"S$\4S% jr#S&S'S(S)S*\$\%   S$S"4S+ jr&g),    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                        \ rS rSr% \\S'   Srg)r      name N__name__
__module____qualname____firstlineno__str__annotations____static_attributes__r       \/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torch/export/graph_signature.pyr   r          
Ir&   r   c                        \ rS rSr% \\S'   Srg)TokenArgument$   r   r   Nr   r   r&   r'   r*   r*   $   r(   r&   r*   c                        \ rS rSr% \\S'   Srg)r   )   r   r   Nr   r   r&   r'   r   r   )   r(   r&   r   c                        \ rS rSr% \\S'   Srg)r   .   r   r   Nr   r   r&   r'   r   r   .   r(   r&   r   c                        \ rS rSr% \\S'   Srg)r   3   r   r   Nr   r   r&   r'   r   r   3   r(   r&   r   c                   >    \ rS rSr% \\S'   \\S'   Sr\\   \S'   Sr	g)r   8   r   	class_fqnNfake_valr   )
r   r    r!   r"   r#   r$   r5   r   r   r%   r   r&   r'   r   r   8   s    
IN+/Hh'(/r&   r   c                   :    \ rS rSr% \\S'   \\\\	\S4   \S'   Sr
g)r   ?   r   Nvaluer   )r   r    r!   r"   r#   r$   r	   intfloatboolr%   r   r&   r'   r   r   ?   s    
IeT3,--r&   r   c                   h    \ rS rSr\" 5       r\" 5       r\" 5       r\" 5       r\" 5       r	\" 5       r
Srg)r   P   r   N)r   r    r!   r"   r   
USER_INPUT	PARAMETERBUFFERCONSTANT_TENSOR
CUSTOM_OBJTOKENr%   r   r&   r'   r   r   P   s,    JIVFfOJFEr&   r   c                   Z    \ rS rSr% \\S'   \\S'   \\   \S'   Sr	\\
   \S'   S rS rS	rg)
r   Y   kindargtargetN
persistentc           
         U R                   [        R                  :X  a  U R                  c   S5       e[	        U R
                  [        [        [        [        [        [        [        45      (       d   S[        U R
                  5       35       eg )Nz,Failed to specify persistent flag on BUFFER.zgot )rF   r   r@   rI   
isinstancerG   r   r   r   r   r   r   r*   typeselfs    r'   __post_init__InputSpec.__post_init__`   s    99	(((??. >. HH  !
 
 	# $txx.!"	# 
r&   c                    U R                   c  SOSU R                    S3nU R                  c  SOSU R                   3n[        U R                  R                  5       S[        U R
                  R                  5       U U 3$ )N 	 target=''z persistent=: )rH   rI   r#   rG   r   rF   )rN   rH   rI   s      r'   __str__InputSpec.__str__r   sp    {{*)DKK=0J??2R,tFW8X
dhhmm$%RDIINN(;'<VHZLQQr&   r   )r   r    r!   r"   r   r$   ArgumentSpecr   r#   rI   r;   rO   rV   r%   r   r&   r'   r   r   Y   s0    
O	SM!%J%#$Rr&   r   c                       \ rS rSr\" 5       r\" 5       r\" 5       r\" 5       r\" 5       r	\" 5       r
\" 5       r\" 5       rSrg)r   x   r   N)r   r    r!   r"   r   USER_OUTPUTLOSS_OUTPUTBUFFER_MUTATIONPARAMETER_MUTATIONGRADIENT_TO_PARAMETERGRADIENT_TO_USER_INPUTUSER_INPUT_MUTATIONrC   r%   r   r&   r'   r   r   x   s>    &K&KfO F!V&FEr&   r   c                   F    \ rS rSr% \\S'   \\S'   \\   \S'   S r	S r
Srg)	r      rF   rG   rH   c           
          [        U R                  [        [        [        [
        [        [        [        45      (       d   U R                  5       eg N)	rK   rG   r   r   r   r   r   r*   r   rM   s    r'   rO   OutputSpec.__post_init__   sH    HH  !
 
 	 88	 
r&   c                     U R                   c  SOSU R                    S3n[        U R                  R                  5       S[        U R                  R                  5       U 3$ )NrR   rS   rT   rU   )rH   r#   rG   r   rF   )rN   rH   s     r'   rV   OutputSpec.__str__   sP    {{*)DKK=0Jdhhmm$%RDIINN(;'<VHEEr&   r   N)r   r    r!   r"   r   r$   rX   r   r#   rO   rV   r%   r   r&   r'   r   r      s#    
	SMFr&   r   c                   H    \ rS rSr% \\\4   \S'   \\\4   \S'   \\S'   Srg)r      gradients_to_parametersgradients_to_user_inputsloss_outputr   N)r   r    r!   r"   dictr#   r$   r%   r   r&   r'   r   r      s$    !#s(^+"38n,r&   r   c            	          \ rS rSr% Sr\\   \S'   \\   \S'   \	S\
\   4S j5       r\	S\
\   4S j5       r\	S\
\   4S j5       r\	S\
\   4S	 j5       r\	S\
\   4S
 j5       r\	S\
\\\\S\4      4S j5       r\	S\
\\\\S\4      4S j5       r\	S\\\4   4S j5       r\	S\\\4   4S j5       r\	S\\\4   4S j5       r\	S\\\4   4S j5       r\	S\\\4   4S j5       r\	S\\\4   4S j5       r\	S\\\4   4S j5       r\	S\\    4S j5       r!\	S\\\\4      4S j5       r"\	S\
\   4S j5       r#\	S\
\   4S j5       r$S S jr%S\S\4S jr&S!S jr'S r(Sr)g)"r      a  
:class:`ExportGraphSignature` models the input/output signature of Export Graph,
which is a fx.Graph with stronger invariants guarantees.

Export Graph is functional and does not access "states" like parameters
or buffers within the graph via ``getattr`` nodes. Instead, :func:`export`
guarantees 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


    mod = CustomModule()
    ep = torch.export.export(mod, (torch.tensor(1.0), torch.tensor(2.0)))

Resulting Graph is non-functional::

    graph():
        %p_my_parameter : [num_users=1] = placeholder[target=p_my_parameter]
        %b_my_buffer1 : [num_users=1] = placeholder[target=b_my_buffer1]
        %b_my_buffer2 : [num_users=2] = placeholder[target=b_my_buffer2]
        %x1 : [num_users=1] = placeholder[target=x1]
        %x2 : [num_users=1] = placeholder[target=x2]
        %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%x1, %p_my_parameter), kwargs = {})
        %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add, %b_my_buffer1), kwargs = {})
        %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%x2, %b_my_buffer2), kwargs = {})
        %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul, %mul_1), kwargs = {})
        %add_ : [num_users=0] = call_function[target=torch.ops.aten.add_.Tensor](args = (%b_my_buffer2, 1.0), kwargs = {})
        return (add_1,)

Resulting ExportGraphSignature of the non-functional Graph would be::

    # inputs
    p_my_parameter: PARAMETER target='my_parameter'
    b_my_buffer1: BUFFER target='my_buffer1' persistent=True
    b_my_buffer2: BUFFER target='my_buffer2' persistent=True
    x1: USER_INPUT
    x2: USER_INPUT

    # outputs
    add_1: USER_OUTPUT

To get a functional Graph, you can use :func:`run_decompositions`::

    mod = CustomModule()
    ep = torch.export.export(mod, (torch.tensor(1.0), torch.tensor(2.0)))
    ep = ep.run_decompositions()

Resulting Graph is functional::

    graph():
        %p_my_parameter : [num_users=1] = placeholder[target=p_my_parameter]
        %b_my_buffer1 : [num_users=1] = placeholder[target=b_my_buffer1]
        %b_my_buffer2 : [num_users=2] = placeholder[target=b_my_buffer2]
        %x1 : [num_users=1] = placeholder[target=x1]
        %x2 : [num_users=1] = placeholder[target=x2]
        %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%x1, %p_my_parameter), kwargs = {})
        %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add, %b_my_buffer1), kwargs = {})
        %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%x2, %b_my_buffer2), kwargs = {})
        %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul, %mul_1), kwargs = {})
        %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%b_my_buffer2, 1.0), kwargs = {})
        return (add_2, add_1)

Resulting ExportGraphSignature of the functional Graph would be::

    # inputs
    p_my_parameter: PARAMETER target='my_parameter'
    b_my_buffer1: BUFFER target='my_buffer1' persistent=True
    b_my_buffer2: BUFFER target='my_buffer2' persistent=True
    x1: USER_INPUT
    x2: USER_INPUT

    # outputs
    add_2: BUFFER_MUTATION target='my_buffer2'
    add_1: USER_OUTPUT

input_specsoutput_specsreturnc                 :    [        S U R                   5       5      $ )Nc              3      #    U  HR  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  UR                  v   MT     g 7fre   )rF   r   r?   rK   rH   r#   .0ss     r'   	<genexpr>2ExportGraphSignature.parameters.<locals>.<genexpr>  sD      
%vv,,,  !((C( AHH%   "AA	Atuplerq   rM   s    r'   
parametersExportGraphSignature.parameters  "     
%%
 
 	
r&   c                 :    [        S U R                   5       5      $ )Nc              3      #    U  HR  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  UR                  v   MT     g 7fre   )rF   r   r@   rK   rH   r#   rv   s     r'   ry   /ExportGraphSignature.buffers.<locals>.<genexpr>   sD      
%vv)))  !((C( AHH%r{   r|   rM   s    r'   buffersExportGraphSignature.buffers  r   r&   c                 :    [        S U R                   5       5      $ )Nc              3      #    U  Hc  nUR                   [        R                  :X  d  M#  UR                  S L d  M4  [	        UR
                  [        5      (       d  MU  UR
                  v   Me     g7f)FN)rF   r   r@   rI   rK   rH   r#   rv   s     r'   ry   >ExportGraphSignature.non_persistent_buffers.<locals>.<genexpr>)  sW      
%vv)))  ||u$  !((C(	 AHH%s   "A-A-A-A-r|   rM   s    r'   non_persistent_buffers+ExportGraphSignature.non_persistent_buffers'  s"     
%%
 
 	
r&   c                 :    [        S U R                   5       5      $ )Nc              3      #    U  HR  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  UR                  v   MT     g 7fre   )rF   r   rA   rK   rH   r#   rv   s     r'   ry   ?ExportGraphSignature.lifted_tensor_constants.<locals>.<genexpr>4  sD      
%vv222  !((C( AHH%r{   r|   rM   s    r'   lifted_tensor_constants,ExportGraphSignature.lifted_tensor_constants2  r   r&   c                 :    [        S U R                   5       5      $ )Nc              3      #    U  HR  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  UR                  v   MT     g 7fre   )rF   r   rB   rK   rH   r#   rv   s     r'   ry   :ExportGraphSignature.lifted_custom_objs.<locals>.<genexpr>=  sD      
%vv---  !((C( AHH%r{   r|   rM   s    r'   lifted_custom_objs'ExportGraphSignature.lifted_custom_objs;  r   r&   Nc           	         / nU R                    H  nUR                  [        R                  :w  a  M#  [	        UR
                  [        [        [        [        [        45      (       a'  UR                  UR
                  R                  5        M~  [	        UR
                  [        5      (       a'  UR                  UR
                  R                  5        M  [        UR
                   S35      e   [!        U5      $ )Nz is not a valid user inputs)rq   rF   r   r>   rK   rG   r   r   r   r   r   appendr   r   r8   RuntimeErrorr}   )rN   user_inputsrx   s      r'   r    ExportGraphSignature.user_inputsE  s    @B!!Avv---""$#%	 	 ""155::.AEE#344""155;;/"aeeW,G#HII% "& [!!r&   c                    / nU R                    GH,  nUR                  [        R                  [        R                  4;  a  M4  [        UR                  [        [        [        [        45      (       a'  UR                  UR                  R                  5        M  [        UR                  [        5      (       a'  UR                  UR                  R                  5        M  [        UR                  [        5      (       a(  UR                  UR                  R                  5        GM  [!        UR                   S35      e   [#        U5      $ )Nz is not a valid user output)rr   rF   r   r[   r\   rK   rG   r   r   r   r   r   r   r   r8   r   r   r}   )rN   user_outputsrx   s      r'   r   !ExportGraphSignature.user_outputs_  s    AC""Avv&&&&  1A?S  ##AEEJJ/AEE#344##AEEKK0AEE#455##AEEJJ/"aeeW,G#HII# #$ \""r&   c                 :    [        S U R                   5       5      $ )Nc              3   *  #    U  H  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  [        UR                  [        5      (       d  Me  UR                  R                  UR                  4v   M     g 7fre   )	rF   r   r?   rK   rG   r   rH   r#   r   rv   s     r'   ry   <ExportGraphSignature.inputs_to_parameters.<locals>.<genexpr>z  sf      
%vv,,, # 155.1 # 188S)	 #QUUZZ"%   "BB	B*)B_immutable_dictrq   rM   s    r'   inputs_to_parameters)ExportGraphSignature.inputs_to_parametersx  "     
%%
 
 	
r&   c                 :    [        S U R                   5       5      $ )Nc              3   *  #    U  H  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  [        UR                  [        5      (       d  Me  UR                  R                  UR                  4v   M     g 7fre   )	rF   r   r@   rK   rG   r   rH   r#   r   rv   s     r'   ry   9ExportGraphSignature.inputs_to_buffers.<locals>.<genexpr>  sf      
%vv))) # 155.1 # 188S)	 #QUUZZ"%r   r   rM   s    r'   inputs_to_buffers&ExportGraphSignature.inputs_to_buffers  r   r&   c                 :    [        S U R                   5       5      $ )Nc              3   *  #    U  H  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  [        UR                  [        5      (       d  Me  UR                  R                  UR                  4v   M     g 7fre   )	rF   r   r]   rK   rG   r   rH   r#   r   rv   s     r'   ry   9ExportGraphSignature.buffers_to_mutate.<locals>.<genexpr>  sf      
&vv333 # 155.1 # 188S)	 #QUUZZ"&r   r   rr   rM   s    r'   buffers_to_mutate&ExportGraphSignature.buffers_to_mutate  "     
&&
 
 	
r&   c                 :    [        S U R                   5       5      $ )Nc              3   *  #    U  H  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  [        UR                  [        5      (       d  Me  UR                  R                  UR                  4v   M     g 7fre   )	rF   r   r^   rK   rG   r   rH   r#   r   rv   s     r'   ry   <ExportGraphSignature.parameters_to_mutate.<locals>.<genexpr>  sf      
&vv666 # 155.1 # 188S)	 #QUUZZ"&r   r   rM   s    r'   parameters_to_mutate)ExportGraphSignature.parameters_to_mutate  r   r&   c                 :    [        S U R                   5       5      $ )Nc              3   *  #    U  H  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  [        UR                  [        5      (       d  Me  UR                  R                  UR                  4v   M     g 7fre   )	rF   r   ra   rK   rG   r   rH   r#   r   rv   s     r'   ry   =ExportGraphSignature.user_inputs_to_mutate.<locals>.<genexpr>  sf      
&vv777 # 155.1 # 188S)	 #QUUZZ"&r   r   rM   s    r'   user_inputs_to_mutate*ExportGraphSignature.user_inputs_to_mutate  r   r&   c                 :    [        S U R                   5       5      $ )Nc              3   *  #    U  H  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  [        UR                  [        5      (       d  Me  UR                  R                  UR                  4v   M     g 7fre   )	rF   r   rA   rK   rG   r   rH   r#   r   rv   s     r'   ry   IExportGraphSignature.inputs_to_lifted_tensor_constants.<locals>.<genexpr>  sf      
%vv222 # 155.1 # 188S)	 #QUUZZ"%r   r   rM   s    r'   !inputs_to_lifted_tensor_constants6ExportGraphSignature.inputs_to_lifted_tensor_constants  r   r&   c                 :    [        S U R                   5       5      $ )Nc              3   *  #    U  H  nUR                   [        R                  :X  d  M#  [        UR                  [
        5      (       d  MD  [        UR                  [        5      (       d  Me  UR                  R                  UR                  4v   M     g 7fre   )	rF   r   rB   rK   rG   r   rH   r#   r   rv   s     r'   ry   DExportGraphSignature.inputs_to_lifted_custom_objs.<locals>.<genexpr>  sg      
%vv--- # 155"34 # 188S)	 #QUUZZ"%r   r   rM   s    r'   inputs_to_lifted_custom_objs1ExportGraphSignature.inputs_to_lifted_custom_objs  r   r&   c                     S n0 n0 nU R                    GHi  nUR                  [        R                  :X  a>  Ub   e[	        UR
                  [        5      (       d   eUR
                  R                  nM`  UR                  [        R                  :X  af  [	        UR                  [        5      (       d   e[	        UR
                  [        5      (       d   eUR                  X$R
                  R                  '   M  UR                  [        R                  :X  d  GM  [	        UR                  [        5      (       d   e[	        UR
                  [        5      (       d   eUR                  X4R
                  R                  '   GMl     Uc  g [        UUUS9$ )N)rm   rk   rl   )rr   rF   r   r\   rK   rG   r   r   r_   rH   r#   r`   r   )rN   rm   rk   rl   specs        r'   backward_signature'ExportGraphSignature.backward_signature  s0   2435 %%DyyJ222"***!$((N;;;;"hhmmj>>>!$++s3333!$((N;;;;9='6j???!$++s3333!$((N;;;;:>++(7 & &#$;%=
 	
r&   c                     g re   r   rM   s    r'   assertion_dep_token(ExportGraphSignature.assertion_dep_token  s    r&   c                    / nU R                    Hi  nUR                  [        R                  :X  d  M#  [	        UR
                  [        5      (       d   eUR                  UR
                  R                  5        Mk     [        U5      $ re   )
rq   rF   r   rC   rK   rG   r*   r   r   r}   )rN   input_tokensrx   s      r'   r   !ExportGraphSignature.input_tokens  sa    !!Avv(!!%%7777##AEEJJ/ " \""r&   c                    / nU R                    Hi  nUR                  [        R                  :X  d  M#  [	        UR
                  [        5      (       d   eUR                  UR
                  R                  5        Mk     [        U5      $ re   )
rr   rF   r   rC   rK   rG   r*   r   r   r}   )rN   output_tokensrx   s      r'   r   "ExportGraphSignature.output_tokens  sc    ""Avv)))!!%%7777$$QUUZZ0 # ]##r&   c                     U R                   nUc  g [        U5      S:X  d   e[        [        UR	                  5       5      5      n[        U R
                  5      [        U R                  5      -   U:X  d   eg )N   )r   lennextiterkeysr   r   )rN   r   assertion_dep_token_indexs      r'   rO   "ExportGraphSignature.__post_init__  su    "66&&'1,,,$(.A.F.F.H)I$J!!!"S)?)?%@@()	
)r&   oldnewc                    [        U[        5      (       d   e[        U[        5      (       d   e[        [        [        [
        [        [        4nU R                   HL  n[        UR                  U5      (       d  M   UR                  R                  U:X  d  M<  X$R                  l
        MN     U R                   HL  n[        UR                  U5      (       d  M   UR                  R                  U:X  d  M<  X%R                  l
        MN     g)zB
Replace all uses of the old name with new name in the signature.
N)rK   r#   r   r   r   r   r   r*   rr   rG   r   rq   )rN   r   r   	arg_typesois         r'   replace_all_uses%ExportGraphSignature.replace_all_uses  s     #s#####s####
	 ""A!%%++55::$!$EEJ # !!A!%%++55::$!$EEJ "r&   c                    ^ ^ UU 4S jnU$ )Nc                    > UR                   S:X  a  TR                  U R                  U5        T(       a.  U R                   S:X  a  TR                  U R                  U5        g g g )Noutputplaceholder)opr   r   )r   r   userreplace_inputsrN   s      r'   _0ExportGraphSignature.get_replace_hook.<locals>._  sL    ww("%%chh4#&&M"9%%chh4 #:~r&   r   )rN   r   r   s   `` r'   get_replace_hook%ExportGraphSignature.get_replace_hook  s    	5 r&   c                     SR                  S U R                   5       5      nSR                  S U R                   5       5      nSU SU S3$ )N
c              3   8   #    U  H  n[        U5      v   M     g 7fre   r#   rv   s     r'   ry   /ExportGraphSignature.__str__.<locals>.<genexpr>$  s     A0@1A0@   c              3   8   #    U  H  n[        U5      v   M     g 7fre   r   rv   s     r'   ry   r   %  s      C1BAQ1Br   z

# inputs
z

# outputs
)joinrq   rr   )rN   rq   rr   s      r'   rV   ExportGraphSignature.__str__#  sK    iiA0@0@AAyy C1B1B CCk]/,rJJr&   r   )rs   N)F)*r   r    r!   r"   __doc__listr   r$   r   propertyr   r#   r~   r   r   r   r   r	   r9   r:   r;   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rO   r   r   rV   r%   r   r&   r'   r   r      s   iV i z"" 
JsO 
 
 
C 
 
 

3 
 
 
C 
 
 
JsO 
 
 "Zc5$c.I(JK " "2 #jsE4s/J)KL # #0 
gc3h&7 
 
 
738#4 
 
 
738#4 
 
 
gc3h&7 
 
 
wsCx'8 
 
 
7383D 
 
 
gc3h.? 
 
 
H-D$E 
 
< Xgc3h.?%@   #jo # # $z# $ $	
%C %c %.Kr&   r   c                 0    SSK Jn  U" [        U 5      5      $ )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   rn   )itemsr   s     r'   r   r   )  s    
 'DK((r&   rs   c           
         SSK JnJnJnJn  SSKJn  [        U [        [        [        [        S 5      [        45      (       a
  [        SU S9$ SU R                  ;   d
   U  S35       eU R                  S   nU R                  U;   a  [!        U R                  S9$ [#        U5      (       a  [%        U R                  S9$ [        Xu5      (       a  ['        U R                  S9$ [        Xt5      (       a  [)        U R                  S9$ [        Xs5      (       a  [+        U R                  S9$ [        Xr5      (       a0  [-        U R                  UR/                  5       R1                  5       S	9$ [        Xv5      (       a  [-        U R                  UR2                  US
9$ [        U[        [        [        [        [        S 5      45      (       a  [        U R                  US9$ [5        S[        U5       S35      e)Nr   )ScriptObjectSymBoolSymFloatSymIntr
   rR   )r   r8   valz8 is not a constant or a node with a 'val' metadata field)r   )r   r4   )r   r4   r5   z*Encountered an unsupported object of type z0 while writing the metadata for exported program)torchr   r   r  r  "torch._library.fake_class_registryr   rK   r9   r;   r:   rL   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  3  s   ==C$dE4:s;<<Rt44DII &HI ))E
CyyK$)),,	499--	C	 	 499--	C	"	"TYY//	C	!	!DII..	C	&	& dii399;;U;U;WXX	C	*	* c&;&;c
 	
 
C#tS%d<	=	=TYYc::8c D> ?
 	
r&   graph_signaturer   gmztorch.fx.GraphModuler   c           	      f  ^^^^^^^^^^^^ SSK Jn  U R                  S Ln[        U R                  5      mU R
                  mU R                  m[        U R                  5      mU R                  mU R                  mU R                  mU(       a  U R                  R                  O0 mU(       a  U R                  R                  O0 mU(       a  U R                  R                  OS mU R                  nU R                  mUR                   R"                   Vs/ s H   nUR$                  S:X  d  M  ['        Xe5      PM"     nnUR)                  [+        [-        [/        UR                   R"                  5      5      5      R0                  5       Vs/ s H  n['        UT5      PM     nnS[2        S[4        4UUUU4S jjn	S[6        S[2        S[8        4UUUUUUUU4S	 jjn
U Vs/ s H
  o" U5      PM     nn[;        U5       VVs/ s H  u  pU
" X5      PM     nnn[=        XS
9$ s  snf s  snf s  snf s  snnf )Nr   )_pytreer   inprs   c                   > [        U [        5      (       a  [        [        R                  U S S9$ [        U [
        5      (       d  [        [        R                  U S S9$ U R                  nUT;   a  [        [        R                  U S S9$ UT;   a  [        [        R                  U TU   S9$ UT;   a#  [        [        R                  U TU   TU   T;  S9$ [        SU 35      e)NrF   rG   rH   )rF   rG   rH   rI   zUnknown tensor input kind: )rK   r*   r   r   rC   r   r>   r   r?   r@   r
  )r  r   r   r   r   r   s     r'   to_input_spec9_convert_to_export_graph_signature.<locals>.to_input_spec  s    c=)))//s4HH#~..)"6"6CMMxx;)"6"6CMM))((+D1 
 &&%%(.-d3;QQ	  !#>tf!EFFr&   idxr   c                 B  > [        U[        5      (       a  [        [        R                  US S9$ [        U[
        5      (       d  [        [        R                  US S9$ UR                  nU [        T5      [        T5      -   [        T	5      -   [        T5      -   :  at  UT;   a  [        [        R                  UTU   S9$ UT;   a  [        [        R                  UTU   S9$ UT	;   a  [        [        R                  UT	U   S9$ [        SU 35      eUT
;   a  [        [        R                  US S9$ UT;   a  [        [        R                  UTU   S9$ UT;   a  [        [        R                  UTU   S9$ UT:X  a  [        [        R                  US S9$ [        SU 35      e)Nr  zUnknown tensor mutation kind: zUnknown tensor output kind: )rK   r*   r   r   rC   r   r[   r   r   r]   r^   ra   r
  r_   r`   r\   )r  r   r   buffer_mutationsgrad_paramsgrad_user_inputsrm   r   parameter_mutationsuser_input_mutationsr   s      r'   to_output_spec:_convert_to_export_graph_signature.<locals>.to_output_spec  s   a'':#3#34HH!^,,:#9#9qNNvv%&-@)AAC E
 
  ''!#33+D1 
 ,,!#66.t4 
 --!#77/5  %'EdV%LMM|#!z'='=1TRR$!#99&t, 
 ))!#::+D1 
 $!z'='=1TRR %'CD6%JKKr&   )rq   rr   )torch.utilsr  r   setr   r   r   r   r   r   r   gradients_to_parameterrl   rm   r   r   graphnodesr   r  tree_leavesr   r   reversedargsrX   r   r9   r   	enumerater   )r  r  r   pytreeis_jointr   r  inputsoutputsr  r  r  rq   r  r   rr   r  r  r  r   r   rm   r   r  r  r   r   s     `             @@@@@@@@@@@r'   "_convert_to_export_graph_signaturer-  X  s   
 .11=H o112K*??'99334L&88)>>*@@  	**AA   	**CC   	**66 
 #//L#11M HHNN"D77m# 	0D/"   &&tD"((..1I,J'K'P'PQQD 	D-0Q  
G< GI G G22LC 2LL 2LZ 2L 2Lh 288#=%K89B79KL9KvsN3*9KLLKSSs
d 9Ls   H,H	H#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   rX   r   r   r   r   r   r   r   r  r!  r#   r-  r   r&   r'   <module>r6     s    /  1 1 ? 1 E                 0 0 0 . . .
   R R R<  F F F0    BK BK BKJ)"
l "
J|T%|T|T  H|T 	|Tr&   