
    [Th,                         S SK r S SKrS SKJr  S SKrS SKrS SKJrJrJ	r	J
r
Jr  S SKJrJrJrJrJrJr  S/r\" SSS9 " S S5      5       rS	 rg)
    N)
deprecated)_disable_profiler_legacy_enable_profiler_legacy
DeviceTypeProfilerConfigProfilerState)_filter_name_filter_stack_entry_rewrite_name	EventListFunctionEventMEMORY_EVENT_NAMEprofilez`torch.autograd.profiler_legacy.profile` is deprecated and will be removed in a future release. Please use `torch.profiler` instead.)categoryc                      \ rS rSrSr SSSSSSSS.S jjrS rS rS rS	 r	S
 r
S rS r       SS jr\R                  R                  \l        S r\R                  R                  \l        SS\S\4S jjrSS jr\R$                  R                  \l        S r\R&                  R                  \l        \S 5       rSrg)r      z'DEPRECATED: use torch.profiler instead.F)use_cudarecord_shapes
with_flopsprofile_memory
with_stackwith_modulesc                   Xl         U R                   (       d  g X l        S U l        SU l        X0l        X@l        U =R                  U R
                  -  sl        XPl        X`l        Xpl        U R                  (       a?  [        R                  R                  5       (       d  [        R                  " SSS9  SU l        U R                  (       a  [        R                  U l        g [        R"                  U l        g )NFz/CUDA is not available, disabling CUDA profiling   )
stacklevel)enabledr   function_eventsenteredr   r   r   r   r   torchcudais_availablewarningswarnr   CUDAprofiler_kindCPU)selfr   r   r   r   r   r   r   s           V/var/www/auris/envauris/lib/python3.13/site-packages/torch/autograd/profiler_legacy.py__init__profile.__init__$   s     %|| #*$doo-,$(==!8!8!:!:MMA "DM==!.!3!3D!.!2!2D    c           
          [        U R                  U R                  U R                  U R                  U R
                  U R                  [        R                  R                  R                  5       5      $ N)r   r%   r   r   r   r   r   r   _C	_profiler_ExperimentalConfigr'   s    r(   configprofile.configH   sW    OOOOHH224	
 		
r+   c                     U R                   (       d  g U R                  (       a  [        S5      eSU l        U R                  5         U $ )Nz)Profiler context manager is not reentrantT)r   r   RuntimeError_start_tracer1   s    r(   	__enter__profile.__enter__T   s7    ||<<JKKr+   c                 6    [        U R                  5       5        g r-   )r   r2   r1   s    r(   r6   profile._start_trace]   s    .r+   c                 T   U R                   (       d  g U R                  (       a  [        R                  R	                  5         [        5       n[        U5      n[        UU R                  (       a  SOS U R                  U R                  S9U l
        U R                  R                  5         g)Nr    )
use_devicer   r   F)r   r   r   r    synchronizer   _parse_legacy_recordsr   r   r   r   _build_tree)r'   exc_typeexc_valexc_tbrecordsparsed_resultss         r(   __exit__profile.__exit__`   sw    ||==JJ""$*,.w7(!%vD..	 
 	((*r+   c                 H    U R                   c  g[        U R                   5      $ )Nz$<unfinished profiler_legacy.profile>)r   reprr1   s    r(   __repr__profile.__repr__q   s"    '9D(())r+   c                 H    U R                   c  g[        U R                   5      $ )Nz,<unfinished profile.profiler_legacy.profile>)r   strr1   s    r(   __str__profile.__str__v   s"    'A4''((r+   c                 4    U R                   c  [        S5      eg )NzProfiler didn't finish running)r   r5   r1   s    r(   _check_finishprofile._check_finish{   s    '?@@ (r+   Nc           
      ~    U R                  5         U R                  c   eU R                  R                  UUUUUUUS9$ )N)sort_by	row_limitmax_src_column_widthmax_name_column_widthmax_shapes_column_widthheadertop_level_events_only)rP   r   table)r'   rS   rT   rU   rV   rW   rX   rY   s           r(   rZ   profile.table   sU     	##///##))!5"7$;"7 * 
 	
r+   c                 v    U R                  5         U R                  c   eU R                  R                  U5      $ r-   )rP   r   export_chrome_trace)r'   paths     r(   r]   profile.export_chrome_trace   s7    ##///##77==r+   r^   metricc                     U R                  5         U R                  c   S5       eU R                  (       d   S5       eU R                  R                  X5      $ )NExpected profiling resultsz(export_stacks() requires with_stack=True)rP   r   r   export_stacks)r'   r^   r`   s      r(   rc   profile.export_stacks   sO    ##/M1MM/J JJ##11$??r+   c                     U R                  5         U R                  c   S5       eU R                  R                  X5      $ Nrb   )rP   r   key_averages)r'   group_by_input_shapegroup_by_stack_ns      r(   rg   profile.key_averages   s>    ##/M1MM/##001EXXr+   c                 ~    U R                  5         U R                  c   S5       eU R                  R                  5       $ rf   )rP   r   total_averager1   s    r(   rl   profile.total_average   s;    ##/M1MM/##1133r+   c                 l    U R                  5         U R                  c   eU R                  R                  $ )z;Return CPU time as the sum of self times across all events.)rP   r   self_cpu_time_totalr1   s    r(   ro   profile.self_cpu_time_total   s4     	##///##777r+   )
r   r   r   r   r%   r   r   r   r   r   )T)Nd   K   7   P   NF)ro   )Fr   )__name__
__module____qualname____firstlineno____doc__r)   r2   r7   r6   rE   rI   rM   rP   rZ   r   r]   rL   rc   rg   rl   propertyro   __static_attributes__ r+   r(   r   r      s     2 "3 "3H

/"*
)
A   "#
, OO++EM>
 #,"?"?"G"G@# @s @Y
 %1199L4
 &33;;M8 8r+   c                 ~	   S nS n/ n[         R                  R                  U 5       H"  nUR                  5       nUb  M  US:X  d  M   UnM$     Ub  UR	                  5       (       a   eU  GH:  n0 n0 n0 n	[        5       n
S nU GH  nU" U5      n[        UR                  5       5      (       d  X;   a  U
R                  U5        MB  UR                  5       S:X  a  Ub  UR                  5       UR                  5       :H  =(       aI    UR                  5       UR                  5       :H  =(       a!    UR                  5       UR                  5       :H  nU(       a  U
R                  U5        M  XIU'   SX|'   SX'   GO)UR                  5       S:X  Ga5  X;   d   SU S35       eX   nX|   nX   nUR                  5       =(       d!    UR                  5       UR                  5       :g  nUR	                  5       nUR                  5       n[        S$0 SUR                  5       _S	UR                  5       _S
[        UR                  5       SS9_S[        UR                  5       SS9_SUR                  5       _SUR!                  U5      _SUR!                  U5      _SUR#                  5       _SUR%                  5       _SUR'                  5        Vs/ s H  n[)        U5      (       d  M  UPM     sn_SUR+                  5       _SUR-                  5       (       a  SOS _SU_SU_SU_SU_SUR/                  5       _S[0        R2                  _SS_SU_6nU(       d[  UR-                  5       (       aF  UR5                  U5      nUS:  a/  UR7                  UR                  5       UR9                  5       U5        UR;                  U5        X	 X|	 X	 OUR                  5       S :X  a  [=        U5      n[=        U5      nUU:X  d   eUR?                  5        H  nUU==   URA                  5       -  ss'   M      UR?                  5        H  nUU==   URC                  5       -  ss'   M      US:X  aC  [        S[D        S SSS/ URA                  5       URC                  5       SS!9
nUR;                  U5        UnGM      GM=     URG                  S" S#9  U$ s  snf )%Nc                 B    U R                  5       U R                  5       4$ )zPReturn a tuple for correlating start and end records in `_parse_legacy_records`.)handlenode_id)records    r(   _get_record_key._parse_legacy_records.<locals>._get_record_key   s    !122r+   __start_profilepushr   popzExpected record with key zo to exist in range_starts.
                    This means that the pop event did not have a corresponding push.idr   nameT)r   with_wildcard
trace_nameFthreadstart_usend_us
fwd_threadinput_shapesstackscoper<   r    cpu_memory_usagedevice_memory_usageis_async	is_remotesequence_nrdevice_type	is_legacyflopsmemory_alloc)
r   r   r   r   r   r   r   r   r   r   c                 \    U R                   R                  U R                   R                  * /$ r-   )
time_rangestartend)evts    r(   <lambda>'_parse_legacy_records.<locals>.<lambda>7  s     CNN$8$83>>;M;M:M#Nr+   )keyr|   )$	itertoolschainfrom_iterabler   r   setr	   addkindr   r   	thread_idr   r   r   r   cpu_elapsed_usfwd_thread_idshapesr   r
   r   has_cudar   r   r&   cuda_elapsed_usappend_kerneldeviceappendlenkeysr   cuda_memory_usager   sort)thread_recordsr   start_record	functionsr   r   thread_record_listcpu_memory_allocscuda_memory_allocsrange_startsfiltered_handlesprev_record
record_key	duplicater   r   r   r   is_remote_eventstart_flopsentryfedurationnum_open_handles_cpunum_open_handles_cudar   s                             r(   r>   r>      s   3 LI ////?{{}D,=$=!L @
 #L,B,B,D,DDD,5(F(0JFKKM**j.L $$Z0{{}& *#((*fkkm; F',,.&++-?F'//1V^^5EE 
 !(,,Z8 +1Z(01!-12".%'.X0 =U XX. %0#4#@ $6$B! >>+X0AVEUEUEW0W"("2"2"4#kkm" }}"NN, 'EJJLM  -%**,eT	
 !??, *88? (66v>  %224 "' ,1;;=+8%<OPU<V=  ++- */)9)9vt &6  ):!" &#$ .%& !& 1 1 3'( !+)* #+, &-2  ENN$4$4$44V<H!|((u||~xP  $ ,%1&2.0'*+<'=$(+,>(?%+/DDDD/446F%f-1H1H1JJ- 70557F&v.&2J2J2LL. 8'1,&.#' !"  )/)@)@)B,2,D,D,F"&B $$R( Ky ) -Z NNNNOos   R:R:)r   r"   typing_extensionsr   r   
torch.cudatorch.autogradr   r   r   r   r   torch.autograd.profiler_utilr	   r
   r   r   r   r   __all__r   r>   r|   r+   r(   <module>r      sa      (     + +
V8 V8
V8r~r+   