+
    \åûjw!  ã                   ó  € ^ RI t ^ RIHtHt ^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHt R	R
.t]! RR7       ! R R	]4      4       tRR R llt]! RR7       ! R R
]P,                  P.                  4      4       tR# )é    N)ÚAnyÚ
NamedTuple)Úenable_python_dispatcher)Údetect_fake_mode)Ú(is_contiguous_for_memory_format_or_false)Úis_sparse_any)Úcompatibility)Úmap_aggregateÚNodeÚTensorMetadataÚ	ShapePropT)Úis_backward_compatiblec                   ó0   a € ] tR t^t o RtV 3R ltRtV tR# )r   zUA structure containing pertinent information about a tensor within a PyTorch program.c                óâ   <€ V ^8„  d   Qh/ S[ P                  ;R&   S[ P                  ;R&   S[;R&   S[S[R3,          ;R&   S[ P                  R,          ;R&   S[;R&   S[S[S[	3,          ;R	&   # )
é   ÚshapeÚdtypeÚrequires_grad.ÚstrideNÚmemory_formatÚis_quantizedÚqparams)
ÚtorchÚSizer   ÚboolÚtupleÚintr   ÚdictÚstrr   )ÚformatÚ__classdict__s   "€ÚVC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\torch\fx\passes\shape_prop.pyÚ__annotate__ÚTensorMetadata.__annotate__   sƒ   ø‡ ‚ ñ
 �:‰:Ññ ñ �;‰;Ññ ñ Ññ ñ ‘#�s�(�OÑñ ñ ×&Ñ&¨Õ-Ñ-ñ ñ Ññ ñ ‘#‘s�(�^Ñò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r!   s   @r"   r   r      s   ø‡ € á_÷ ƒ r%   c                óP   € V ^8„  d   QhR\         P                  R\        R\        /# )r   ÚresultÚinclude_contiguityÚreturn)r   ÚTensorr   r   )r    s   "r"   r#   r#   %   s(   € ÷ 0ñ 0Ü�L‰Lð0Ü.2ð0äñ0r%   c           	     ó|  € V P                   pV P                  pV P                  p\        V 4      '       g   V P	                  4       MRpRpV'       d`   \        V 4      '       gO   \
        P                  \
        P                  \
        P                  3pV F  p\        WR7      '       g   K  Tp M	  V P                  p	/ p
V	'       dê   V P                  4       pWºR&   V\
        P                  \
        P                  39   d(   V P                  4       V
R&   V P                  4       V
R&   M‰V\
        P                   \
        P"                  \
        P$                  39   dV   V P'                  4       P)                  4       V
R&   V P+                  4       P)                  4       V
R&   V P-                  4       V
R&   \/        W#WEWiV
4      # )z:
Extract a TensorMetadata NamedTuple describing `result`.
N)r   ÚqschemeÚscaleÚ
zero_pointÚaxisr&   )r   r   r   r   r   r   Úcontiguous_formatÚchannels_lastÚchannels_last_3dr   r   r5   Úper_tensor_affineÚper_tensor_symmetricÚq_scaleÚq_zero_pointÚper_channel_affineÚ per_channel_affine_float_qparamsÚper_channel_symmetricÚq_per_channel_scalesÚtolistÚq_per_channel_zero_pointsÚq_per_channel_axisr   )r0   r1   r   r   r   r   r   Úmemory_formatsÚquery_formatr   r   r5   s   &&          r"   Ú_extract_tensor_metadatarI   %   s‚  € ð �L‰L€EØ�L‰L€EØ×(Ñ(€MÜ$1°&×$9Ò$9ˆV�]‰]Œ_¸r€Fà€Mç¤-°×"7Ò"7ä×#Ñ#Ü×ÑÜ×"Ñ"ð
ˆó
 +ˆLÜ7Ø÷õ ð !-�Ùñ +ð ×&Ñ&€LØ €GßØ—.‘.Ó"ˆØ$�	ÑØ”u×.Ñ.´×0JÑ0JÐKÔKØ%Ÿ~™~Ó/ˆG�GÑØ$*×$7Ñ$7Ó$9ˆG�LÒ!ØÜ×$Ñ$Ü×2Ñ2Ü×'Ñ'ð
ô 
ð  &×:Ñ:Ó<×CÑCÓEˆG�GÑØ$*×$DÑ$DÓ$F×$MÑ$MÓ$OˆG�LÑ!Ø$×7Ñ7Ó9ˆG�F‰OäØ�m¨]È'óð r%   c                   óv   a a€ ] tR t^Xt oRtR	V3R lV 3R llltV3R lV 3R lltV3R lV 3R lltRtVt	V ;t
# )
r   a±  
Execute an FX graph Node-by-Node and
record the shape and type of the result
into the corresponding node.

Example:
     In this example, we record the shape
     and data type of a module given
     an example input ``torch.randn(50, D_in)``.
     We print the name, shape and dtype of each node.

    class TwoLayerNet(torch.nn.Module):
        def __init__(self, D_in, H, D_out):
            super().__init__()
            self.linear1 = torch.nn.Linear(D_in, H)
            self.linear2 = torch.nn.Linear(H, D_out)
        def forward(self, x):
            h_relu = self.linear1(x).clamp(min=0)
            y_pred = self.linear2(h_relu)
            return y_pred
    N, D_in, H, D_out = 64, 1000, 100, 10
    x = torch.randn(N, D_in)
    y = torch.randn(N, D_out)
    model = TwoLayerNet(D_in, H, D_out)
    gm = torch.fx.symbolic_trace(model)
    sample_input = torch.randn(50, D_in)
    ShapeProp(gm).propagate(sample_input)

    for node in gm.graph.nodes:
        print(node.name, node.meta['tensor_meta'].dtype,
            node.meta['tensor_meta'].shape)

    The output of this code is:

    x torch.float32 torch.Size([50, 1000])
    linear1 torch.float32 torch.Size([50, 100])
    clamp_1 torch.float32 torch.Size([50, 100])
    linear2 torch.float32 torch.Size([50, 10])
    output torch.float32 torch.Size([50, 10])

Args:
     module (GraphModule): The module to be executed
     fake_mode (FakeTensorMode): A fake mode for copying the gm

c                óR   <€ V ^8„  d   QhRS[ P                  P                  RS[RR/# )r   ÚgmÚ	fake_moder2   N)r   ÚfxÚGraphModuler   )r    r!   s   "€r"   r#   ÚShapeProp.__annotate__ˆ   s,   ø€ ÷ 'ñ '™5Ÿ8™8×/Ñ/ð '¹Cð 'È4ñ 'r%   c                óÒ   <€ \         SV `  V4       Vf   \        4       pVe&   ^ RIHp V! V P
                  V4      V n        W n        MR V n        R V n        V P
                  V n        R # )N)Údeepcopy_to_fake_tensor)	ÚsuperÚ__init__r   Útorch._dynamo.utilsrR   ÚmoduleÚfake_modulerM   Úreal_module)ÚselfrL   rM   rR   Ú	__class__s   &&& €r"   rT   ÚShapeProp.__init__ˆ   s\   ø€ Ü‰Ñ˜ÔØÒÜ(Ó*ˆIØÒ ÝCñ  7°t·{±{ÀIÓNˆDÔØ&�Nà#ˆDÔØ!ˆDŒNàŸ;™;ˆÖr%   c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   Únr2   )r   r   )r    r!   s   "€r"   r#   rP       s   ø€ ÷ /ñ /™$ð /¡3ñ /r%   c           	     óÄ  <a
€ ^ RI HpHp  V P                  e   V P                  V n         V P
                  ef   V P
                  ;_uu_ 4        \        4       ;_uu_ 4        \        SV `!  V4      pV! V P
                  P                  W4       RRR4       RRR4       M\        SV `!  V4      pV P                  V n        Ro
R T
3R llp\#        XT4      pS
'       d   YqP                   R&   T P
                  '       d=   T P
                  P                  ;p'       d   T! Y„4      ;p	'       d   Y‘P                   R	&   \%        T4      TP                   R
&   T#   + '       g   i     LÎ; i  + '       g   i     LÉ; i  T P                  T n        i ; i  \         dE   p\        P                  ! 4        \        RTP                  4        RTP                    24      ThRp?ii ; i)r   )Úcompute_unbacked_bindingsÚrebind_unbackedNzShapeProp error for: node=z with meta=Fc                ó0   € V ^8„  d   QhR\         R\         /# )r   Úobjr2   ©r   )r    s   "r"   r#   Ú(ShapeProp.run_node.<locals>.__annotate__¼   s   € ÷ 	ñ 	¤Sð 	¬Sñ 	r%   c                 ób   <€ \        V \        P                  4      '       d   R o\        V 4      # V # ©T)Ú
isinstancer   r3   rI   )rb   Úfound_tensors   &€r"   Úextract_tensor_metaÚ/ShapeProp.run_node.<locals>.extract_tensor_meta¼   s)   ø€ Ü˜#œuŸ|™|×,Ò,à#�Ü/°Ó4Ð4à�
r%   Útensor_metaÚunbacked_bindingsÚtype)Ú%torch.fx.experimental.symbolic_shapesr_   r`   rW   rV   rM   r   rS   Úrun_nodeÚ	shape_envrX   Ú	ExceptionÚ	tracebackÚ	print_excÚRuntimeErrorÚformat_nodeÚmetar
   rm   )rY   r]   r_   r`   r0   Úeri   rv   rp   Úsymbol_to_pathrh   rZ   s   &&        @€r"   ro   ÚShapeProp.run_node    sz  ù€ ÷	
ð
	Ø×ÑÒ+ð #×.Ñ.�”ð/Ø—>‘>Ò-ØŸŸ›Ô)A×)CÕ)CÜ!&¡Ñ!1°!Ó!4˜Ù'¨¯©×(@Ñ(@À!ÔL÷ *DŸ˜ô #™WÑ-¨aÓ0�Fà"×.Ñ.�”ð ˆ÷	ð 	ô ˜VÐ%8Ó9ˆßØ$(�F‰F�=Ñ!à�>�>ˆ>Ø!Ÿ^™^×5Ñ5Ð5�	Ö5Ù";¸IÓ"NÐN�ÖNà.<—‘Ð*Ñ+ä˜f›ˆ�‰ˆv‰Øˆ÷E *D×)CúŸŸûð #×.Ñ.�•ûÜô 	Ü×ÒÔ!ÜØ,¨Q¯]©]«_Ð,=¸[ÈÏÉÈÐQóàðûð	ús^   ŒF ¬"E: ÁE'Á!-E	ÂE'ÂE: Â.F ÅE$ÅE'Å'E7	Å2E: Å:FÆF ÆGÆ?GÇGc                ó&   <€ V ^8„  d   QhRS[ RS[ /# )r   Úargsr2   rc   )r    r!   s   "€r"   r#   rP   Ñ   s   ø€ ÷ 'ñ '™sð '¡sñ 'r%   c                óä   <€ V P                   eN   V Uu. uF@  p\        V\        P                  4      '       d   V P                   P	                  V4      MTNKB  	  ppMTp\
        SV `  ! V!  # u upi )zÐ
Run `module` via interpretation and return the result and
record the shape and type of each node.

Args:
    *args (Tensor): the sample input.

Returns:
    Any: The value returned from executing the Module
)rM   rg   r   r3   Úfrom_tensorrS   Úrun)rY   r{   ÚtÚ	fake_argsrZ   s   &*  €r"   Ú	propagateÚShapeProp.propagateÑ   ss   ø€ ð �>‰>Ò%ñ óá�Aô 2<¸A¼u¿|¹|×1LÒ1L�—‘×*Ñ*¨1Ô-ÐRSÒSÙð ð ˆIð
 ˆIÜ‰wŠ{˜IÑ&Ð&ùòs   ”AA-)rM   rW   rV   rX   )N)r'   r(   r)   r*   r+   rT   ro   r�   r-   r.   Ú__classcell__)rZ   r!   s   @@r"   r   r   X   s/   ù‡ € ñ,÷\'õ '÷0/ó /÷b'÷ 'ó 'r%   rf   )rr   Útypingr   r   r   Útorch.fxÚtorch._dispatch.pythonr   Útorch._guardsr   Útorch._prims_commonr   Útorch._subclasses.meta_utilsr   Útorch.fx._compatibilityr	   Útorch.fx.noder
   r   Ú__all__r   rI   rN   ÚInterpreterr   r&   r%   r"   Ú<module>rŽ      s‚   ðÛ ß "ã Û Ý ;Ý *Ý HÝ 6Ý 1ß -ð ˜[Ð
)€ñ  dÔ+ô�Zó ó ,ð÷&0ñf  dÔ+ôJ'�—‘×$Ñ$ó J'ó ,òJ'r%   