Ë
    g^(ha	  ã                   ót   — d dl Z d dlZd dlZddlmZmZ g d¢Zg d¢Zd
d„Zd„ Z	d„ Z
e j                  d	„ «       Zy)é    Né   )Úcheck_errorÚcudart)ÚinitÚstartÚstopÚprofile)ÚgpustarttimestampÚgpuendtimestampÚ
gridsize3dÚthreadblocksizeÚstreamidzenableonstart 0Úconckerneltracec                 óÞ  — t        «       }t        |d«      st        d«      ‚t        t        j                  d«      r]t        j                  j
                  �Ct        t        j                  j
                  j                  d«      d   «      dk\  rt        d«      ‚|€t        n|}|dk(  r|j                  j                  }n'|d	k(  r|j                  j                  }nt        d
«      ‚t        j                  d¬«      5 }|j                  dj!                  d„ |D «       «      «       |j#                  «        t%        |j'                  |j(                  | |«      «       d d d «       y # 1 sw Y   y xY w)NÚcudaOutputModez-HIP does not support profiler initialization!Úcudaú.r   é   z.CUDA12+ does not need profiler initialization!Ú	key_valueÚcsvz;supported CUDA profiler output modes are: key_value and csvT)Údeleteó   
c              3   ó>   K  — | ]  }|j                  d «      –— Œ y­w)ÚasciiN)Úencode)Ú.0Úfs     úQ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/cuda/profiler.pyú	<genexpr>zinit.<locals>.<genexpr>-   s   è ø€ Ò<°˜1Ÿ8™8 G×,Ñ<ùs   ‚)r   ÚhasattrÚAssertionErrorÚtorchÚversionr   ÚintÚsplitÚDEFAULT_FLAGSr   ÚKeyValuePairÚCSVÚRuntimeErrorÚtempfileÚNamedTemporaryFileÚwriteÚjoinÚflushr   ÚcudaProfilerInitializeÚname)Úoutput_fileÚflagsÚoutput_modeÚrtÚoutput_mode_enumr   s         r   r   r      s-  € Ü	‹€BÜ�2Ð'Ô(ÜÐLÓMÐMä”—‘˜vÔ&Ü�M‰M×ÑÐ*Ü”—‘×"Ñ"×(Ñ(¨Ó-¨aÑ0Ó1°RÒ7ô ÐMÓNÐNØ"˜]�M°€EØ�kÒ!Ø×,Ñ,×9Ñ9ÑØ	˜Ò	Ø×,Ñ,×0Ñ0ÑäØIó
ð 	
ô 
×	$Ñ	$¨DÔ	1ð V°QØ	�‰�—
‘
Ñ<°eÔ<Ó<Ô=Ø	�‰Œ	Ü�B×-Ñ-¨a¯f©f°kÐCSÓTÔU÷V÷ Vñ Vús   Ã<AE#Å#E,c                  óF   — t        t        «       j                  «       «       y)z„Starts cuda profiler data collection.

    .. warning::
        Raises CudaError in case of it is unable to start the profiler.
    N)r   r   ÚcudaProfilerStart© ó    r   r   r   2   s   € ô ”“×*Ñ*Ó,Õ-r9   c                  óF   — t        t        «       j                  «       «       y)z‚Stops cuda profiler data collection.

    .. warning::
        Raises CudaError in case of it is unable to stop the profiler.
    N)r   r   ÚcudaProfilerStopr8   r9   r   r   r   ;   s   € ô ”“×)Ñ)Ó+Õ,r9   c               #   ó\   K  — 	 t        «        d–— t        «        y# t        «        w xY w­w)a™  
    Enable profiling.

    Context Manager to enabling profile collection by the active profiling tool from CUDA backend.
    Example:
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_CUDA)
        >>> import torch
        >>> model = torch.nn.Linear(20, 30).cuda()
        >>> inputs = torch.randn(128, 20).cuda()
        >>> with torch.cuda.profiler.profile() as prof:
        ...     model(inputs)
    N)r   r   r8   r9   r   r	   r	   D   s   è ø€ ðÜŒÛä�øŒ�üs   ‚,„ ’,�)©,)Nr   )Ú
contextlibr*   r"   Ú r   r   Ú__all__r&   r   r   r   Úcontextmanagerr	   r8   r9   r   ú<module>rA      sI   ðã Û ã ç !ò /€ò€óVò6.ò-ð ×Ññó ñr9   