ó
    ÊÙ¢j~  ã                   ó¶   • S r SSKrSSKrSSKrSSKJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJrJrJrJr  SSKJr  \R*                  " \5      r " S	 S
\5      rg)z<Profiler to check if there are any bottlenecks in your code.é    N)ÚABCÚabstractmethod)Ú	Generator)Úcontextmanager)ÚPath)ÚAnyÚCallableÚOptionalÚTextIOÚUnion)Úget_filesystemc            	       ó|  • \ rS rSrSr  SS\\\\4      S\\   SS4S jjr	\
S\SS4S	 j5       r\
S\SS4S
 j5       rS\4S jr\S\S\4S j5       rS\S\SS4S jr  SS\\   S\S\4S jjrS S jrS S jrS\\\4   S\4S jrSS\S\\   S\\   SS4S jjrS\\   SS4S jrS S jr\S\4S j5       rSrg)!ÚProfileré   zKIf you wish to write a custom profiler, you should inherit from this class.NÚdirpathÚfilenameÚreturnc                 óT   • Xl         X l        S U l        S U l        S U l        S U l        g )N)r   r   Ú_output_fileÚ_write_streamÚ_local_rankÚ_stage)Úselfr   r   s      Ú²C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\pytorch_lightning/profilers/profiler.pyÚ__init__ÚProfiler.__init__!   s-   € ð
 ŒØ Œà.2ˆÔØ15ˆÔØ*.ˆÔØ%)ˆ�ó    Úaction_namec                 ó   • g)z)Defines how to start recording an action.N© ©r   r   s     r   ÚstartÚProfiler.start.   ó   � r   c                 ó   • g)z>Defines how to record the duration once an action is complete.Nr    r!   s     r   ÚstopÚProfiler.stop2   r$   r   c                 ó   • g)NÚ r    ©r   s    r   ÚsummaryÚProfiler.summary6   s   € Ør   c              #   ó†   #   •  U R                  U5        Uv •  U R                  U5        g! U R                  U5        f = f7f)a  Yields a context manager to encapsulate the scope of a profiled action.

Example::

    with self.profile('load training data'):
        # load training data code

The profiler will start once you've entered the context and will automatically
stop once you exit the code block.

N)r"   r&   r!   s     r   ÚprofileÚProfiler.profile9   s4   é € ð	#Ø�J‰J�{Ô#ØÒà�I‰I�kÕ"øˆD�I‰I�kÕ"üs   ‚A„+ ™A«>¾AÚargsÚkwargsc                 óR   • U R                   S;   a  [        R                  " U0 UD6  g g )N©Nr   )r   ÚlogÚinfo)r   r0   r1   s      r   Ú_rank_zero_infoÚProfiler._rank_zero_infoL   s&   € Ø×Ñ˜yÓ(Ü�HŠH�dÐ%˜fÓ%ð )r   Ú	extensionc                 óô  • / nU R                   b  UR                  U R                   5        U R                  (       a  UR                  U R                  5        U R                  b$  UR                  [	        U R                  5      5        Ub  UR                  U5        SR                  U5      n[        R                  " SSU5      n[        R                  " SSU5      nUR                  5       nU(       d  SnXB-   $ )NÚ-z[\\/:*?\"<>|\n\r\t]Ú_z_+r.   )	r   Úappendr   r   ÚstrÚjoinÚreÚsubÚstrip)r   r   r8   r0   Úbases        r   Ú_prepare_filenameÚProfiler._prepare_filenameP   s½   € ð
 ˆØ�;‰;Ñ"Ø�K‰K˜Ÿ™Ô$Ø�=�=Ø�K‰K˜Ÿ™Ô&Ø×ÑÑ'Ø�K‰Kœ˜D×,Ñ,Ó-Ô.ØÑ"Ø�K‰K˜Ô$Ø�x‰x˜‹~ˆä�vŠvÐ,¨c°4Ó8ˆÜ�vŠv�e˜S $Ó'ˆØ�z‰z‹|ˆÞØˆDØÑÐr   c                 ó”  • U R                   b  g U R                  (       a˜  U R                  (       a‡  [        R                  R                  U R                  U R                  5       5      n[        U5      nUR                  U R                  SS9  UR                  US5      nX0l
        UR                  U l         g U R                  U l         g )NT)Úexist_okÚa)r   r   r   ÚosÚpathr>   rC   r   ÚmkdirsÚopenr   Úwriter6   )r   ÚfilepathÚfsÚfiles       r   Ú_prepare_streamsÚProfiler._prepare_streamsg   s�   € Ø×ÑÑ)ØØ�=�=˜TŸ\Ÿ\Ü—w‘w—|‘| D§L¡L°$×2HÑ2HÓ2JÓKˆHÜ Ó)ˆBØ�I‰I�d—l‘l¨TˆIÑ2Ø—7‘7˜8 SÓ)ˆDØ $ÔØ!%§¡ˆDÕà!%×!5Ñ!5ˆDÕr   c                 ó  • U R                  5         U R                  5       nU(       a  U R                  b  U R                  U5        U R                  b  U R                  R	                  5         U R                  U R                  S9  g)z2Logs a profile report after the conclusion of run.N©Ústage)rP   r+   r   r   ÚflushÚteardownr   )r   r+   s     r   ÚdescribeÚProfiler.describet   sg   € ð
 	×ÑÔØ—,‘,“.ˆÞ�t×)Ñ)Ñ5Ø×Ñ˜wÔ'Ø×ÑÑ(Ø×Ñ×#Ñ#Ô%Ø�‰˜DŸK™KˆÒ(r   Ústatsc                 ób  • U R                   b  U R                   R                  5        S3OSnUS-   /nUR                  5        HK  u  pESU 3nU R                  b  USU R                   3-  nUR	                  U5        UR	                  U5        MM     [
        R                  R                  U5      $ )NÚ r)   zProfiler ReportzProfile stats for: z rank: )r   ÚupperÚitemsr   r<   rH   Úlinesepr>   )r   rY   rT   ÚoutputÚactionÚvalueÚheaders          r   Ú_stats_to_strÚProfiler._stats_to_str�   s¤   € Ø-1¯[©[Ñ-D�4—;‘;×$Ñ$Ó&Ð' qÑ)È"ˆØÐ+Ñ+Ð,ˆØ"Ÿ[™[ž]‰MˆFØ*¨6¨(Ð3ˆFØ×ÑÑ+Ø˜G D×$4Ñ$4Ð#5Ð6Ñ6�Ø�M‰M˜&Ô!Ø�M‰M˜%Ö ñ +ô �z‰z�‰˜vÓ&Ð&r   rT   Ú
local_rankÚlog_dirc                 óP   • Xl         X l        U R                  =(       d    UU l        g)z-Execute arbitrary pre-profiling set-up steps.N)r   r   r   )r   rT   re   rf   s       r   ÚsetupÚProfiler.setupŒ   s   € àŒØ%ÔØ—|‘|×. wˆ�r   c                 óp   • SU l         U R                  b"  U R                  R                  5         SU l        gg)z_Execute arbitrary post-profiling tear-down steps.

Closes the currently open file and stream.

N)r   r   Úclose)r   rT   s     r   rV   ÚProfiler.teardown’   s7   € ð "ˆÔØ×ÑÑ(Ø×Ñ×#Ñ#Ô%Ø $ˆDÕð )r   c                 ó6   • U R                  U R                  S9  g )NrS   )rV   r   r*   s    r   Ú__del__ÚProfiler.__del__�   s   € Ø�‰˜DŸK™KˆÒ(r   c                 ó8   • U R                   c  S$ U R                   $ r3   )r   r*   s    r   re   ÚProfiler.local_rank    s   € à×$Ñ$Ñ,ˆqÐB°$×2BÑ2BÐBr   )r   r   r   r   r   r   )NN)Nz.txt)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r
   r   r=   r   r   r   r"   r&   r+   r   r   r.   r   r6   rC   rP   rW   Údictrc   Úintrh   rV   rn   Úpropertyre   Ú__static_attributes__r    r   r   r   r      s‡  † ÙUð /3Ø"&ñ*à˜%  T 	Ñ*Ñ+ð*ð ˜3‘-ð*ð 
õ	*ð ð8 ð 8¨ó 8ó ð8ð ðM ð M¨ó Mó ðMð˜ô ð ð# 3ð #¨9ó #ó ð#ð$& Sð &°Cð &¸Dô &ð &*Øñ à˜c‘]ð ð ð ð 
õ	 ô.6ô)ð	' 4¨¨S¨¡>ð 	'°cô 	'ñ/˜3ð /¨H°S©Mð /È8ÐTWÉ=ð /Ðdhõ /ð	%˜h s™mð 	%°ô 	%ô)ð ðC˜Có Có óCr   r   )rv   ÚloggingrH   r?   Úabcr   r   Úcollections.abcr   Ú
contextlibr   Úpathlibr   Útypingr   r	   r
   r   r   Ú#lightning_fabric.utilities.cloud_ior   Ú	getLoggerrr   r4   r   r    r   r   Ú<module>rƒ      sI   ðñ Cã Û 	Û 	ß #Ý %Ý %Ý ß 9Õ 9å >à×Ò˜Ó!€ôDCˆsõ DCr   