
    [Tha	                     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     K/var/www/auris/envauris/lib/python3.13/site-packages/torch/cuda/profiler.py	<genexpr>init.<locals>.<genexpr>-   s     <e88G,,es   )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&&MM*""((-a01R7 MNN"]MEk!,,99		,,00I
 	
 
	$	$D	1Q	

<e<<=		B--affkTU 
2	1	1s   	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:   