Ë
    S²j  ã                   óì  — d dl Z d dlmZmZ d dlmZmZ d dlmZ ddl	m
Z
 e j                  j                  Z ee j                  e j                  e j                  e j                   g«      Z eg ej$                  ‘ej&                  ‘ej(                  ‘ej*                  ‘ej,                  ‘ej.                  ‘ej0                  ‘ej2                  ‘ej4                  ‘ej6                  ‘ej8                  ‘ej:                  ‘ej<                  ‘ej>                  ‘ej@                  ‘ejB                  ‘ejD                  ‘ejF                  ‘ejH                  ‘ejJ                  ‘ejL                  ‘ejN                  ‘ejP                  ‘ejR                  ‘ejT                  ‘ejV                  ‘ejX                  ‘ejZ                  ‘ej\                  ‘ej^                  ‘ej`                  ‘«      Z1 eejd                  ejf                  ejh                  ejj                  ejl                  ejn                  ejp                  ejr                  ejt                  g	«      Z;e1e;z  Z<de=fd„Z>d	e j~                  de@fd
„ZAde=fd„ZBy)é    N)Úget_device_tflopsÚget_gpu_dram_gbps)Úoptimization_hintÚstatically_known_true)Ú
OrderedSeté   )Úflop_registryÚreturnc                 óà   — | t         v rft        |«      dk7  rt        d|› d| › �«      ‚|j                  «       }t	        |«      dz  }d}||z  }t         |    }	 |	|i |¤d|i¤Ždz  }
|
|z  dz  }|S y	)
aw  
    Estimates the compute time of an aten operator.

    Args:
        func_packet: The operator overload packet.
        args: The arguments to the operator.
        kwargs: The keyword arguments to the operator.
        out: The output of the operator.
        out_dtypes: The output data types.

    Returns:
        float: The estimated compute time in nanoseconds.
    r   z"Only support single out dtype got z for g  4&õkCg      è?Úout_valé   g    eÍÍAg        )r	   ÚlenÚAssertionErrorÚpopr   )Úfunc_packetÚargsÚkwargsÚoutÚ
out_dtypesÚdtypeÚpeak_gpu_flopsÚfactorÚpeak_empirical_flopsÚflop_count_funcÚ
flop_countÚcompute_times               ú^/var/www/html/ia-enhanced/venv/lib/python3.12/site-packages/torch/utils/_runtime_estimation.pyÚget_compute_timer   M   sž   € ð ”mÑ#Üˆz‹?˜aÒÜ Ø4°Z°LÀÀkÀ]ÐSóð ð —‘Ó ˆä*¨5Ó1°DÑ8ˆàˆØ%¨Ñ6ÐÜ'¨Ñ4ˆá$ dÐB¨fÑB¸cÒBÀQÑFˆ
à"Ð%9Ñ9¸SÑ@ˆØÐØó    Útc                 óÂ   — d}t        | j                  | j                  «       «      D ]$  \  }}t        |dk(  «      rŒ|t	        |d¬«      z  }Œ& || j                  «       z  S )z¹
    Calculates the memory consumption of a tensor.

    Args:
        t (torch.Tensor): The input tensor.

    Returns:
        int: The memory consumption of the tensor in bytes.
    r   r   )Úfallback)ÚzipÚshapeÚstrider   r   Úelement_size)r    Ú
real_numelÚsizer%   s       r   Úget_num_bytesr)   o   s_   € ð €JÜ˜AŸG™G Q§X¡X£ZÓ0ò >‰ˆˆfä$ V¨q¡[Õ1ØÔ+¨D¸1Ô=Ñ=‰Jð>ð
 ˜Ÿ™Ó(Ñ(Ð(r   c                 óv   — t        «       }t        d„ | D «       «      }t        d„ |D «       «      }||z   }||z  }|S )aG  
    Estimates the memory transfer time of input and output tensors.

    Args:
        flat_args_kwargs (List[torch.Tensor]): The flat list of arguments and keyword arguments.
        flat_outs (List[torch.Tensor]): The flat list of outputs.

    Returns:
        float: The estimated memory transfer time in nanoseconds.
    c              3   óh   K  — | ]*  }t        |t        j                  «      sŒt        |«      –— Œ, y ­w©N©Ú
isinstanceÚtorchÚTensorr)   ©Ú.0r    s     r   ú	<genexpr>z$get_transfer_time.<locals>.<genexpr>Ž   s'   è ø€ ò Ø´jÀÄEÇLÁLÕ6QŒ�a×ñùó   ‚2¢2c              3   óh   K  — | ]*  }t        |t        j                  «      sŒt        |«      –— Œ, y ­wr,   r-   r1   s     r   r3   z$get_transfer_time.<locals>.<genexpr>‘   s'   è ø€ ò Ø¬z¸!¼U¿\¹\Õ/JŒ�a×ñùr4   )r   Úsum)Úflat_args_kwargsÚ	flat_outsÚgpu_memory_bandwidthÚ
read_bytesÚwrite_bytesÚcounted_bytesÚtransfer_times          r   Úget_transfer_timer>   ‚   sZ   € ô -Ó.ÐÜñ Ø"2ôó €Jô ñ Ø"+ôó €Kð  Ñ,€Mà!Ð$8Ñ8€MØÐr   )Cr/   Útorch._inductor.utilsr   r   Ú%torch.fx.experimental.symbolic_shapesr   r   Útorch.utils._ordered_setr   Úflop_counterr	   ÚopsÚatenÚfloat16Úbfloat16Úfloat32Úfloat64Ú_FLOAT_TYPESÚ
lift_freshr    Ú	transposeÚviewÚdetachÚ_unsafe_viewÚsplitÚadjointÚ
as_stridedÚdiagonalÚexpandÚ	expand_asÚmovedimÚpermuteÚselectÚsqueezeÚmTÚmHÚrealÚimagÚview_asÚ	unflattenÚunfoldÚunbindÚ	unsqueezeÚvsplitÚhsplitÚsplit_with_sizesÚswapaxesÚswapdimsÚchunkÚ	_VIEW_OPSÚrandintÚrandnÚrandÚ
randn_likeÚ	rand_likeÚrandint_likeÚarangeÚ	ones_likeÚ
zeros_likeÚ_CREATE_OPSÚ_IGNORE_OPSÚfloatr   r0   Úintr)   r>   © r   r   ú<module>rw      s¤  ðÛ ß F÷õ 0å 'ð ‡y�y‡~�~€áà�‰Ø�‰Ø�‰Ø�‰ð	ó€ñ ð Ø�‰ð à�‰ð ð 	�‰ð ð 	�	‰	ð	 ð
 	�‰ð ð 	×Ñð ð 	�
‰
ð ð 	�‰ð ð 	�‰ð ð 	�‰ð ð 	�‰ð ð 	�‰ð ð 	�‰ð ð 	�‰ð ð 	�‰ð ð  	�‰ð! ð" 	�‰ð# ð$ 	�‰ð% ð& 	�	‰	ð' ð( 	�	‰	ð) ð* 	�‰ð+ ð, 	�‰ð- ð. 	�‰ð/ ð0 	�‰ð1 ð2 	�‰ð3 ð4 	�‰ð5 ð6 	�‰ð7 ð8 	×Ñð9 ð: 	�‰ð; ð< 	�‰ð= ð> 	�
‰
ð? ó"€	ñH à�‰Ø�
‰
Ø�	‰	Ø�‰Ø�‰Ø×ÑØ�‰Ø�‰Ø�‰ð
ó€ð ˜+Ñ%€ðÀEó ðD)�U—\‘\ð ) có )ð&°eô r   