Ë
    f^(h#  ã                   ól   — d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ  G d„ de«      Zd	„ Zy)
é    N)ÚFakeTensorProp)ÚCapabilityBasedPartitioner)ÚOperatorSupport)ÚCALLABLE_NODE_OPS)Ú_pytreec                   óD   — e Zd Zdej                  j
                  defd„Zy)ÚCudaGraphsSupportÚnodeÚreturnc                 ó²  ‡— |j                   t        vry|j                  t        j                  j
                  j                  j                  fv ry|j                  t        j                  fv rydŠd„ }ˆfd„}|j                  D ](  }t        j                  | ||j                  «      «       Œ* t        j                  | ||j                  «      «       ‰ S )NFTc                 ó   — d| v r| d   S | d   S )NÚvalÚfake_result© )Úmetas    úa/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/fx/passes/backends/cudagraphs.pyÚmeta_fkz4CudaGraphsSupport.is_node_supported.<locals>.meta_fk   s   € Ø"'¨4¡-�4˜‘;ÐH°T¸-Ñ5HÐHó    c                 ót   •— t        | t        j                  «      r| j                  j                  dk7  rdŠy y y )NÚcudaT)Ú
isinstanceÚtorchÚTensorÚdeviceÚtype)ÚtÚfound_not_cudas    €r   Úfind_not_cudaz:CudaGraphsSupport.is_node_supported.<locals>.find_not_cuda   s.   ø€ ä˜!œUŸ\™\Ô*¨q¯x©x¯}©}ÀÒ/FØ!%‘ð 0GÐ*r   )Úopr   Útargetr   ÚopsÚatenÚembedding_dense_backwardÚdefaultÚoperatorÚgetitemÚall_input_nodesÚpytreeÚ	tree_map_r   )ÚselfÚ
submodulesr
   r   r   Únr   s         @r   Úis_node_supportedz#CudaGraphsSupport.is_node_supported   s¶   ø€ Ø�7‰7Ô+Ñ+Øà�;‰;œ5Ÿ9™9Ÿ>™>×BÑB×JÑJÐKÑKØà�;‰;œ8×+Ñ+Ð,Ñ,Øàˆò	Iô	&ð
 ×%Ñ%ò 	=ˆAÜ×Ñ˜]©G°A·F±F«OÕ<ð	=ô 	×Ñ˜©°·	±	Ó(:Ô;ð
 "Ð!Ð!r   N)Ú__name__Ú
__module__Ú__qualname__r   ÚfxÚNodeÚboolr-   r   r   r   r	   r	      s   „ ð"°%·(±(·-±-ð "ÀDô "r   r	   c                 ó¨   —  t        | «      j                  |Ž  t        «       }t        | |d¬«      }|j	                  «       }|j                  |«      }|S )zÉ
    Partition an FX graph into sub-GraphModules that can be validly run under
    CUDA graphs.  For a subgraph to be runnable under CUDA, all of the operations
    must involve CUDA tensors only/
    T)Úallows_single_node_partition)r   Ú	propagater	   r   Úpropose_partitionsÚfuse_partitions)ÚgmÚinputsÚsupported_opsÚpartitionerÚ
partitionsÚfused_graphs         r   Úpartition_cudagraphsr?   -   sZ   € ð !„N�2Ó× Ñ  &Ñ)Ü%Ó'€Mô -Ø
ˆM¸ô€Kð ×/Ñ/Ó1€JØ×-Ñ-¨jÓ9€KØÐr   )r%   r   Ú torch.fx.passes.fake_tensor_propr   Ú!torch.fx.passes.infra.partitionerr   Ú torch.fx.passes.operator_supportr   Útorch.fx.passes.tools_commonr   Útorch.utilsr   r(   r	   r?   r   r   r   ú<module>rE      s,   ðã ã Ý ;Ý HÝ <Ý :Ý )ô"˜ô "óBr   