ó
    0Vði·	  ã                   óv   • S SK r S SKrS SKrSSKJrJr  / SQr/ SQrS
S jrS r	S r
\ R                  S	 5       rg)é    Né   )Úcheck_errorÚcudart)ÚinitÚstartÚstopÚprofile)ÚgpustarttimestampÚgpuendtimestampÚ
gridsize3dÚthreadblocksizeÚstreamidzenableonstart 0Úconckerneltracec                 ó   • [        5       n[        US5      (       d  [        S5      e[        [        R                  S5      (       a_  [        R                  R
                  bD  [        [        R                  R
                  R                  S5      S   5      S:¼  a  [        S5      eUc  [        OUnUS:X  a  UR                  R                  nO(US	:X  a  UR                  R                  nO[        S
5      e[        R                  " SS9 nUR                  SR!                  S U 5       5      5        UR#                  5         [%        UR'                  UR(                  X5      5        S S S 5        g ! , (       d  f       g = f)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   óB   #   • U  H  oR                  S 5      v •  M     g7f)ÚasciiN)Úencode)Ú.0Úfs     ÚXD:\a\ltx-desktop-ci\ltx-desktop-ci\python-embed\Lib\site-packages\torch\cuda\profiler.pyÚ	<genexpr>Úinit.<locals>.<genexpr>-   s   é € Ð<²e°Ÿ8™8 G×,Ð,²eù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°QØ	�‰�—
‘
Ñ<±eÓ<Ó<Ô=Ø	�‰Œ	Ü�B×-Ñ-¨a¯f©f°kÓTÔU÷ 
2×	1Ö	1ús   Ä	AE/Å/
E=c                  óF   • [        [        5       R                  5       5        g)zxStarts 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   € ô ”“×*Ñ*Ó,Õ-r:   c                  óF   • [        [        5       R                  5       5        g)zvStops cuda profiler data collection.

.. warning::
    Raises CudaError in case of it is unable to stop the profiler.
N)r   r   ÚcudaProfilerStopr9   r:   r   r   r   ;   s   € ô ”“×)Ñ)Ó+Õ,r:   c               #   ó\   #   •  [        5         Sv •  [        5         g! [        5         f = f7f)aq  
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   r9   r:   r   r	   r	   D   s   é € ðÜŒÛä�øŒ�üs   ‚,„ ’,�)©,)Nr   )Ú
contextlibr+   r#   Ú r   r   Ú__all__r'   r   r   r   Úcontextmanagerr	   r9   r:   r   Ú<module>rB      sI   ðã Û ã ç !ò /€ò€ôVò6.ò-ð ×Ññó ñr:   