
    ǄgE	                     h    d dl Z d dlZg dZd	dededdfdZd Ze j                  d	dedefd       Zy)
    N)startstopprofilemodewait_until_completedreturnc                     | j                         j                  dd      }t        j                  j	                  ||       y)a  Start OS Signpost tracing from MPS backend.

    The generated OS Signposts could be recorded and viewed in
    XCode Instruments Logging tool.

    Args:
        mode(str): OS Signpost tracing mode could be "interval", "event",
            or both "interval,event".
            The interval mode traces the duration of execution of the operations,
            whereas event mode marks the completion of executions.
            See document `Recording Performance Data`_ for more info.
        wait_until_completed(bool): Waits until the MPS Stream complete
            executing each encoded GPU operation. This helps generating single
            dispatches on the trace's timeline.
            Note that enabling this option would affect the performance negatively.

    .. _Recording Performance Data:
       https://developer.apple.com/documentation/os/logging/recording_performance_data
      N)lowerreplacetorch_C_mps_profilerStartTrace)r   r   mode_normalizeds      Z/home/mcse/projects/flask_80/flask-venv/lib/python3.12/site-packages/torch/mps/profiler.pyr   r   
   s1    ( jjl**33O	HH$$_6JK    c                  @    t         j                  j                          y)z6Stops generating OS Signpost tracing from MPS backend.N)r   r   _mps_profilerStopTrace r   r   r   r   "   s    	HH##%r   c              #   `   K   	 t        | |       d t                y# t                w xY ww)a>  Context Manager to enabling generating OS Signpost tracing from MPS backend.

    Args:
        mode(str): OS Signpost tracing mode could be "interval", "event",
            or both "interval,event".
            The interval mode traces the duration of execution of the operations,
            whereas event mode marks the completion of executions.
            See document `Recording Performance Data`_ for more info.
        wait_until_completed(bool): Waits until the MPS Stream complete
            executing each encoded GPU operation. This helps generating single
            dispatches on the trace's timeline.
            Note that enabling this option would affect the performance negatively.

    .. _Recording Performance Data:
       https://developer.apple.com/documentation/os/logging/recording_performance_data
    N)r   r   )r   r   s     r   r   r   '   s#     $d()s   . .+.)intervalF)	
contextlibr   __all__strboolr   r   contextmanagerr   r   r   r   <module>r      s]      'L L L L0&
 # $  r   