+
    ړLj                        ^ RI t ^ RIt^ RIHt ^ RIHtHtHtHt ^RI	H	t	 ^RI
HtHt ^ RIHt ] P                   ! 4       t]]]]],          ]],          3,          t ! R R4      t ! R	 R
]4      tRR/R R lltRRR/R R llltR# )    Nwraps)OptionalUnionAnySequence)flags)transform_tensor_metricsset_metric_kernels)protonc                   X   a  ] tR t^t o RtRV 3R lR lltR tR tR tR t	R	 t
R
tV tR# )scopea  
A context manager and decorator for entering and exiting a scope.

Usage:
    context manager:
    ```python
    with proton.scope("test0", {metric_name: metric_value}):
        foo[1,](x, y)
    ```

    decorator:
    ```python
    @proton.scope("test0", {metric_name: metric_value})
    def foo(x, y):
        ...
    ```

Args:
    name (str): The name of the scope.
    metrics (dict[str, float], optional): The metrics of the scope. Default is None.
Nc                P   < V ^8  d   QhRS[ RS[S[S[ S[3,          ,          RR/#    namemetricsreturnNstrr   dictr   )format__classdict__s   "A/app/.local/lib/python3.14/site-packages/triton/profiler/scope.py__annotate__scope.__annotate__&   s/      S 8DcN+C t     c                ,    Wn         W n        R V n        R # Nr   r   id)selfr   r   s   &&&r   __init__scope.__init__&   s    	r   c                f   \         P                  '       g   R # \        P                  ! 4       V n        \        P
                  ! V P                  V P                  4       V P                  '       dB   \        4        \        P                  ! V P                  .\        V P                  4      O5!   R # R # r   )r	   profiling_on	libprotonrecord_scoper!   enter_scoper   r   r   add_metricsr
   r"   s   &r   _enter_scopescope._enter_scope+   sn    !!!((*dggtyy1<<< !!$''S,DT\\,RS r   c                    \         P                  '       d   V P                  f   R # \        P                  ! V P                  V P
                  4       R # r   )r	   r&   r!   r'   
exit_scoper   r+   s   &r   _exit_scopescope._exit_scope4   s1    !!!TWW_TWWdii0r   c                &    V P                  4        V # r   )r,   r+   s   &r   	__enter__scope.__enter__9   s    r   c                &    V P                  4        R # r   )r0   )r"   exc_type	exc_value	tracebacks   &&&&r   __exit__scope.__exit__=   s    r   c                4   a a \        S4      VV 3R  l4       pV# )c                     < SP                  4         S! V / VB SP                  4        #   SP                  4        i ; ir   )r,   r0   )argskwargsfuncr"   s   *,r   wrapperscope.__call__.<locals>.wrapperB   s:    #T,V,  "  "s   + =r   )r"   r?   r@   s   ff r   __call__scope.__call__@   s     	t	# 
	# r   )r!   r   r   r   )__name__
__module____qualname____firstlineno____doc__r#   r,   r0   r3   r9   rB   __static_attributes____classdictcell__)r   s   @r   r   r      s3     , 
T1

 
r   r   c                   ^   a a ] tR t^Mt oRtRV3R lV 3R llltV 3R ltV 3R ltRtVt	V ;t
# )cpu_timed_scopez
A scope that measures elapsed time (cpu_time).

Args:
    name (str): The name of the scope.
    metrics (dict[str, float], optional): Additional metrics to add. Default is None.
c                P   < V ^8  d   QhRS[ RS[S[S[ S[3,          ,          RR/# r   r   )r   r   s   "r   r   cpu_timed_scope.__annotate__V   s4     H HS H8DcN+C Ht Hr   c                l   < \         SV `  W4       R V n        V'       d   RV9   d   \        R4      hR # R # )Ncpu_timez'The metric name 'cpu_time' is reserved.)superr#   
start_time
ValueError)r"   r   r   	__class__s   &&&r   r#   cpu_timed_scope.__init__V   s4    'zW,FGG -7r   c                   < \         P                  '       g   R # \        P                  ! 4       V n        \
        SV `  4        R # r   )r	   r&   timetime_nsrR   rQ   r,   )r"   rT   s   &r   r,   cpu_timed_scope._enter_scope\   s*    !!!,,.r   c                  < \         P                  '       g   R # V P                  eJ   \        P                  ! 4       V P                  ,
          p\
        P                  ! V P                  RV/4       \        SV `%  4        R # )Nzcpu_time (ns)(exc))
r	   r&   rR   rW   rX   r'   r*   r!   rQ   r0   )r"   rP   rT   s   & r   r0   cpu_timed_scope._exit_scopeb   sU    !!!??&||~7H!!$'',@(+KLr   )rR   r   )rD   rE   rF   rG   rH   r#   r,   r0   rI   rJ   __classcell__)rT   r   s   @@r   rL   rL   M   s%     H H r   rL   r   c                    V ^8  d   QhR\         R\        \        \         \        3,          ,          R\        \        ,          /# r   r   r   r   )r   r   r   r   int)r   s   "r   r   r   k   s3     
 
c 
xS#X'? 
8TW= 
r   c                f   \         P                  '       g   R # \        P                  ! 4       p\	        \
        R. 4      \
        n        \
        P                  P                  W 34       \        P                  ! W 4       V'       d,   \        4        \        P                  ! V.\        V4      O5!   V# )Nscopes)r	   r&   r'   r(   getattrthread_local_scopesra   appendr)   r   r*   r
   r    s   &$ r   r)   r)   k   s}    				!B!()<h!K%%rj1"#bE#;G#DEIr   c                    V ^8  d   QhR\         \        ,          R\         \        \        \        3,          ,          R\         \        ,          /# r^   )r   r   r   r   r_   )r   s   "r   r   r   x   s9      Xc] xS#X7O [cdg[h r   c                Z   \         P                  '       g   R # \        P                  P	                  4       w  r#V '       d   W8w  d   \        RV  RV 24      hV '       g   Tp V'       d,   \        4        \        P                  ! V.\        V4      O5!   \        P                  ! W 4       V# )NzScope name mismatch: z != )r	   r&   rc   ra   poprS   r   r'   r*   r
   r/   )r   r   r!   popped_names   &$  r   r/   r/   x   s    )00446OB#0d;-HIIbE#;G#DE"Ir   r   )	threadingrW   	functoolsr   typingr   r   r   r   r	   metricr
   r   triton._C.libprotonr   r'   localrc   floatr_   MetricValueTyper   rL   r)   r/    r   r   <module>rr      sz       1 1  @ 3oo' sHUOXc]BC; ;|e <
$ 
RV  r   