§
    U�’jpÆ  ã                  óJ  — d dl mZ d dlZd dlZd dlZd dlZd dlZd dlm	Z	m
Z
mZmZ d dlZd dlmZmZmZmZmZmZ d dlmZ d dlmZ erd dlmZ d dlmZ d d	lmZ ed
e f         Z!ede f         Z" ej#        e$¦  «        Z% G d„ dej&        ¦  «        Z'e'j(        de'j)        de'j*        de'j+        de'j,        de'j-        de'j.        dddiZ/d„  e0e/¦  «        D ¦   «         Z1 G d„ dej&        ¦  «        Z2d„ e2D ¦   «         Z3 ej4        ddd¬¦  «         G d„ d
¦  «        ¦   «         Z5ej4         G d„ d¦  «        ¦   «         Z6 ej4        ddd¬¦  «         G d „ de5¦  «        ¦   «         Z7dBd%„Z8dCd'„Z9dDd)„Z:dEd-„Z; G d.„ d/¦  «        Z< G d0„ d1¦  «        Z= G d2„ d3¦  «        Z> ej4        ¦   «          G d4„ d5¦  «        ¦   «         Z? G d6„ d7¦  «        Z@ G d8„ d9¦  «        ZAej4         G d:„ d;¦  «        ¦   «         ZBej4         G d<„ d=¦  «        ¦   «         ZC G d>„ d?¦  «        ZD G d@„ dA¦  «        ZEdS )Fé    )ÚannotationsN)ÚAnyÚcastÚLiteralÚTYPE_CHECKING)Ú
_EventTypeÚ_ExtraFields_AllocationÚ_ExtraFields_TorchOpÚ_ProfilerEventÚ_TensorMetadataÚRecordScope)Ú_element_size)Ú_utils)ÚIterator)ÚFunctionSchema)Ú_ProfilerResultÚKeyÚ	TensorKeyc                  óà   — e Zd Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         Z	 ej        ¦   «         Z
 ej        ¦   «         ZdS )ÚCategoryN)Ú__name__Ú
__module__Ú__qualname__ÚenumÚautoÚINPUTÚ	TEMPORARYÚ
ACTIVATIONÚGRADIENTÚAUTOGRAD_DETAILÚ	PARAMETERÚOPTIMIZER_STATE© ó    úMC:\Projects\DSCons\.venv\Lib\site-packages\torch\profiler\_memory_profiler.pyr   r   %   si   € € € € € ØˆDŒI‰KŒK€EØ�”	‘”€IØ�”‘”€JØˆtŒy‰{Œ{€HØ�d”i‘k”k€OØ�”	‘”€IØ�d”i‘k”k€O€O€Or$   r   Ú	darkgreenÚ	goldenrodÚblackÚmediumpurpleÚredÚ
mediumblueÚ	royalblueÚgreyc                ó   — i | ]\  }}||“Œ	S r#   r#   )Ú.0ÚiÚcs      r%   ú
<dictcomp>r2   :   s   € ÐFÐFÐF™t˜q !�a˜ÐFÐFÐFr$   c                  ó†   — e Zd Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         ZdS )ÚActionN)	r   r   r   r   r   ÚPREEXISTINGÚCREATEÚINCREMENT_VERSIONÚDESTROYr#   r$   r%   r4   r4   =   sC   € € € € € Ø�$”)‘+”+€KØˆTŒY‰[Œ[€FØ!˜œ	™œÐØˆdŒi‰kŒk€G€G€Gr$   r4   c                ó   — i | ]
}||j         “ŒS r#   ©Úvalue©r/   r0   s     r%   r2   r2   D   s   € Ð/Ð/Ð/ 1�A�q”wÐ/Ð/Ð/r$   TF)ÚeqÚunsafe_hashÚfrozenc                  ó   — e Zd ZU ded<   dS )r   útorch.deviceÚdeviceN)r   r   r   Ú__annotations__r#   r$   r%   r   r   G   s   € € € € € € àÐÐÑÐÐr$   c                  ó@   — e Zd ZU dZded<   ded<   dd„Zdd„Zdd„ZdS )Ú_StoragezñBundle storage pointer and id.

    All profiling logic should use `allocation_id`, however it is useful to
    print storage pointers for debugging and unit tests sometimes look up
    values using the storage data pointer of a live Tensor.ÚintÚptrÚallocation_idÚreturnÚstrc                óB   — t          | j        ¦  «        d›d| j        › d�S )Nz>18ú (ú))ÚhexrG   rH   ©Úselfs    r%   Ú__repr__z_Storage.__repr__W   s'   € Ý�d”h‘-”-Ð<Ð<Ð< tÔ'9Ð<Ð<Ð<Ð<r$   ÚotherÚobjectÚboolc                óL   — t          |t          ¦  «        o| j        |j        k    S ©N)Ú
isinstancerE   rH   ©rP   rR   s     r%   Ú__eq__z_Storage.__eq__Z   s"   € Ý˜%¥Ñ*Ô*ÐX¨tÔ/AÀUÔEXÒ/XÐXr$   c                ó*   — t          | j        ¦  «        S rV   )ÚhashrH   rO   s    r%   Ú__hash__z_Storage.__hash__]   s   € Ý�DÔ&Ñ'Ô'Ð'r$   N©rI   rJ   )rR   rS   rI   rT   ©rI   rF   )r   r   r   Ú__doc__rC   rQ   rY   r\   r#   r$   r%   rE   rE   L   sw   € € € € € € ð?ð ?ð €H€H�HØÐÐÑð=ð =ð =ð =ðYð Yð Yð Yð(ð (ð (ð (ð (ð (r$   rE   c                  ó˜   — e Zd ZU dZded<   ded<   dd„Zdd„Zedd„¦   «         Ze	d d„¦   «         Z
e	d!d„¦   «         Zed"d„¦   «         ZdS )#r   a  Hashable identifier for a storage which has been assigned an ID.

    A detailed description of Tensor IDs and why they are needed is given in
    `torch/csrc/profiler/collection.h` when `TensorID` is declared. To
    summarize, multiple Storage buffers can map to the same logical Tensor.
    This dataclass is used to refer to a concrete in-memory StorageImpl of
    a Tensor.
    rF   ÚidrE   ÚstoragerI   rJ   c                óT   — d| j         › dt          | j        ¦  «        d›d| j        › d�S )Nzid=z: z<24rL   rM   )ra   Úreprrb   rB   rO   s    r%   rQ   zTensorKey.__repr__o   s4   € ØH�T”WÐHÐH¥ T¤\Ñ 2Ô 2ÐHÐHÐH¸$¼+ÐHÐHÐHÐHr$   rR   rT   c                ó"   — | j         |j         k     S rV   )Ú_as_sortablerX   s     r%   Ú__lt__zTensorKey.__lt__r   s   € ØÔ  5Ô#5Ò5Ð5r$   Ú	tensor_idú
int | NoneÚstorage_ptrrH   rB   rA   úTensorKey | Nonec                óP   — | �#|�!|�t          || t          ||¦  «        ¦  «        S d S rV   )r   rE   )rh   rj   rH   rB   s       r%   Ú_makezTensorKey._makeu   s7   € ð Ð!ØÐ'ØÐ)å˜V Yµ¸ÀmÑ0TÔ0TÑUÔUÐUØˆtr$   Úallocr	   c                óZ   — |                       |j        |j        |j        |j        ¦  «        S rV   )rm   ra   rG   rH   rB   )Úclsrn   s     r%   Úfrom_allocationzTensorKey.from_allocation„   s#   € à�yŠy˜œ 5¤9¨eÔ.AÀ5Ä<ÑPÔPÐPr$   Útú_TensorMetadata | Nonec                ób   — |�,|                       |j        |j        |j        |j        ¦  «        S d S rV   )rm   ra   Ústorage_data_ptrrH   rB   )rp   rr   s     r%   Úfrom_tensorzTensorKey.from_tensorˆ   s-   € àˆ=Ø—9’9˜QœT 1Ô#5°q´ÈÌÑQÔQÐQØˆtr$   útuple[int, int, str, int]c                óT   — | j         | j        j        | j        j        | j        j        fS rV   )ra   rb   rH   rB   ÚtypeÚindexrO   s    r%   rf   zTensorKey._as_sortableŽ   s"   € àŒw˜œÔ2°D´KÔ4DÀdÄkÔFWÐWÐWr$   Nr]   )rR   r   rI   rT   )
rh   ri   rj   ri   rH   ri   rB   rA   rI   rk   )rn   r	   rI   rk   )rr   rs   rI   rk   )rI   rw   )r   r   r   r_   rC   rQ   rg   Ústaticmethodrm   Úclassmethodrq   rv   Úpropertyrf   r#   r$   r%   r   r   a   sí   € € € € € € ðð ð €G€G�GØÐÐÑðIð Ið Ið Ið6ð 6ð 6ð 6ð ðð ð ñ „\ðð ðQð Qð Qñ „[ðQð ðð ð ñ „[ðð
 ðXð Xð Xñ „XðXð Xð Xr$   Únoder   rI   ú3Iterator[tuple[TensorKey | None, TensorKey | None]]c              #  óä  K  — | j         }| j        d         t          j        k    râ| j        d         j        t
          j        k    rÂ| j        dk    r·|rµ|d         j        d         t          j        k    r”|d         j        dv r…|d         j        d         j        rmt          |d         j        d         j        d         t          ¦  «        r<d t                               |d         j        d         j        d         ¦  «        fV — d S | j        d         t          j        k    rÊ| j        d         }|j        �|j        �t!          d¦  «        ‚|j        �I|j        j        D ]<\  }}}t                               |¦  «        t                               |¦  «        fV — Œ=|j        �K|j        j        D ]@\  }}}t                               |¦  «        t                               |¦  «        fV — Œ=d S d S d S )Nr   é   ztorch::autograd::AccumulateGrad)zaten::detachz
aten::add_ú'module and optimizer cannot both be set)ÚchildrenÚtypedr   ÚTorchOpÚscoper   ÚBACKWARD_FUNCTIONÚnameÚinputsrW   r   r   rv   ÚPyCallÚmoduleÚ	optimizerÚAssertionErrorÚ
parameters)r~   rƒ   Útyped_fieldsÚ_ÚpÚp_grads         r%   Ú!_extract_parameters_and_gradientsr“   “   s   è è € ð Œ}€Hð 	Œ
�1Œ�Ô+Ò+Ð+ØŒJ�qŒMÔ¥;Ô#@Ò@Ð@àŒIÐ:Ò:Ð:Øð ;à�QŒKÔ˜aÔ ¥JÔ$6Ò6Ð6Ø�QŒKÔÐ >Ð>Ð>Ø�QŒKÔ˜aÔ Ô'ð ?å�x ”{Ô(¨Ô+Ô2°1Ô5µÑGÔGð ?ð •I×)Ò)¨(°1¬+Ô*;¸AÔ*>Ô*EÀaÔ*HÑIÔIÐIÐIÐIÐIÐIÐIð 
Œ�AŒ�*Ô+Ò	+Ð	+Ø”z !”}ˆØÔÐ*¨|Ô/EÐ/QÝ Ð!JÑKÔKÐKØÔÐ*Ø ,Ô 3Ô >ð Nð N‘��1�fÝ×+Ò+¨AÑ.Ô.µ	×0EÒ0EÀfÑ0MÔ0MÐMÐMÐMÐMÐMàÔ!Ð-Ø ,Ô 6Ô Að Nð N‘��6˜1Ý×+Ò+¨AÑ.Ô.µ	×0EÒ0EÀfÑ0MÔ0MÐMÐMÐMÐMÐMð 
,Ð	+ð .Ð-ðNð Nr$   úIterator[TensorKey]c              #  ó@   K  — t          | ¦  «        D ]\  }}|�|V — Œd S rV   ©r“   )r~   r‘   Ú_p_grads      r%   Úextract_parametersr˜   ¾   s:   è è € Ý7¸Ñ=Ô=ð ð ‰
ˆˆ7Øˆ=ØˆGˆGˆGøðð r$   ú,Iterator[tuple[TensorKey | None, TensorKey]]c              #  óD   K  — t          | ¦  «        D ]\  }}|�||fV — Œd S rV   r–   )r~   r‘   r’   s      r%   Úextract_gradientsr›   Ä   sA   è è € õ 7°tÑ<Ô<ð ð ‰	ˆˆ6ØÐØ�V�)ˆOˆOˆOøðð r$   Úeventú_ProfilerEvent | Noneútuple[RecordScope, ...]c                óº   — g }| rI| j         d         t          j        k    r%|                     | j         d         j        ¦  «         | j        } | °It          |¦  «        S ©Nr   r�   )r„   r   r…   Úappendr†   ÚparentÚtuple)rœ   Úscopess     r%   Ú
get_scopesr¥   Ì   s]   € Ø€FØ
ð ØŒ;�qŒ>�ZÔ/Ò/Ð/Ø�MŠM˜%œ+ aœ.Ô.Ñ/Ô/Ð/Ø”ˆð ð õ �‰=Œ=Ðr$   c                  ór   — e Zd ZdZedd„¦   «         Zedd„¦   «         Zedd
„¦   «         Zedd„¦   «         Z	dS )ÚSchemaMatcheraò  Lookup operator schema based on profiled name.

    When profiling we record the operator's name but not the schema. However
    some analysis requires that information. Fortunately we can look up
    registered schema from the recorded name. We do not, however, record the
    overload and so we must compare the profiled arguments with all overloads
    to determine viable matches.

    Note: Once https://github.com/pytorch/pytorch/issues/78871 is completed
    this code will be obsolete.
    rr   r
   rI   útuple[bool | None, ...]c           
     ó  — d}|                       |¦  «        D ]S}|pd„ |j        D ¦   «         }t          |j        ¦  «        D ])\  }}||xx         t          |j        dd¦  «        z  cc<   Œ*ŒTt          |pd„ |j        D ¦   «         ¦  «        S )a¯  Determine which inputs may have mutated based on function schema.

        Note that we don't need to resolve down to a single schema to perform
        this analysis. An input is mutable if it is mutable in any overload. In
        practice, however, it is overwhelmingly common to match a single
        overload. If we cannot find any valid schema then we must be
        conservative and assume all inputs are mutable.
        Nc                ó   — g | ]}d ‘ŒS )Fr#   ©r/   r�   s     r%   ú
<listcomp>z4SchemaMatcher.inputs_are_mutable.<locals>.<listcomp>î   s   € Ð!BÐ!BÐ!B¨A %Ð!BÐ!BÐ!Br$   Úis_writeFc              3  ó   K  — | ]}d V — Œd S rV   r#   r«   s     r%   ú	<genexpr>z3SchemaMatcher.inputs_are_mutable.<locals>.<genexpr>ó   s"   è è € Ð 8Ð 8¨! Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8r$   )Úmatch_schemasÚ	argumentsÚ	enumerateÚgetattrÚ
alias_infor£   r‰   )rp   rr   ÚmutableÚschemar0   Úargs         r%   Úinputs_are_mutablez SchemaMatcher.inputs_are_mutableâ   s¶   € ð &*ˆØ×'Ò'¨Ñ*Ô*ð 	Ið 	IˆFØÐBÐ!BÐ!B°Ô1AÐ!BÑ!BÔ!BˆGÝ# FÔ$4Ñ5Ô5ð Ið I‘��3à˜�
�
”
�g c¤n°jÀ%ÑHÔHÑH�
�
‘
�
ðIõ �WÐ8Ð 8Ð 8¨q¬xÐ 8Ñ 8Ô 8Ñ9Ô9Ð9r$   útuple[FunctionSchema, ...]c                ó¼   ‡ ‡‡— t          d„ |j        D ¦   «         ¦  «        Šdˆ ˆfd„Št          ˆfd„‰                      |j        ¦  «        pdD ¦   «         ¦  «        S )Nc              3  óº   K  — | ]V}t          |t          ¦  «        rt                               |¦  «        n"t          |t          ¦  «        rd „ |D ¦   «         n|V — ŒWdS )c                óB   — g | ]}t                                |¦  «        ‘ŒS r#   )r   rv   )r/   Újs     r%   r¬   z9SchemaMatcher.match_schemas.<locals>.<genexpr>.<listcomp>ý   s&   € Ð6Ð6Ð6¨q•)×'Ò'¨Ñ*Ô*Ð6Ð6Ð6r$   N)rW   r   r   rv   Úlistr<   s     r%   r¯   z.SchemaMatcher.match_schemas.<locals>.<genexpr>÷   s‡   è è € ð 
ð 
ð õ ˜!�_Ñ-Ô-ð�I×!Ò! !Ñ$Ô$Ð$õ
 ˜!�TÑ"Ô"ðÐ6Ð6°AÐ6Ñ6Ô6Ð6ð ð
ð 
ð 
ð 
ð 
ð 
r$   rI   rT   c                ó®   •— t          | j        ¦  «        t          ‰¦  «        k    o/t          ˆfd„t          ‰| j        d¬¦  «        D ¦   «         ¦  «        S )Nc              3  óT   •K  — | ]"\  }}‰                      ||j        ¦  «        V — Œ#d S rV   )Ú_types_matchry   )r/   ÚobservedÚ
schema_argrp   s      €r%   r¯   z?SchemaMatcher.match_schemas.<locals>.matches.<locals>.<genexpr>  sU   øè è € ð Cð Cá(�H˜jð × Ò  ¨:¬?Ñ;Ô;ðCð Cð Cð Cð Cð Cr$   T©Ústrict)Úlenr±   ÚallÚzip)r¶   rp   Ú	signatures    €€r%   Úmatchesz,SchemaMatcher.match_schemas.<locals>.matches  sz   ø€ Ý�vÔ'Ñ(Ô(­C°	©N¬NÒ:ð ½sð Cð Cð Cð Cå,/Ø˜vÔ/¸ð-ñ -ô -ðCñ Cô Cñ @ô @ð r$   c              3  ó2   •K  — | ]} ‰|¦  «        ¯|V — Œd S rV   r#   )r/   ÚsrÊ   s     €r%   r¯   z.SchemaMatcher.match_schemas.<locals>.<genexpr>  s0   øè è € ÐOÐO˜1ÀGÀGÈAÁJÄJÐO�QÐOÐOÐOÐOÐOÐOr$   r#   ©rI   rT   )r£   r‰   Úlookup_schemasrˆ   )rp   rr   rÊ   rÉ   s   ` @@r%   r°   zSchemaMatcher.match_schemasõ   s‘   øøø€ åð 
ð 
ð ”Xð
ñ 
ô 
ñ 
ô 
ˆ	ð	ð 	ð 	ð 	ð 	ð 	ð 	õ ÐOÐOÐOÐO × 2Ò 2°1´6Ñ :Ô :Ð @¸bÐOÑOÔOÑOÔOÐOr$   rT   c                ó~  — t          |t          j        j        ¦  «        r.|                     ¦   «         }|d u p|                      ||¦  «        S t          |t          j        j        ¦  «        rdS |                     t          j        j         	                    ¦   «         ¦  «        r.t          |t          ¦  «        ot          d„ |D ¦   «         ¦  «        S t          j        j        t          ft          j        j        t          d ¦  «        ft          j        j        t"          ft          j        j        t&          ft          j        j        t*          ft          j        j        t.          ft          j        j        t"          t&          t*          t.          fff}|D ]'\  }}t          ||¦  «        rt          ||¦  «        c S Œ(|d u S )NTc              3  ó@   K  — | ]}t          |t          ¦  «        V — Œd S rV   )rW   r   r<   s     r%   r¯   z-SchemaMatcher._types_match.<locals>.<genexpr>  s=   è è € ð 6ð 6Ø-.•
˜1�iÑ(Ô(ð6ð 6ð 6ð 6ð 6ð 6r$   )rW   ÚtorchÚ_CÚOptionalTypeÚgetElementTyperÁ   ÚAnyTypeÚisSubtypeOfÚListTypeÚ	ofTensorsr¾   rÇ   Ú
TensorTyper   ÚNoneTypery   ÚBoolTyperT   ÚIntTyperF   Ú	FloatTypeÚfloatÚComplexTypeÚcomplexÚ
NumberType)rp   rÂ   Úschema_typeÚtype_mapÚjit_typeÚpy_typess         r%   rÁ   zSchemaMatcher._types_match  s‘  € å�k¥5¤8Ô#8Ñ9Ô9ð 	OØ%×4Ò4Ñ6Ô6ˆKØ˜tÐ#ÐN s×'7Ò'7¸À+Ñ'NÔ'NÐNå�k¥5¤8Ô#3Ñ4Ô4ð 	Ø�4à×"Ò"¥5¤8Ô#4×#>Ò#>Ñ#@Ô#@ÑAÔAð 	Ý˜h­Ñ-Ô-ð µ#ð 6ð 6Ø2:ð6ñ 6ô 6ñ 3ô 3ð õ
 ŒXÔ ¥)Ð,ÝŒXÔ¥ T¡
¤
Ð+ÝŒXÔ¥Ð%ÝŒXÔ�sÐ#ÝŒXÔ¥Ð'ÝŒXÔ!¥7Ð+ÝŒXÔ ¥4­­eµWÐ"=Ð>ðE
ˆð #+ð 	6ð 	6ÑˆH�hÝ˜+ xÑ0Ô0ð 6Ý! (¨HÑ5Ô5Ð5Ð5Ð5ð6ð ˜4ÐÐr$   rˆ   rJ   ú!tuple[FunctionSchema, ...] | Nonec                óŠ   — 	 d| vrd S t          t          j                             | ¦  «        ¦  «        S # t          $ r Y d S w xY w)Nz::)r£   rÑ   rÒ   Ú_jit_get_schemas_for_operatorÚRuntimeError©rˆ   s    r%   rÎ   zSchemaMatcher.lookup_schemas1  sY   € ð	ð ˜4ÐÐØ�tÝ�œ×?Ò?ÀÑEÔEÑFÔFÐFøÝð 	ð 	ð 	Ø�4�4ð	øøøs   ‚4 ˆ+4 ´
AÁAN)rr   r
   rI   r¨   )rr   r
   rI   r¹   rÍ   )rˆ   rJ   rI   ræ   )
r   r   r   r_   r|   r¸   r°   rÁ   r{   rÎ   r#   r$   r%   r§   r§   Õ   s£   € € € € € ð
ð 
ð ð:ð :ð :ñ „[ð:ð$ ðPð Pð Pñ „[ðPð2 ð ð  ð  ñ „[ð ðB ðð ð ñ „\ðð ð r$   r§   c                  ó6   — e Zd Zdd„Zdd„Zedd	„¦   «         Zd
S )ÚOpTreeÚresultr   rI   ÚNonec                ó¤   — |                      ¦   «         | _        t          t          |                      ¦   «         d„ ¬¦  «        ¦  «        | _        d S )Nc                ó   — | j         S rV   ©Ústart_time_ns©Úxs    r%   ú<lambda>z!OpTree.__init__.<locals>.<lambda>J  s   € ÀAÄO€ r$   ©Úkey)Úexperimental_event_treeÚ_root_nodesr£   ÚsortedÚdfsÚ_sorted_nodes©rP   rí   s     r%   Ú__init__zOpTree.__init__H  sE   € Ø!×9Ò9Ñ;Ô;ˆÔÝ"¥6¨$¯(ª(©*¬*Ð:SÐ:SÐ#TÑ#TÔ#TÑUÔUˆÔÐÐr$   úIterator[_ProfilerEvent]c              /  óJ   K  — t          j        | j        g|¢R i |¤ŽE d {V —† d S rV   )r   Útraverse_dfsrù   ©rP   ÚargsÚkwargss      r%   rû   z
OpTree.dfsL  sB   è è € ÝÔ& tÔ'7ÐI¸$ÐIÐIÐIÀ&ÐIÐIÐIÐIÐIÐIÐIÐIÐIÐIÐIr$   útuple[_ProfilerEvent, ...]c                ó   — | j         S rV   )rü   rO   s    r%   Úsorted_nodeszOpTree.sorted_nodesO  s   € àÔ!Ð!r$   N©rí   r   rI   rî   )rI   rÿ   ©rI   r  )r   r   r   rþ   rû   r}   r  r#   r$   r%   rì   rì   G  sd   € € € € € ðVð Vð Vð VðJð Jð Jð Jð ð"ð "ð "ñ „Xð"ð "ð "r$   rì   c                  ó>   — e Zd Zdd„Zdd„Zedd„¦   «         Zdd„ZdS )ÚSizeMapÚop_treerì   rI   rî   c                ó   — i | _         |j        D �]A}|j        d         t          j        k    r9|                      |j        d         ¦  «        D ]}|                      |¦  «         ŒŒW|j        d         t          j        k    rÏ|j        d         }|j        �|j	        �t          d¦  «        ‚|j        �=|j        j        D ]0\  }}}|                      |¦  «         |                      |¦  «         Œ1|j	        �Z|j	        j        D ]M\  }}}|                      |¦  «         |                      |¦  «         |D ]\  }}|                      |¦  «         ŒŒN�ŒCi }	|j        D ]˜}|j        d         t          j        k    r{|j        d         }
t                               |
¦  «        }|rRt          |
j        ¦  «        }|	                     ||¦  «        }||k    r"|› d|› �}t$                               d|¦  «         Œ™| j                              |	¦  «         d S )Nr   r�   r‚   z vs. z(Mismatch between allocation and free: %s)Ú_valuesr  r„   r   r…   Ú_flat_tensor_inputsÚ_update_valuesrŠ   r‹   rŒ   r�   rŽ   Ú
Allocationr   rq   ÚabsÚ
alloc_sizeÚ
setdefaultÚlogÚwarningÚupdate)rP   r  r~   rr   r�   r�   r‘   r’   ÚstateÚallocationsÚalloc_fieldsr÷   Únew_sizeÚ
prior_sizeÚdeltas                  r%   rþ   zSizeMap.__init__U  sJ  € Ø-/ˆŒàÔ(ð 	3ñ 	3ˆDØŒz˜!Œ}¥
Ô 2Ò2Ð2Ø×1Ò1°$´*¸Q´-Ñ@Ô@ð +ð +�AØ×'Ò'¨Ñ*Ô*Ð*Ð*ð+ð ”˜A”¥*Ô"3Ò3Ð3Ø#œz¨!œ}�à Ô'Ð3Ø$Ô.Ð:å(Ð)RÑSÔSÐSØÔ&Ð2Ø(4Ô(;Ô(Fð 4ð 4™˜˜1˜fØ×+Ò+¨AÑ.Ô.Ð.Ø×+Ò+¨FÑ3Ô3Ð3Ð3àÔ)Ð5Ø,8Ô,BÔ,Mð 3ð 3Ñ(˜˜6 5Ø×+Ò+¨AÑ.Ô.Ð.Ø×+Ò+¨FÑ3Ô3Ð3Ø$)ð 3ð 3™D˜A˜qØ ×/Ò/°Ñ2Ô2Ð2Ð2ð3ùð -/ˆØÔ(ð 	Wð 	WˆDØŒz˜!Œ}¥
Ô 5Ò5Ð5Ø#œz¨!œ}�Ý×/Ò/°Ñ=Ô=�Øð WÝ" <Ô#:Ñ;Ô;�HØ!,×!7Ò!7¸¸XÑ!FÔ!F�Jð " XÒ-Ð-Ø#-Ð >Ð >°HÐ >Ð >˜ÝŸšÐ$NÐPUÑVÔVÐVøàŒ×Ò˜KÑ(Ô(Ð(Ð(Ð(r$   rr   rs   c                óª  — t                                |¦  «        }|�²|�²|j        t          j        k    rŸt          d„ t          |j        pdg|j        pdgd¬¦  «        D ¦   «         ¦  «        }|t          |j
        ¦  «        z  }|dk     rt          d|› �¦  «        ‚t          | j                             |d¦  «        |¦  «        | j        |<   d S d S d S d S )Nc              3  ó8   K  — | ]}|d          |d         z  V — ŒdS ©r   r�   Nr#   r<   s     r%   r¯   z)SizeMap._update_values.<locals>.<genexpr>‰  s?   è è € ð ð Ø !��!”�q˜”t‘ðð ð ð ð ð r$   r�   TrÄ   r   z$num_bytes must be non-negative, got )r   rv   ÚlayoutrÑ   ÚstridedÚmaxrÈ   ÚsizesÚstridesr   Údtyper�   r  Úget)rP   rr   r÷   ÚnÚ	num_bytess        r%   r  zSizeMap._update_values…  sí   € Ý×#Ò# AÑ&Ô&ˆØˆ?˜q˜}°´½U¼]Ò1JÐ1Jåð ð Ý%(¨¬¨°Q°C¸¼Ð9IÀqÀcÐRVÐ%WÑ%WÔ%Wðñ ô ñ ô ˆAð �M¨!¬'Ñ2Ô2Ñ2ˆIØ˜1Š}ˆ}Ý$Ð%WÈIÐ%WÐ%WÑXÔXÐXÝ # D¤L×$4Ò$4°S¸!Ñ$<Ô$<¸iÑ HÔ HˆDŒL˜ÑÐÐð ˆ?˜}˜}Ð1JÐ1Jr$   Úopr
   úIterator[_TensorMetadata]c              #  óŒ   K  — | j         D ]9}t          |t          ¦  «        r|V — Œt          |t          ¦  «        r|E d {V —† Œ:d S rV   )r‰   rW   r   r¾   )r*  r0   s     r%   r  zSizeMap._flat_tensor_inputs’  sb   è è € à”ð 	ð 	ˆAÝ˜!�_Ñ-Ô-ð Ø����Ý˜A�tÑ$Ô$ð Ø�������øð		ð 	r$   r÷   r   c                ó   — | j         |         S rV   )r  ©rP   r÷   s     r%   Ú__getitem__zSizeMap.__getitem__š  s   € ØŒ|˜CÔ Ð r$   N©r  rì   rI   rî   )rr   rs   rI   rî   )r*  r
   rI   r+  )r÷   r   )r   r   r   rþ   r  r{   r  r/  r#   r$   r%   r  r  T  su   € € € € € ð.)ð .)ð .)ð .)ð`Ið Ið Ið Ið ðð ð ñ „\ðð!ð !ð !ð !ð !ð !r$   r  c                  ó\   — e Zd ZU dZded<   dZded<   edd	„¦   «         Zedd
„¦   «         ZdS )ÚDataFlowEdgeNri   Úinput_versionFzbool | NoneÚmutatedrI   rT   c                ó   — | j         d u S rV   )r3  rO   s    r%   Úis_allocationzDataFlowEdge.is_allocation£  s   € àÔ! TÐ)Ð)r$   c                ó   — | j         d u S rV   )r4  rO   s    r%   Úis_deletionzDataFlowEdge.is_deletion§  s   € àŒ|˜tÐ#Ð#r$   rÍ   )	r   r   r   r3  rC   r4  r}   r6  r8  r#   r$   r%   r2  r2  ž  sv   € € € € € € à $€MÐ$Ð$Ð$Ñ$Ø €GÐ Ð Ð Ñ àð*ð *ð *ñ „Xð*ð ð$ð $ð $ñ „Xð$ð $ð $r$   r2  c                  ó~   — e Zd Zdd„Zdd	„Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Z	dS )ÚDataFlowNoderœ   r   ÚgraphÚDataFlowGraphrI   rî   c                ó¸  ‡ — |‰ _         |‰ _        ‰                      ¦   «         ‰ _        ‰ j                             ¦   «         D ]-\  }}|j        r!|j        s‰ j                             |¦  «         Œ.ˆ fd„‰ j                             ¦   «         D ¦   «         }t          d„ | 
                    ¦   «         D ¦   «         ¦  «        st          d|› d‰ j        › �¦  «        ‚d S )Nc                óP   •— i | ]"\  }}||‰j                              |¦  «        f“Œ#S r#   )Ú_graphÚlookup)r/   ÚkÚvrP   s      €r%   r2   z)DataFlowNode.__init__.<locals>.<dictcomp>·  s4   ø€ ÐSÐSÐS±d°a¸�A˜˜4œ;×-Ò-¨aÑ0Ô0Ð1ÐSÐSÐSr$   c              3  ó(   K  — | ]\  }}||k    V — Œd S rV   r#   )r/   r0   r½   s      r%   r¯   z(DataFlowNode.__init__.<locals>.<genexpr>¸  s*   è è € Ð8Ð8™d˜a �1˜’6Ð8Ð8Ð8Ð8Ð8Ð8r$   zversion mismatch: z, )Ú_eventr?  Ú_determine_edgesÚ_edgesÚitemsr4  r6  ÚbumpÚoutputsrÇ   Úvaluesr�   )rP   rœ   r;  r÷   ÚedgeÚversionss   `     r%   rþ   zDataFlowNode.__init__­  sñ   ø€ ØˆŒØˆŒØ59×5JÒ5JÑ5LÔ5LˆŒàœ×*Ò*Ñ,Ô,ð 	&ð 	&‰IˆC�ØŒ|ð & DÔ$6ð &Ø”× Ò  Ñ%Ô%Ð%øð TÐSÐSÐS¸d¼l×>PÒ>PÑ>RÔ>RÐSÑSÔSˆÝÐ8Ð8 h§o¢oÑ&7Ô&7Ð8Ñ8Ô8Ñ8Ô8ð 	QÝ Ð!O°hÐ!OÐ!OÀ$Ä+Ð!OÐ!OÑPÔPÐPð	Qð 	Qr$   údict[TensorKey, DataFlowEdge]c                ó  — t          t          j        | j        g¦  «        ¦  «        }i }d„ |D ¦   «         D �]}t	          |j        t                               |¦  «        d¬¦  «        D ]Ó\  }}t          |t          ¦  «        rPt                               |¦  «        }|                     |t          ¦   «         ¦  «                             |¦  «         Œjt          |t          ¦  «        rT|D ]Q}t                               |¦  «        }|                     |t          ¦   «         ¦  «                             |¦  «         ŒRŒÔ�Œt!          j        t$          ¦  «        }|                     ¦   «         D ]T\  }}	|�M|r| j                             |¦  «        nd||         _        d|	v pt          |	¦  «        dk    }
|
||         _        ŒU|D ]¥}|j        d         t2          j        k    rˆ|j        d         j        dk     rrt                               |j        d         ¦  «        }||         }|�|j        €t;          d|› �¦  «        ‚d |_        |r| j                             |¦  «        nd|_        Œ¦|D ]c}|j        d         t2          j        k    rF|j        d         j        dk    r0d |t                               |j        d         ¦  «                 _        Œdt=          t?          d	„ |                     ¦   «         D ¦   «         ¦  «        ¦  «        S )
Nc              3  óf   K  — | ],}|j         d          t          j        k    ¯|j         d         V — Œ-dS r   )r„   r   r…   r<   s     r%   r¯   z0DataFlowNode._determine_edges.<locals>.<genexpr>À  s;   è è € ÐSÐS !°!´'¸!´*Å
Ô@RÒ2RÐ2R�1”7˜1”:Ð2RÐ2RÐ2RÐ2RÐSÐSr$   TrÄ   éÿÿÿÿrV   r   r�   zDouble delete: c              3  ó(   K  — | ]\  }}|®||fV — Œd S rV   r#   ©r/   rA  rB  s      r%   r¯   z0DataFlowNode._determine_edges.<locals>.<genexpr>í  s*   è è € ÐMÐM¡d a¨¸q¸}˜A˜q˜6¸}¸}¸}¸}ÐMÐMr$   ) r£   r   r  rD  rÈ   r‰   r§   r¸   rW   r   r   rv   r  ÚsetÚaddr¾   ÚcollectionsÚdefaultdictr2  rG  r?  r@  r3  r4  r„   r   r  r  rq   r�   Údictrú   )rP   ÚsubtreeÚmutable_by_keyr*  Úop_inputrµ   r÷   Ú
op_input_iÚedgesÚmutable_setr4  r0   rK  s                r%   rE  zDataFlowNode._determine_edges»  sü  € Ý�Ô+¨T¬[¨MÑ:Ô:Ñ;Ô;ˆð DFˆØSÐS wÐSÑSÔSð 	Kñ 	KˆBÝ%(Ø”	�=×;Ò;¸BÑ?Ô?Èð&ñ &ô &ð Kð KÑ!�˜'õ ˜h­Ñ8Ô8ð KÝ#×/Ò/°Ñ9Ô9�CØ"×-Ò-¨cµ3±5´5Ñ9Ô9×=Ò=¸gÑFÔFÐFÐFõ   ­$Ñ/Ô/ð KØ&.ð Kð K˜
Ý'×3Ò3°JÑ?Ô?˜Ø&×1Ò1°#µs±u´uÑ=Ô=×AÒAÀ'ÑJÔJÐJÐJøñKõ Ô'­Ñ5Ô5ˆØ .× 4Ò 4Ñ 6Ô 6ð 	-ð 	-ÑˆC�ØˆØFIÐ+Q¨4¬;×+=Ò+=¸cÑ+BÔ+BÐ+BÈr��c”
Ô(ð
   ;Ð.ÐRµE¸+Ñ4FÔ4FÈ'Ò4Q�Ø%,��c”
Ô"øð ð 	Lð 	LˆAØŒw�qŒz�ZÔ2Ò2Ð2°q´w¸q´zÔ7LÈqÒ7PÐ7PÝ×/Ò/°´¸´
Ñ;Ô;�Ø˜S”z�Ø�? t¤|Ð';Ý(Ð)@¸3Ð)@Ð)@ÑAÔAÐAØ#�”Ø@CÐ%K T¤[×%7Ò%7¸Ñ%<Ô%<Ð%<È�Ô"øð ð 	Rð 	RˆAØŒw�qŒz�ZÔ2Ò2Ð2°q´w¸q´zÔ7LÈqÒ7PÐ7PØMQ�•i×/Ò/°´¸´
Ñ;Ô;Ô<ÔJøõ •FÐMÐM¨e¯kªk©m¬mÐMÑMÔMÑMÔMÑNÔNÐNr$   ú!dict[TensorKey, tuple[bool, int]]c                óH   — d„ | j                              ¦   «         D ¦   «         S )Nc                ó€   — i | ];\  }}|j         °|t          |j        ¦  «        t          t          |j        ¦  «        f“Œ<S r#   )r6  rT   r4  r   rF   r3  rR  s      r%   r2   z'DataFlowNode.inputs.<locals>.<dictcomp>ñ  sS   € ð 
ð 
ð 
ñ ��1Ø”?ð
ð •�Q”Y‘”¥¥c¨1¬?Ñ!;Ô!;Ð<ð
ð 
ð 
r$   ©rF  rG  rO   s    r%   r‰   zDataFlowNode.inputsï  s3   € ð
ð 
ð œ×)Ò)Ñ+Ô+ð	
ñ 
ô 
ð 	
r$   údict[TensorKey, int]c                óH   — d„ | j                              ¦   «         D ¦   «         S )Nc                óf   — i | ].\  }}|j         r|j        r|j        ¯||j        €dn	|j        dz   “Œ/S r    )r6  r8  r4  r3  rR  s      r%   r2   z(DataFlowNode.outputs.<locals>.<dictcomp>û  s`   € ð 
ð 
ð 
á��1Ø”ð
ð )*¬ð
ð ;<¼)ð
Ø�A”OÐ+ˆqˆq°´À1Ñ1Dð
ð 
ð 
r$   ra  rO   s    r%   rI  zDataFlowNode.outputsù  s1   € ð
ð 
àœ×)Ò)Ñ+Ô+ð
ñ 
ô 
ð 	
r$   útuple[TensorKey, ...]c                ób   — t          d„ | j                             ¦   «         D ¦   «         ¦  «        S )Nc              3  ó<   K  — | ]\  }}|j         ¯|j        ¯|V — Œd S rV   )r6  r8  rR  s      r%   r¯   z-DataFlowNode.intermediates.<locals>.<genexpr>  sK   è è € ð 
ð 
Ù�!�Q°´ð
ØEFÄ]ð
Øð
ð 
ð 
ð 
ð 
ð 
r$   )r£   rF  rG  rO   s    r%   ÚintermediateszDataFlowNode.intermediates  s>   € åð 
ð 
Øœ+×+Ò+Ñ-Ô-ð
ñ 
ô 
ñ 
ô 
ð 	
r$   rF   c                ó   — | j         j        S rV   )rD  rò   rO   s    r%   Ú
start_timezDataFlowNode.start_time  s   € àŒ{Ô(Ð(r$   N)rœ   r   r;  r<  rI   rî   )rI   rM  )rI   r^  )rI   rb  )rI   re  r^   )
r   r   r   rþ   rE  r}   r‰   rI  rh  rj  r#   r$   r%   r:  r:  ¬  sÅ   € € € € € ðQð Qð Qð Qð2Oð 2Oð 2Oð 2Oðh ð
ð 
ð 
ñ „Xð
ð ð
ð 
ð 
ñ „Xð
ð ð
ð 
ð 
ñ „Xð
ð
 ð)ð )ð )ñ „Xð)ð )ð )r$   r:  c                  ó~   — e Zd Zdd„Zedd„¦   «         Zdd„Zedd
„¦   «         Zedd„¦   «         Z	dd„Z
dd„Zdd„ZdS )r<  r  rì   rI   rî   c                óè   ‡ — |‰ _         ‰                      |¦  «        ‰ _        i ‰ _        ˆ fd„‰ j        D ¦   «         ‰ _        ‰ j                             d„ ¬¦  «         ‰                      ¦   «          d S )Nc                ó0   •— g | ]}t          |‰¦  «        ‘ŒS r#   )r:  )r/   ÚerP   s     €r%   r¬   z*DataFlowGraph.__init__.<locals>.<listcomp>  s#   ø€ ÐLÐLÐL°a�L¨¨DÑ1Ô1ÐLÐLÐLr$   c                ó   — | j         S rV   )rj  ró   s    r%   rõ   z(DataFlowGraph.__init__.<locals>.<lambda>  s   € ¨A¬L€ r$   rö   )Ú_op_treeÚ_extract_leaf_eventsÚ_leaf_eventsÚ_active_versionÚleaf_eventsÚ_flow_nodesÚsortÚvalidate)rP   r  s   ` r%   rþ   zDataFlowGraph.__init__  sv   ø€ ØˆŒØ ×5Ò5°gÑ>Ô>ˆÔØ<>ˆÔØLÐLÐLÐL¸4Ô;KÐLÑLÔLˆÔØÔ×ÒÐ"8Ð"8ÐÑ9Ô9Ð9Ø�Š‰Œˆˆˆr$   útuple[DataFlowNode, ...]c                ó*   — t          | j        ¦  «        S rV   )r£   ru  rO   s    r%   Ú
flow_nodeszDataFlowGraph.flow_nodes  s   € å�TÔ%Ñ&Ô&Ð&r$   c           	     óP  — t          ¦   «         }| j        D ][}t          |j                             ¦   «         ¦  «        }||z  }|r't	          d|j        j        › d|j        › d|› �¦  «        ‚||z  }Œ\i }| j        D ]ª}|j                             ¦   «         D ]9\  }\  }}| 	                    |d¦  «        }	|	|k    rt	          d|	› d|› �¦  «        ‚Œ:|j                             ¦   «         D ];\  }}| 	                    ||¦  «        }
||
k     rt	          d|› d|
› �¦  «        ‚|||<   Œ<Œ«d S )Nzduplicate outputs: ú r   z%version mismatch for input: expected z, got zversion regression: z < )
rS  rz  rI  rG  r�   rD  rˆ   rF  r‰   r'  )rP   rI  r~   Únode_outputsÚ
duplicatesÚtensor_versionsr÷   r�   ÚversionÚexpectedÚprior_versions              r%   rw  zDataFlowGraph.validate  sš  € å.1©e¬eˆØ”Oð 	$ð 	$ˆDÝ˜tœ|×1Ò1Ñ3Ô3Ñ4Ô4ˆLØ  <Ñ/ˆJØð Ý$ØW¨$¬+Ô*:ÐWÐW¸T¼[ÐWÐWÈ:ÐWÐWñô ð ð �|Ñ#ˆGˆGð 13ˆØ”Oð 	/ð 	/ˆDØ%)¤[×%6Ò%6Ñ%8Ô%8ð ð Ñ!�‘\�a˜Ø*×.Ò.¨s°AÑ6Ô6�Ø˜wÒ&Ð&Ý(ØYÀÐYÐYÐPWÐYÐYñô ð ð 'ð
 !%¤× 2Ò 2Ñ 4Ô 4ð /ð /‘��WØ /× 3Ò 3°C¸Ñ AÔ A�Ø˜]Ò*Ð*Ý(ØJ¨wÐJÐJ¸=ÐJÐJñô ð ð (/� Ñ$Ð$ð/ð	/ð 	/r$   r  c                ó   — | j         S rV   )rr  rO   s    r%   rt  zDataFlowGraph.leaf_events7  s   € àÔ Ð r$   c                ó�   ‡‡— g Šd
d„Šdˆˆfd„}|                       |¬¦  «        D ]}Œt          t          ‰d„ ¬	¦  «        ¦  «        S )aÿ  Partially traverse the op tree and extract top level ops.

        Consider the following code:
        ```
        with record_function("My annotation"):
            x.zero_()
            y.zero_()
        ```

        The op tree (assuming no Autograd) will look like:
          <Python context>
            TorchOp: "My annotation"
              TorchOp: zero_
                TorchOp: fill_
              TorchOp: zero_
                TorchOp: fill_

        The recursive structure of operator calls makes data flow unwieldy.
        In order to simplify analysis we would like to select the highest level
        ops to represent in the graph. In this case those are the `zero_` ops;
        the fact that `fill_` is called is an implementation detail. We also
        do not want to group everything under "My annotation" as this could
        create overly coarse bundles and lose critical semantics.

        To address this issue we walk over the graph and select the topmost
        torch ops ** which match at least one operator schema **. These form
        the leaves of the first pass through the op tree. (As well as any
        allocations or frees which do are not part of a kernel.) These events
        form the logical nodes in our data flow graph.
        rn  r   rI   rT   c                óÜ   — | j         d         t          j        k    oQ| j         d         j        t          j        k    p1t          t                               | j         d         ¦  «        ¦  «        S r    )	r„   r   r…   r†   r   r‡   rT   r§   r°   )rn  s    r%   Úleaf_opz3DataFlowGraph._extract_leaf_events.<locals>.leaf_op^  sV   € Ø”7˜1”:¥Ô!3Ò3ð Ø”˜”
Ô ¥KÔ$AÒAð AÝ�×3Ò3°A´G¸A´JÑ?Ô?Ñ@Ô@ðr$   c                ó€   •—  ‰| ¦  «        s| j         t          j        k    r‰                     | ¦  «         g S | j        S rV   )Útagr   r  r¡   rƒ   )rn  rt  r†  s    €€r%   Úchildren_fnz7DataFlowGraph._extract_leaf_events.<locals>.children_fnd  sC   ø€ Øˆw�q‰zŒzð ˜QœU¥jÔ&;Ò;Ð;Ø×"Ò" 1Ñ%Ô%Ð%Ø�	à”:Ðr$   )r‰  c                ó   — | j         S rV   rñ   ró   s    r%   rõ   z4DataFlowGraph._extract_leaf_events.<locals>.<lambda>n  s   € °q´€ r$   rö   )rn  r   rI   rT   )rn  r   )rû   r£   rú   )r  r‰  r�   rt  r†  s      @@r%   rq  z"DataFlowGraph._extract_leaf_events;  s„   øø€ ðB -/ˆð	ð 	ð 	ð 	ð	ð 	ð 	ð 	ð 	ð 	ð 	ð —’¨�Ñ5Ô5ð 	ð 	ˆAØå•V˜KÐ-FÐ-FÐGÑGÔGÑHÔHÐHr$   r÷   r   rF   c                óf   — | j                              |d¦  «        }|€t          d|› d�¦  «        ‚|S )Nr   zversion for key ú is None©rs  r  r�   )rP   r÷   r€  s      r%   r@  zDataFlowGraph.lookupp  s>   € ØÔ&×1Ò1°#°qÑ9Ô9ˆØˆ?Ý Ð!A°CÐ!AÐ!AÐ!AÑBÔBÐBØˆr$   c                ó€   — | j                              |d ¦  «        }|€t          d|› d�¦  «        ‚|dz   | j         |<   d S )Nzprior_version for key rŒ  r�   )rs  r'  r�   )rP   r÷   r‚  s      r%   rH  zDataFlowGraph.bumpv  sR   € ØÔ,×0Ò0°°dÑ;Ô;ˆØÐ Ý Ð!G¸#Ð!GÐ!GÐ!GÑHÔHÐHØ$1°AÑ$5ˆÔ˜SÑ!Ð!Ð!r$   c                óv   — | j                              |d¦  «        €t          d|› d�¦  «        ‚d | j         |<   d S )Nr   zcannot delete key z, already deletedr�  r.  s     r%   ÚdeletezDataFlowGraph.delete|  sH   € ØÔ×*Ò*¨3°Ñ2Ô2Ð:Ý Ð!L°cÐ!LÐ!LÐ!LÑMÔMÐMØ$(ˆÔ˜SÑ!Ð!Ð!r$   Nr0  )rI   rx  ©rI   rî   r	  )r  rì   rI   r  )r÷   r   rI   rF   )r÷   r   rI   rî   )r   r   r   rþ   r}   rz  rw  rt  r{   rq  r@  rH  r�  r#   r$   r%   r<  r<    sÝ   € € € € € ðð ð ð ð ð'ð 'ð 'ñ „Xð'ð/ð /ð /ð /ð< ð!ð !ð !ñ „Xð!ð ð2Ið 2Ið 2Iñ „\ð2Iðhð ð ð ð6ð 6ð 6ð 6ð)ð )ð )ð )ð )ð )r$   r<  c                  ó¢   — e Zd ZU dZded<    ej        e¬¦  «        Zded<    ej        e¬¦  «        Z	ded<    ej        e
¬¦  «        Zd	ed
<   dS )ÚCategoryElementNúCategory | NoneÚby_id©Údefault_factoryzdict[TensorKey, Category]Úby_keyzdict[TensorAndID, Category]Ú
by_versionzset[TensorKey]Ú_by_id_keyset)r   r   r   r•  rC   ÚdataclassesÚfieldrW  r˜  r™  rS  rš  r#   r$   r%   r“  r“  ‚  s‰   € € € € € € à!€EÐ!Ð!Ð!Ñ!Ø(9¨Ô(9È$Ð(OÑ(OÔ(O€FÐOÐOÐOÑOØ.?¨kÔ.?ÐPTÐ.UÑ.UÔ.U€JÐUÐUÐUÑUð %6 KÔ$5ÀcÐ$JÑ$JÔ$J€MÐJÐJÐJÑJÐJÐJr$   r“  c                  óf   — e Zd ZU  ej        d„ ¬¦  «        Zded<   dd„Zdd„Zdd„Z	dd„Z
dd„ZdS )ÚCategoryDictc                 ó4   — t          j        t          ¦  «        S rV   )rU  rV  r“  r#   r$   r%   rõ   zCategoryDict.<lambda>�  s   € ¥Ô 7½Ñ HÔ H€ r$   r–  z-collections.defaultdict[int, CategoryElement]r  r÷   r   Úcategoryr   rI   rî   c                óˆ   — || j         |j                 _        | j         |j                 j                             |¦  «         d S rV   )r  ra   r•  rš  rT  ©rP   r÷   r   s      r%   Ú	set_by_idzCategoryDict.set_by_id“  s9   € Ø%-ˆŒ�S”VÔÔ"ØŒ�S”VÔÔ*×.Ò.¨sÑ3Ô3Ð3Ð3Ð3r$   c                ó:   — || j         |j                 j        |<   d S rV   )r  ra   r˜  r¢  s      r%   Ú
set_by_keyzCategoryDict.set_by_key—  s   € Ø+3ˆŒ�S”VÔÔ# CÑ(Ð(Ð(r$   r€  rF   c                ó>   — || j         |j                 j        ||f<   d S rV   )r  ra   r™  ©rP   r÷   r€  r   s       r%   Úset_by_versionzCategoryDict.set_by_versionš  s"   € Ø:BˆŒ�S”VÔÔ'¨¨g¨Ñ7Ð7Ð7r$   c                ó`   — | j         |j                 j                             ||f|¦  «         d S rV   )r  ra   r™  r  r§  s       r%   Úsetdefault_by_versionz"CategoryDict.setdefault_by_version�  s0   € ð 	Œ�S”VÔÔ'×2Ò2°C¸°>À8ÑLÔLÐLÐLÐLr$   r   r”  c                óü   — t          |t          ¦  «        rt          |t          ¦  «        sd S | j        |j                 }|j        p7|j                             |d ¦  «        p|j                             ||fd ¦  «        S rV   )	rW   r   r   r  ra   r•  r˜  r'  r™  )rP   r÷   r€  Úelements       r%   r'  zCategoryDict.get¢  s{   € Ý�c�3ÑÔð 	­
°3½	Ñ(BÔ(Bð 	Ø�4Ø”,˜sœvÔ&ˆàŒMð <ØŒ~×!Ò! # tÑ,Ô,ð<àÔ!×%Ò% s¨G n°dÑ;Ô;ð	
r$   N)r÷   r   r   r   rI   rî   )r÷   r   r€  rF   r   r   rI   rî   )r÷   r   r€  rF   rI   r”  )r   r   r   r›  rœ  r  rC   r£  r¥  r¨  rª  r'  r#   r$   r%   rž  rž  �  sµ   € € € € € € à=N¸[Ô=NØHÐHð>ñ >ô >€Gð ð ð ñ ð4ð 4ð 4ð 4ð4ð 4ð 4ð 4ðCð Cð Cð CðMð Mð Mð Mð

ð 
ð 
ð 
ð 
ð 
r$   rž  c                  ó~   — e Zd Zdd„Zedd„¦   «         Zdd	„Zdd„Zdd„Zdd„Z	dd„Z
dd„Zdd„Zdd„Zdd„Zdd„ZdS )ÚMemoryProfilerí   r   rI   rî   c                óÐ  — t          |¦  «        | _        t          | j        ¦  «        | _        t	          | j        ¦  «        | _        t          ¦   «         | _        |                      ¦   «          |  	                    ¦   «          |  
                    ¦   «          |                      ¦   «          |                      ¦   «          |                      ¦   «          |                      ¦   «          d S rV   )rì   rp  r<  Ú_data_flow_graphr  Ú	_size_maprž  Ú_categoriesÚ_set_gradients_and_temporariesÚ#_set_parameters_using_python_tracerÚ_set_inputsÚ_set_parameters_using_data_flowÚ_set_activationsÚ_set_optimizer_stateÚ_set_autograd_detailrý   s     r%   rþ   zMemoryProfile.__init__®  sÂ   € Ý˜v™œˆŒÝ -¨d¬mÑ <Ô <ˆÔÝ  ¤Ñ/Ô/ˆŒÝ'™>œ>ˆÔà×+Ò+Ñ-Ô-Ð-Ø×0Ò0Ñ2Ô2Ð2Ø×ÒÑÔÐØ×,Ò,Ñ.Ô.Ð.Ø×ÒÑÔÐØ×!Ò!Ñ#Ô#Ð#Ø×!Ò!Ñ#Ô#Ð#Ð#Ð#r$   ú-tuple[tuple[int, Action, KeyAndID, int], ...]c           	     óÖ  ‡ ‡— g }i Ši }‰ j                              ¦   «         D �]?}|j        d         t          j        k    �r |j        d         }|j        }|dk    }|j        }t                               |¦  «        }|�|‰||f<   Œdt          |j
        ¦  «        }	|j        |	j
        f}
|rU|
|v r&|                     |t          j        |	df|f¦  «         Œ²d||
<   |                     |t          j        |	df|f¦  «         ŒÝ|                     |t          j        |	df| f¦  «         |                     |
d¦  «        s&|                     dt          j        |	df| f¦  «         �ŒA‰                      ¦   «         }t)          t+          |                     ¦   «         ¦  «        ¦  «        }ˆfd„|D ¦   «         }‰ j        j        D ]ä}|j                             ¦   «         D ]È\  }	}|j        r/‰|	df         }|                     |t          j        |	dff¦  «         nR|j        rK|j        j        }|j        }|€t?          d|	› �¦  «        ‚|                     |t          j        |	|ff¦  «         |j         r4‰|	df         }|                     |t          j        |	||	         ff¦  «         ŒÉŒå| !                    ˆ fd„|D ¦   «         ¦  «         | "                    d	„ ¬
¦  «         tG          |¦  «        S )Nr   r�   TFrP  c                óP   •— g | ]"\  }}|d f‰v¯|dk    ¯dt           j        ||ff‘Œ#S )Tr   rP  )r4   r5   )r/   r÷   r€  Úallocation_timess      €r%   r¬   z*MemoryProfile.timeline.<locals>.<listcomp>â  sK   ø€ ð 9
ð 9
ð 9
á��WØ�Tˆ{Ð"2Ð2Ð2°wÀ!²|°|ð •Ô# c¨7 ^Ð4à7C°|°|r$   zinput_version is None for key c              3  óL   •K  — | ]\  }}\  }}||||f‰j         |         fV — Œd S rV   )r±  )r/   ÚtimeÚactionr÷   r€  rP   s        €r%   r¯   z)MemoryProfile.timeline.<locals>.<genexpr>ù  sU   øè è € ð 
ð 
á,��f™n˜s Gð �6˜C ˜>¨4¬>¸#Ô+>Ð?ð
ð 
ð 
ð 
ð 
ð 
r$   c                ó,   — | d         | d         j         fS r    r:   ró   s    r%   rõ   z(MemoryProfile.timeline.<locals>.<lambda>þ  s   €  1 Q¤4¨¨1¬¬Ð"4€ r$   rö   )$rp  rû   r„   r   r  r  rò   r   rq   r   rB   rG   r¡   r4   r7   r6   r8   Úpopr5   Ú_category_snapshotrW  rú   Úkeysr°  rz  rF  rG  r6  r4  rD  r3  r�   r8  Úextendrv  r£   )rP   ÚoutputÚlive_unknownrœ   r  r  r6  rr   Útkeyr÷   Úptr_and_deviceÚsnapshotÚlast_versionÚeventsr~   rK  r€  r½  s   `                @r%   ÚtimelinezMemoryProfile.timeline¼  sb  øø€ à:<ˆØ>@ÐØFHˆà”]×&Ò&Ñ(Ô(ð 	ñ 	ˆEØŒ{˜1Œ~¥Ô!6Ò6Ñ6Ø$œ{¨1œ~�Ø)Ô4�
Ø *¨Q¢�ØÔ'�å ×0Ò0°Ñ>Ô>�ØÐ#Ø>?Ð$ d¨MÐ%:Ñ;Ð;õ ˜lÔ1Ñ2Ô2�CØ&2Ô&6¸¼
Ð%C�NØ$ð Ø)¨\Ð9Ð9Ø"ŸMšMØ!"¥FÔ$<¸sÀA¸hÈ
Ð Sñô ð ð ð <@˜L¨Ñ8Ø"ŸMšM¨1­f¬m¸cÀ1¸XÀzÐ*RÑSÔSÐSÐSàŸš q­&¬.¸3À¸(ÀZÀKÐ&PÑQÔQÐQØ+×/Ò/°ÀÑFÔFð Ø"ŸMšMØ!#¥VÔ%7¸#¸q¸ÀJÀ;Ð Oñô ð ùð ×*Ò*Ñ,Ô,ˆÝ�F 8§=¢=¡?¤?Ñ3Ô3Ñ4Ô4ˆð9
ð 9
ð 9
ð 9
à (ð9
ñ 9
ô 9
ˆð Ô)Ô4ð 	Qð 	QˆDØ!œ[×.Ò.Ñ0Ô0ð Qð Q‘	��TØÔ%ð 	QØ(¨#¨t¨Ô5�AØ—M’M 1¥f¤m°c¸1°XÐ">Ñ?Ô?Ð?Ð?à”\ð QØœÔ1�AØ"Ô0�GØ�Ý,Ð-SÈcÐ-SÐ-SÑTÔTÐTØ—M’M 1¥fÔ&>ÀÀgÀÐ"OÑPÔPÐPàÔ#ð QØ(¨#¨u¨Ô6�AØ—M’M 1¥f¤n°s¸LÈÔ<MÐ6NÐ"OÑPÔPÐPøðQð  	�Šð 
ð 
ð 
ð 
à06ð
ñ 
ô 
ñ 	
ô 	
ð 	
ð
 	�ŠÐ4Ð4ˆÑ5Ô5Ð5Ý�V‰}Œ}Ðr$   rT   c                óB   —  | j         j        |i |¤Žt          j        k    S rV   )r²  r'  r   r   r  s      r%   Ú_is_gradientzMemoryProfile._is_gradient  s%   € Ø#ˆtÔÔ# TÐ4¨VÐ4Ð4½Ô8IÒIÐIr$   ú"dict[TensorAndID, Category | None]c                ó
  ‡ — t          ¦   «         }‰ j        j        D ]ˆ}|                     d„ |j                             ¦   «         D ¦   «         ¦  «         |                     d„ |j        D ¦   «         ¦  «         |                     |j                             ¦   «         ¦  «         Œ‰‰ j        j	         
                    ¦   «         D ]&}|                     d„ |j        D ¦   «         ¦  «         Œ'ˆ fd„t          |¦  «        D ¦   «         S )Nc              3  ó*   K  — | ]\  }\  }}||fV — Œd S rV   r#   )r/   rA  r�   rB  s       r%   r¯   z3MemoryProfile._category_snapshot.<locals>.<genexpr>  s.   è è € Ð'TÐ'T±9°1±f°q¸!¨¨A¨Ð'TÐ'TÐ'TÐ'TÐ'TÐ'Tr$   c              3  ó   K  — | ]}|d fV — Œ	dS ©r   Nr#   ©r/   r÷   s     r%   r¯   z3MemoryProfile._category_snapshot.<locals>.<genexpr>	  s&   è è € Ð&NÐ&N°C¨¨Q xÐ&NÐ&NÐ&NÐ&NÐ&NÐ&Nr$   c              3  ó   K  — | ]}|d fV — Œ	dS rÔ  r#   rÕ  s     r%   r¯   z3MemoryProfile._category_snapshot.<locals>.<genexpr>  s&   è è € Ð&KÐ&K°C¨¨Q xÐ&KÐ&KÐ&KÐ&KÐ&KÐ&Kr$   c                óR   •— i | ]#\  }}||f‰j                              ||¦  «        “Œ$S r#   ©r²  r'  )r/   r÷   r€  rP   s      €r%   r2   z4MemoryProfile._category_snapshot.<locals>.<dictcomp>  sF   ø€ ð 
ð 
ð 
á��Wð �'ˆN˜DÔ,×0Ò0°°gÑ>Ô>ð
ð 
ð 
r$   )rS  r°  rz  r  r‰   rG  rh  rI  r²  r  rJ  rš  rú   )rP   Úall_tensor_versionsr~   r0   s   `   r%   rÃ  z MemoryProfile._category_snapshot  s  ø€ Ý03±´ÐàÔ)Ô4ð 	=ð 	=ˆDØ×&Ò&Ð'TÐ'TÀÄ×@QÒ@QÑ@SÔ@SÐ'TÑ'TÔ'TÑUÔUÐUØ×&Ò&Ð&NÐ&N¸4Ô;MÐ&NÑ&NÔ&NÑNÔNÐNØ×&Ò& t¤|×'9Ò'9Ñ';Ô';Ñ<Ô<Ð<Ð<àÔ!Ô)×0Ò0Ñ2Ô2ð 	Lð 	LˆAØ×&Ò&Ð&KÐ&K¸1¼?Ð&KÑ&KÔ&KÑKÔKÐKÐKð
ð 
ð 
ð 
å &Ð':Ñ ;Ô ;ð
ñ 
ô 
ð 	
r$   úset[int]c                óh  ‡ ‡— t          ¦   «         Š	 t          ‰¦  «        }‰ j        j        D ]p}t	          ˆˆ fd„|j                             ¦   «         D ¦   «         ¦  «        }|r9‰                     |¦  «         ‰                     d„ |j        D ¦   «         ¦  «         Œqt          ‰¦  «        |k    r‰S Œ¢)a\  Extract IDs of Tensors which depend or will depend on a gradient.

        Note that this weakened definition of "depends" requires us to loop
        over the data flow graph multiple times because it allows dependency
        information to flow backward through edges and removes the guarantee
        that nodes are topologically sorted. (Or indeed, even that a valid
        topological order exists.) Put another way, we have converted an
        acyclic data flow graph into a cyclic graph and we are attempting to
        partition cycles involving a gradient from the rest of the graph.
        Tc              3  óª   •K  — | ]M\  }\  }}‰j                              ||¦  «        t          j        t          j        fv s	|j        ‰v ¯D|j        V — ŒNd S rV   )r²  r'  r   r   r!   ra   )r/   r÷   r�   r€  Údepends_on_gradientrP   s       €€r%   r¯   zAMemoryProfile._any_version_depends_on_gradient.<locals>.<genexpr>#  sw   øè è € ð ð á)˜™\˜a ØÔ'×+Ò+¨C°Ñ9Ô9Ý Ô)­8Ô+=Ð>ð?ð ?à”vÐ!4Ð4Ð4ð	 ”Fð 5Ð4Ð4Ð4ðð r$   c              3  ó$   K  — | ]}|j         V — Œd S rV   ©ra   rÕ  s     r%   r¯   zAMemoryProfile._any_version_depends_on_gradient.<locals>.<genexpr>.  s$   è è € Ð.NÐ.N¸#¨s¬vÐ.NÐ.NÐ.NÐ.NÐ.NÐ.Nr$   )	rS  rÆ   r°  rz  r£   r‰   rG  r  rI  )rP   Ú
start_sizer~   ÚidsrÝ  s   `   @r%   Ú _any_version_depends_on_gradientz.MemoryProfile._any_version_depends_on_gradient  sè   øø€ õ ),©¬Ðð	+ÝÐ0Ñ1Ô1ˆJØÔ-Ô8ð Oð O�Ýð ð ð ð ð à-1¬[×->Ò->Ñ-@Ô-@ðñ ô ñ ô �ð ð OØ'×.Ò.¨sÑ3Ô3Ð3à'×.Ò.Ð.NÐ.NÀÄÐ.NÑ.NÔ.NÑNÔNÐNøõ Ð&Ñ'Ô'¨:Ò5Ð5Ø*Ð*ð-	+r$   c                ó.  — | j                              ¦   «         D ]<}t          |¦  «        D ]*\  }}| j                             |t
          j        ¦  «         Œ+Œ=| j        j        D ]1}|j	        D ]'}| j         
                    |t
          j        ¦  «         Œ(Œ2dS )z>Mark Tensors which are unambiguous and simple to reason about.N)rp  rû   r›   r²  r£  r   r   r°  rz  rh  r¥  r   )rP   rœ   r�   r’   r~   r0   s         r%   r³  z,MemoryProfile._set_gradients_and_temporaries8  sÃ   € ð ”]×&Ò&Ñ(Ô(ð 	Fð 	FˆEÝ.¨uÑ5Ô5ð Fð F‘	��6ØÔ ×*Ò*¨6µ8Ô3DÑEÔEÐEÐEðFð Ô)Ô4ð 	Cð 	CˆDØÔ'ð Cð C�ØÔ ×+Ò+¨A­xÔ/AÑBÔBÐBÐBðCð	Cð 	Cr$   c                ó°   — | j                              ¦   «         D ];}t          |¦  «        D ])}|�%| j                             |t
          j        ¦  «         Œ*Œ<d S rV   )rp  rû   r˜   r²  r£  r   r!   )rP   rœ   r‘   s      r%   r´  z1MemoryProfile._set_parameters_using_python_tracerI  sn   € Ø”]×&Ò&Ñ(Ô(ð 	Fð 	FˆEÝ'¨Ñ.Ô.ð Fð F�Ø�=ØÔ$×.Ò.¨qµ(Ô2DÑEÔEÐEøðFð	Fð 	Fr$   c                óŒ  ‡ ‡— ‰                       ¦   «         }t          ¦   «         Št          ‰ j        j        ¦  «        D ]b}d„ |j                             ¦   «         D ¦   «         }||j                             ¦   «         z  }t          ˆˆ fd„|D ¦   «         ¦  «        r‰|z  ŠŒc‰ 	                    ¦   «         }‰ j        j        D ]K}t          j        t          |j        ¦  «        v r)|t          |j                             ¦   «         ¦  «        z  }ŒL|D ]4\  }}|j        |vr&‰ j                             ||t"          j        ¦  «         Œ5dS )aÍ  Mark inputs based on which Tensors are updated using gradients.

        The process for differentiating between inputs and activations is more
        involved. Most Tensors in a training loop depend on at least one
        gradient: parameters depend on them through updates, and activations
        and optimizer state depend on them transitively through parameters.
        Critically, we do not need to know which Tensors are parameters to
        apply this method; we can simply walk the data flow graph to build the
        set of all values which depend on a gradient and then obtain the set
        of inputs from the conjugate set.

        There is, however, one hiccup. The first time we see a parameter is
        generally on the forward pass of the first step. We know from
        inspection of the data flow graph that v1 of that Tensor depends on
        a gradient (provided we profile an optimizer step), but not v0. To
        address this problem we weaken the definition of "depends on a
        gradient" to "any version of this Tensor depends on a gradient",
        which in turn strengthens the criteria for the input set enough to
        filter the activations in the forward pass of the first step.c                ó"   — h | ]\  }\  }}||f’ŒS r#   r#   ©r/   r÷   r�   r€  s       r%   ú	<setcomp>z,MemoryProfile._set_inputs.<locals>.<setcomp>n  s%   € ÐSÐSÐSÑ*;¨#©|°°7˜˜W�~ÐSÐSÐSr$   c              3  ón   •K  — | ]/} ‰j         j        |Ž t          j        t          j        fv p|‰v V — Œ0d S rV   )r²  r'  r   r   r!   )r/   r0   Úproduces_gradientrP   s     €€r%   r¯   z,MemoryProfile._set_inputs.<locals>.<genexpr>p  sd   øè è € ð ð ð ð %�Ô Ô$ aÐ(­XÔ->ÅÔ@RÐ,SÐSð *ØÐ)Ð)ðð ð ð ð ð r$   N)râ  rS  Úreversedr°  rz  r‰   rG  rI  ÚanyÚcopyr   r‡   r¥   rD  ra   r²  rª  r   r   )rP   rÝ  r~   ÚtensorsÚinput_candidatesr÷   r€  rê  s   `      @r%   rµ  zMemoryProfile._set_inputsO  sw  øø€ ð2 #×CÒCÑEÔEÐõ /2©e¬eÐÝ˜TÔ2Ô=Ñ>Ô>ð 	-ð 	-ˆDØSÐS¸t¼{×?PÒ?PÑ?RÔ?RÐSÑSÔSˆGØ�t”|×)Ò)Ñ+Ô+Ñ+ˆGÝð ð ð ð ð ð !ðñ ô ñ ô ð -ð
 " WÑ,Ð!øð -×1Ò1Ñ3Ô3ÐØÔ)Ô4ð 	>ð 	>ˆDÝÔ,µ
¸4¼;Ñ0GÔ0GÐGÐGØ ¥C¨¬×(:Ò(:Ñ(<Ô(<Ñ$=Ô$=Ñ=Ð øà,ð 	Uð 	U‰LˆC�ØŒvÐ0Ð0Ð0ØÔ ×6Ò6°s¸GÅXÄ^ÑTÔTÐTøð	Uð 	Ur$   c                ó\  ‡ ‡	— ‰                       ¦   «         }t          ¦   «         }d„ |                     ¦   «         D ¦   «         }‰ j        j        D ]Û}d„ |j                             ¦   «         D ¦   «         }t          j        t          |j	        ¦  «        vr–t          ˆ fd„|D ¦   «         ¦  «        s{t          ˆ fd„|j                             ¦   «         D ¦   «         ¦  «        sI|                     |¦  «        r4||j                             ¦   «         z  }||                     |¦  «        z  }ŒÜt          ¦   «         Š	t          ‰ j        j        ¦  «        D ]k}t          ˆ ˆ	fd„|j                             ¦   «         D ¦   «         ¦  «        r6‰	                     d„ |j                             ¦   «         D ¦   «         ¦  «         Œl|                     ‰	¦  «         d„ |D ¦   «         }|‰                      ¦   «         z  }|D ]3\  }}|j        |v r%‰ j                             |t*          j        ¦  «         Œ4dS )	aþ  Deduce which Tensors are parameters.

        Consider the following code for the step of SGD with momentum
        (nesterov=False), where `d_p` is the gradient of `param` and `buf` is
        the momentum buffer.
        ```
          buf.mul_(momentum).add_(d_p, alpha=1 - dampening)
          d_p = buf
          param.add_(d_p, alpha=-lr)
        ```
        Both `param` and `buf` take a gradient and perform an in-place update.

        The python tracer will inspect calls to `nn.Module.forward` and
        `optim.Optimizer.step` to extract parameter and optimizer state
        respectively (including parameters), so this is generally a non-issue.

        However as a fallback we can also exploit several properties of
        parameters to distinguish them from other model state.

        First, they are directly used in the forward pass. (At this point we
        haven't established which parts of the graph correspond to the forward
        pass but we can deduce enough to suffice.) Some mutable state such as
        batch norm moving averages also contribute to the forward pass, but
        optimizer state does not.

        Second, a parameter is by definition used to compute at least one
        gradient and depends on at least one gradient.
        c                ó8   — h | ]\  }}|t           j        k    ¯|’ŒS r#   )r   r   )r/   r0   r   s      r%   rè  z@MemoryProfile._set_parameters_using_data_flow.<locals>.<setcomp>¦  s/   € ð 3
ð 3
ð 3
Ù�!�X°XÅÄÒ5OÐ5OˆAÐ5OÐ5OÐ5Or$   c                ó"   — h | ]\  }\  }}||f’ŒS r#   r#   ©r/   r÷   r�   r;   s       r%   rè  z@MemoryProfile._set_parameters_using_data_flow.<locals>.<setcomp>«  ó$   € ÐNÐNÐN¡ s©J¨Q°�s˜E�lÐNÐNÐNr$   c              3  ó,   •K  — | ]} ‰j         |Ž V — Œd S rV   ©rÏ  ©r/   r0   rP   s     €r%   r¯   z@MemoryProfile._set_parameters_using_data_flow.<locals>.<genexpr>¯  s.   øè è € ÐBÐB°aÐ-˜DÔ-¨qÐ1ÐBÐBÐBÐBÐBÐBr$   c              3  ó,   •K  — | ]} ‰j         |Ž V — Œd S rV   rö  r÷  s     €r%   r¯   z@MemoryProfile._set_parameters_using_data_flow.<locals>.<genexpr>°  s.   øè è € ÐPÐP°aÐ-˜DÔ-¨qÐ1ÐPÐPÐPÐPÐPÐPr$   c              3  ó4   •K  — | ]} ‰j         |Ž p|‰v V — Œd S rV   rö  )r/   r0   rP   Úused_for_gradients     €€r%   r¯   z@MemoryProfile._set_parameters_using_data_flow.<locals>.<genexpr>»  sL   øè è € ð ð àð "�Ô! 1Ð%Ð?¨Ð.?Ð)?ðð ð ð ð ð r$   c              3  ó*   K  — | ]\  }\  }}||fV — Œd S rV   r#   rç  s       r%   r¯   z@MemoryProfile._set_parameters_using_data_flow.<locals>.<genexpr>¿  s?   è è € ð )ð )Ù'8 s©L¨Q°�S˜'�Nð)ð )ð )ð )ð )ð )r$   c                ó"   — h | ]\  }}|j         ’ŒS r#   rß  )r/   r÷   r�   s      r%   rè  z@MemoryProfile._set_parameters_using_data_flow.<locals>.<setcomp>Å  s   € ÐDÐDÐD¡V S¨!˜#œ&ÐDÐDÐDr$   N)rÃ  rS  rG  r°  rz  r‰   r   r‡   r¥   rD  rì  rI  ÚintersectionÚ
differencerë  r  Úintersection_updaterâ  ra   r²  r£  r   r!   )
rP   rÊ  Úcandidate_parametersÚcandidate_fwd_tensorsr~   r‰   Úparameter_keysr÷   r�   rú  s
   `        @r%   r¶  z-MemoryProfile._set_parameters_using_data_flow‚  s‘  øø€ ð: ×*Ò*Ñ,Ô,ˆõ 25±´Ðð3
ð 3
Ø!)§¢Ñ!1Ô!1ð3
ñ 3
ô 3
Ðð Ô)Ô4ð 	Qð 	QˆDØNÐN¸$¼+×:KÒ:KÑ:MÔ:MÐNÑNÔNˆFõ Ô-µZÀÄÑ5LÔ5LÐLÐLÝÐBÐBÐBÐB¸6ÐBÑBÔBÑBÔBð MåÐPÐPÐPÐP¸4¼<×;MÒ;MÑ;OÔ;OÐPÑPÔPÑPÔPð Mð
 *×6Ò6°vÑ>Ô>ð Mð &¨¬×);Ò);Ñ)=Ô)=Ñ=Ð%Ø$¨×(9Ò(9Ð:OÑ(PÔ(PÑPÐ$øõ /2©e¬eÐÝ˜TÔ2Ô=Ñ>Ô>ð 	ð 	ˆDÝð ð ð ð ð àœ×+Ò+Ñ-Ô-ðñ ô ñ ô ð ð "×(Ò(ð )ð )Ø<@¼K×<MÒ<MÑ<OÔ<Oð)ñ )ô )ñ ô ð øð 	×0Ò0Ð1BÑCÔCÐCð EÐDÐ/CÐDÑDÔDˆØ˜$×?Ò?ÑAÔAÑAˆàð 	Dð 	D‰FˆC�ØŒv˜Ð'Ð'ØÔ ×*Ò*¨3µÔ0BÑCÔCÐCøð	Dð 	Dr$   c                ó¶  ‡ — t           j        t           j        h}t           j        t           j        h}‰ j        j        D ]š}d„ |j                             ¦   «         D ¦   «         }ˆ fd„|D ¦   «         }||z  rb|||z  z
  sZt          j
        t          |j        ¦  «        vr:|j                             ¦   «         D ] } ‰ j        j        g |¢t           j        ‘R Ž  Œ!Œ›dS )z(Flood the graph to identify activations.c                ó"   — h | ]\  }\  }}||f’ŒS r#   r#   ró  s       r%   rè  z1MemoryProfile._set_activations.<locals>.<setcomp>Ò  rô  r$   c                ó.   •— h | ]} ‰j         j        |Ž ’ŒS r#   rØ  r÷  s     €r%   rè  z1MemoryProfile._set_activations.<locals>.<setcomp>Ó  s'   ø€ ÐIÐIÐI¸QÐ 4 Ô 0Ô 4°aÐ 8ÐIÐIÐIr$   N)r   r   r   r!   r   r°  rz  r‰   rG  r   r‡   r¥   rD  rI  r²  rª  )rP   ÚrequiredÚalso_allowedr~   r‰   Úinput_categoriesr0   s   `      r%   r·  zMemoryProfile._set_activationsÌ  s  ø€ õ ”N¥HÔ$7Ð8ˆÝ Ô*­HÔ,>Ð?ˆØÔ)Ô4ð 	Tð 	TˆDØNÐN¸$¼+×:KÒ:KÑ:MÔ:MÐNÑNÔNˆFØIÐIÐIÐIÀ&ÐIÑIÔIÐð " HÑ,ðTà)¨X¸Ñ-DÑEðTõ
  Ô1½ÀDÄKÑ9PÔ9PÐPÐPàœ×+Ò+Ñ-Ô-ð Tð T�AØ:�DÔ$Ô:ÐS¸AÐS½xÔ?RÐSÐSÐSÐSÐSøð	Tð 	Tr$   c                ó¦  — | j                              ¦   «         D ]¶}|j        d         t          j        k    r™|j        d         j        r‡|j        d         j        j        }t          j         	                    d„ |D ¦   «         ¦  «        D ]F\  }}t                               |¦  «        }|�%| j                             |t          j        ¦  «         ŒGŒ·d S )Nr   r�   c              3  ó"   K  — | ]
\  }}}|V — Œd S rV   r#   )r/   r�   r  s      r%   r¯   z5MemoryProfile._set_optimizer_state.<locals>.<genexpr>ä  s(   è è € Ð9Ð9™{˜q ! U�UÐ9Ð9Ð9Ð9Ð9Ð9r$   )rp  rû   r„   r   rŠ   rŒ   rŽ   ÚitÚchainÚfrom_iterabler   rv   r²  r£  r   r"   )rP   rœ   rŽ   r�   rr   r÷   s         r%   r¸  z"MemoryProfile._set_optimizer_stateß  sÐ   € Ø”]×&Ò&Ñ(Ô(ð 	Rð 	RˆEØŒ{˜1Œ~¥Ô!2Ò2Ð2°u´{À1´~Ô7OÐ2Ø"œ[¨œ^Ô5Ô@�
ÝœH×2Ò2Ø9Ð9¨jÐ9Ñ9Ô9ñô ð Rð R‘D�A�qõ $×/Ò/°Ñ2Ô2�CØ�ØÔ(×2Ò2°3½Ô8PÑQÔQÐQøøð	Rð 	Rr$   c                óV  — d t           j        h}| j        j        D ]�}t          j        t          |j        ¦  «        v rk|j         	                    ¦   «         D ]Q\  }}|dk    s | j
                             ||dz
  ¦  «        |v r&| j
                             ||t           j        ¦  «         ŒRŒŽd S r    )r   r    r°  rz  r   r‡   r¥   rD  rI  rG  r²  r'  rª  )rP   Úpriorr~   r÷   r€  s        r%   r¹  z"MemoryProfile._set_autograd_detailê  s¹   € Ø•xÔ/Ð0ˆØÔ)Ô4ð 	ð 	ˆDÝÔ,µ
¸4¼;Ñ0GÔ0GÐGÐGØ$(¤L×$6Ò$6Ñ$8Ô$8ð ð ‘L�C˜Ø !’|�| tÔ'7×';Ò';¸CÀÈ1ÁÑ'MÔ'MÐQVÐ'VÐ'VØÔ(×>Ò>Ø ­(Ô*Bñô ð øøð		ð 	r$   Nr  )rI   rº  rÍ   )rI   rÐ  )rI   rÚ  r‘  )r   r   r   rþ   r}   rÍ  rÏ  rÃ  râ  r³  r´  rµ  r¶  r·  r¸  r¹  r#   r$   r%   r®  r®  ­  s8  € € € € € ð$ð $ð $ð $ð ðBð Bð Bñ „XðBðHJð Jð Jð Jð
ð 
ð 
ð 
ð "+ð "+ð "+ð "+ðHCð Cð Cð Cð"Fð Fð Fð Fð1Uð 1Uð 1Uð 1UðfHDð HDð HDð HDðTTð Tð Tð Tð&	Rð 	Rð 	Rð 	Rðð ð ð ð ð r$   r®  c                  ó8   — e Zd Zd
d„Zd„ Zd
d„Zd
d„Z	 dd
d	„ZdS )ÚMemoryProfileTimelinerI   rî   c                ó6   — |j         | _         |j        | _        dS )a»  The minimum representation of the memory profile timeline
        includes the memory timeline and categories. The timeline
        consists of [timestamp, action, (TensorKey, version), numbytes]
        elements, to denote any actions (pre-existing, create, destroy,
        or increment_version) that occurred to a specific Tensor for a
        chunk of memory. The categories help map each (TensorKey,
        version) pair into a category.N)rÍ  r²  Ú
categories)rP   Úmemory_profiles     r%   rþ   zMemoryProfileTimeline.__init__ö  s   € ð 'Ô/ˆŒØ(Ô4ˆŒˆˆr$   c                óV  ‡ ‡
‡— t          j        |¦  «        }g }g Š
dˆ ˆ
fd„}dŠ‰ j        D �]k\  }}\  }}}	|j        |k    rŒ|dk    rt          |dz  ¦  «        }‰dk    s|‰k     r|dk    r|Št	          |¦  «        dk    r>|                     |¦  «         ‰
                     dgd„ t          D ¦   «         z   ¦  «         nN||d         k    rB|                     |¦  «         ‰
                     ‰
d                              ¦   «         ¦  «         |t          j	        t          j
        fv r ||||	¦  «         �Œ|t          j        k    r  ||||	 ¦  «          |||dz   |	¦  «         �Œ;|t          j        k    r ||||	 ¦  «         �Œ[t          d	|› �¦  «        ‚ˆfd
„|D ¦   «         }|‰
fS )zñConvert the memory timeline and categories into a memory plot
        consisting of timestamps and their respective sizes by category
        for a given device.

        Input: device
        Output: [timestamps, sizes by category]
        rI   rî   c                óÒ   •— t          | t          ¦  «        r‰j                             | |¦  «        nd }t          |         dz   }‰d         |xx         t          |¦  «        z  cc<   d S )Nr�   rP  )rW   r   r  r'  Ú_CATEGORY_TO_INDEXrF   )r÷   r€  r  r   rz   rP   r$  s        €€r%   r  z8MemoryProfileTimeline._coalesce_timeline.<locals>.update  ss   ø€ õ ˜c¥9Ñ-Ô-ð�”×#Ò# C¨Ñ1Ô1Ð1àð õ
 ' xÔ0°1Ñ4ˆEØ�"ŒI�eÐÐÔ¥ E¡
¤
Ñ*ÐÐÑÐÐr$   rP  iè  r   c                ó   — g | ]}d ‘ŒS ©r   r#   r«   s     r%   r¬   z<MemoryProfileTimeline._coalesce_timeline.<locals>.<listcomp>&  s   € Ð#BÐ#BÐ#B¨! AÐ#BÐ#BÐ#Br$   r�   úUnknown action: c                ó$   •— g | ]}|d k     r‰n|‘ŒS r  r#   )r/   rr   Út_mins     €r%   r¬   z<MemoryProfileTimeline._coalesce_timeline.<locals>.<listcomp>:  s%   ø€ Ð6Ð6Ð6¨1˜!˜aš%˜%�� QÐ6Ð6Ð6r$   r‘  )rÑ   rB   rÍ  rF   rÆ   r¡   r  rí  r4   r5   r6   r7   r8   Ú
ValueError)rP   Ú
device_strrB   Útimesr  rr   rÀ  r÷   r€  Únumbytesr$  r  s   `         @@r%   Ú_coalesce_timelinez(MemoryProfileTimeline._coalesce_timeline  s	  øøø€ õ ”˜jÑ)Ô)ˆØˆØ!#ˆð	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð ˆØ37´=ð !	>ñ !	>Ñ/ˆAˆv‘~˜˜W xØŒz˜VÒ#Ð#Øð �BŠwˆwÝ˜˜D™‘M”M�ð ˜Š{ˆ{˜q 5šy˜y¨Q°ªU¨UØ�õ �5‰zŒz˜QŠˆØ—’˜Q‘”�Ø—’˜a˜SÐ#BÐ#BÕ/AÐ#BÑ#BÔ#BÑBÑCÔCÐCÐCà�e˜B”i’�Ø—’˜Q‘”�Ø—’˜U 2œYŸ^š^Ñ-Ô-Ñ.Ô.Ð.ð �&Ô,­f¬mÐ<Ð<Ð<Ø��s˜G XÑ.Ô.Ð.Ñ.à�6Ô3Ò3Ð3Ø��s˜G h YÑ/Ô/Ð/Ø��s˜G a™K¨Ñ2Ô2Ð2Ñ2à�6œ>Ò)Ð)Ø��s˜G h YÑ/Ô/Ð/Ñ/õ !Ð!<°FÐ!<Ð!<Ñ=Ô=Ð=à6Ð6Ð6Ð6°Ð6Ñ6Ô6ˆØ�eˆ|Ðr$   c                óÀ   — |                       |¦  «        \  }}ddl}t          |d¦  «        5 }|                     ||g|¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zˆSaves the memory timeline as [times, sizes by category]
        as a JSON formatted file to the given path for the given
        device.r   NÚw)r!  ÚjsonÚopenÚdump)rP   Úpathr  r  r$  r$  Úfs          r%   Úexport_memory_timelinez,MemoryProfileTimeline.export_memory_timeline=  s«   € ð ×.Ò.¨zÑ:Ô:‰ˆˆuàˆˆˆå�$˜‰_Œ_ð 	) Ø�IŠI�u˜e�n aÑ(Ô(Ð(ð	)ð 	)ð 	)ñ 	)ô 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)øøøð 	)ð 	)ð 	)ð 	)ð 	)ð 	)s   ­AÁAÁAc                ó  ‡ — t          j        |¦  «        }g }ˆ fd„}‰ j        D �]"\  }}\  }}	}
|j        |k    rŒ|t          j        t          j        fv r/|                     |t          |         |
 |||	¦  «        f¦  «         Œ`|t          j        k    ra|                     |t          |         |
  |||	¦  «        f¦  «         |                     |t          |         |
 |||	dz   ¦  «        f¦  «         ŒÑ|t          j	        k    r1|                     |t          |         |
  |||	¦  «        f¦  «         �Œt          d|› �¦  «        ‚ddl}t          |d¦  «        5 }|                     ||¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zÄSaves the memory timeline as raw memory event tuples in the
        form of (timestamp, action, numbytes, category)
        as a JSON formatted file to the given path for the given
        device.c                ó‚   •— t          | t          ¦  «        r‰j                             | |¦  «        nd }t          |         S rV   )rW   r   r  r'  r  )r÷   r€  r   rP   s      €r%   Úget_category_indexzLMemoryProfileTimeline.export_memory_timeline_raw.<locals>.get_category_indexP  sC   ø€ õ ˜c¥9Ñ-Ô-ð�”×#Ò# C¨Ñ1Ô1Ð1àð õ
 & hÔ/Ð/r$   r�   r  r   Nr#  )rÑ   rB   rÍ  r4   r5   r6   r¡   Ú_ACTION_TO_INDEXr7   r8   r  r$  r%  r&  )rP   r'  r  rB   Ú
raw_eventsr,  rr   rÀ  r÷   r€  r   r$  r(  s   `            r%   Úexport_memory_timeline_rawz0MemoryProfileTimeline.export_memory_timeline_rawH  sH  ø€ õ
 ”˜jÑ)Ô)ˆØ68ˆ
ð	0ð 	0ð 	0ð 	0ð 	0ð 48´=ð /	>ñ /	>Ñ/ˆAˆv‘~˜˜W xØŒz˜VÒ#Ð#Øà�&Ô,­f¬mÐ<Ð<Ð<Ø×!Ò!ð Ý(¨Ô0Ø Ø*Ð*¨3°Ñ8Ô8ð	ñô ð ð ð �6Ô3Ò3Ð3Ø×!Ò!ð Ý(¨Ô0Ø!˜	Ø*Ð*¨3°Ñ8Ô8ð	ñô ð ð ×!Ò!ð Ý(¨Ô0Ø Ø*Ð*¨3°¸!±Ñ<Ô<ð	ñô ð ð ð �6œ>Ò)Ð)Ø×!Ò!ð Ý(¨Ô0Ø!˜	Ø*Ð*¨3°Ñ8Ô8ð	ñô ð ñ õ !Ð!<°FÐ!<Ð!<Ñ=Ô=Ð=àˆˆˆå�$˜‰_Œ_ð 	% Ø�IŠI�j !Ñ$Ô$Ð$ð	%ð 	%ð 	%ñ 	%ô 	%ð 	%ð 	%ð 	%ð 	%ð 	%ð 	%ð 	%øøøð 	%ð 	%ð 	%ð 	%ð 	%ð 	%s   ÅF Æ FÆF©é   é   Nc           	     ó  — ddl }|j                             d¦  «        }|€t          d¦  «         dS ddlm} ddlm} ddlm	}	 ddl
}
|                      |¦  «        }|
                     |d         ¦  «        |
                     |d         ¦  «        }}t          |¦  «        }||z  }|
                     |d¬¦  «        d	z  }t          j        |¦  «        }t          j                             |¦  «        }t          j                             |¦  «        }|	                     |d
¬¦  «        }|                     ¦   «         }t,                               ¦   «         D ]F\  }}t0          |         }|                     |dz  |dd…|f         |dd…|dz   f         |d¬¦  «         ŒG|                     d„ t,          D ¦   «         ¦  «         |                     d¦  «         |                     d¦  «         d                     |r|gng d|d	z  d›d|d	z  d›d�gz   ¦  «        }|                     |¦  «          |dd¬¦  «        5 }|                     |d¬¦  «         |                      dd¦  «          || !                    ¦   «         ¦  «         "                    d¦  «        }|stG          d¦  «        ‚d|› d�}tI          |d d¬!¦  «        5 }| %                    |¦  «         ddd¦  «         n# 1 swxY w Y   ddd¦  «         dS # 1 swxY w Y   dS )"zsExports the memory timeline as an HTML file which contains
        the memory timeline plot embedded as a PNG file.r   NÚ
matplotlibzDexport_memory_timeline_html failed because matplotlib was not found.)Ú	b64encode)ÚNamedTemporaryFiler�   )Úaxisi   @éP   )ÚfigsizeÚdpig     @�@gffffffæ?)ÚcolorÚalphac                ó$   — g | ]}|€dn|j         ‘ŒS )NÚUnknownrê   r<   s     r%   r¬   zEMemoryProfileTimeline.export_memory_timeline_html.<locals>.<listcomp>µ  s"   € ÐTÐTÐT¸1  �I�I°´ÐTÐTÐTr$   z	Time (ms)zMemory (GB)z

zMax memory allocated: z.2fz GiB 
Max memory reserved: z GiBzw+bz.png)ÚsuffixÚpng)Úformatzutf-8z failed to encode image as base64z}<html>
<head><meta charset="utf-8" /><title>GPU Memory Timeline HTML</title></head>
<body>
  <img src='data:image/png;base64,z'>
</body>
</html>r#  )Úencoding)&Úimportlib.utilÚutilÚ	find_specÚprintÚbase64r5  Útempfiler6  Úmatplotlib.pyplotÚpyplotÚnumpyr!  ÚarrayÚminÚcumsumrÑ   rB   ÚcudaÚmax_memory_allocatedÚmax_memory_reservedÚfigureÚgcaÚ_CATEGORY_TO_COLORSrG  r  Úfill_betweenÚlegendÚ
set_xlabelÚ
set_ylabelÚjoinÚ	set_titleÚsavefigÚseekÚreadÚdecoder�   r%  Úwrite)rP   r'  r  r9  ÚtitleÚ	importlibÚmatplotlib_specr5  r6  ÚpltÚnpÚmtr  r$  r  ÚstackedrB   rP  rQ  ÚfigÚaxesr   r;  r0   ÚtmpfileÚencodedÚhtmlr(  s                               r%   Úexport_memory_timeline_htmlz1MemoryProfileTimeline.export_memory_timeline_htmlŽ  sú  € ð 	ÐÐÐà#œ.×2Ò2°<Ñ@Ô@ˆØÐ"ÝØVñô ð ð ˆFà$Ð$Ð$Ð$Ð$Ð$Ø/Ð/Ð/Ð/Ð/Ð/à'Ð'Ð'Ð'Ð'Ð'ØÐÐÐà×$Ò$ ZÑ0Ô0ˆØ—x’x  1¤‘”¨¯ª°°A´©¬ˆuˆå�E‘
”
ˆØ�‰ˆØ—)’)˜E¨�)Ñ*Ô*¨WÑ4ˆÝ”˜jÑ)Ô)ˆÝ$œz×>Ò>¸vÑFÔFÐÝ#œj×<Ò<¸VÑDÔDÐð �jŠj ¨bˆjÑ1Ô1ˆØ�wŠw‰yŒyˆÝ2×8Ò8Ñ:Ô:ð 	ð 	‰OˆH�eÝ" 8Ô,ˆAØ×ÒØ˜‘˜W Q Q Q¨ Tœ]¨G°A°A°A°q¸1±u°HÔ,=ÀUÐRUð ñ ô ð ð ð 	�
Š
ÐTÐTÕ@SÐTÑTÔTÑUÔUÐUà�Š˜Ñ$Ô$Ð$Ø�Š˜Ñ&Ô&Ð&Ø—’ØÐ%ˆeˆWˆW 2ðRÐ)=ÀÑ)IÐVð Rð RØ(;¸wÑ(GÐQðRð Rð Rðññ
ô 
ˆð 	�Š�uÑÔÐð  Ð ¨fÐ5Ñ5Ô5ð 	¸Ø�KŠK˜¨ˆKÑ.Ô.Ð.à�LŠL˜˜AÑÔÐØ�i §¢¡¤Ñ/Ô/×6Ò6°wÑ?Ô?ˆGØð IÝ$Ð%GÑHÔHÐHðð $+ðð ð ˆDõ �d˜C¨'Ð2Ñ2Ô2ð °aØ—’˜‘”�ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s7   È;BK<ËK$ËK<Ë$K(	Ë(K<Ë+K(	Ë,K<Ë<L ÌL r‘  )r0  N)r   r   r   rþ   r!  r)  r/  rl  r#   r$   r%   r  r  õ  sŠ   € € € € € ð	5ð 	5ð 	5ð 	5ð:ð :ð :ðx	)ð 	)ð 	)ð 	)ðD%ð D%ð D%ð D%ðN 9=ðDð Dð Dð Dð Dð Dð Dr$   r  )r~   r   rI   r   )r~   r   rI   r”   )r~   r   rI   r™   )rœ   r�   rI   rž   )FÚ
__future__r   rU  r›  r   Ú	itertoolsr  ÚloggingÚtypingr   r   r   r   rÑ   Útorch._C._profilerr   r	   r
   r   r   r   Útorch._utilsr   Útorch.profilerr   Úcollections.abcr   Útorch._Cr   Útorch._C._autogradr   r£   rF   ÚKeyAndIDÚTensorAndIDÚ	getLoggerr   r  ÚEnumr   r!   r"   r   r   r   r   r    rT  r²   r  r4   r-  Ú	dataclassr   rE   r   r“   r˜   r›   r¥   r§   rì   r  r2  r:  r<  r“  rž  r®  r  r#   r$   r%   ú<module>r|     ss  ðà "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø Ð Ð Ð Ø €€€Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4à €€€ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 'Ð &Ð &Ð &Ð &Ð &Ø !Ð !Ð !Ð !Ð !Ð !ð ð 3Ø(Ð(Ð(Ð(Ð(Ð(à'Ð'Ð'Ð'Ð'Ð'Ø2Ð2Ð2Ð2Ð2Ð2ð �˜�Ô€Ø�K Ð$Ô%€à€gÔ˜Ñ!Ô!€ð"ð "ð "ð "ð "ˆtŒyñ "ô "ð "ð Ô˜ØÔ˜kØ„N�GØÔ˜ØÔ˜ØÔ�|ØÔ˜kØˆ&ð	Ð ð GÐF y yÐ1DÑ'EÔ'EÐFÑFÔFÐ ðð ð ð ð ˆTŒYñ ô ð ð 0Ð/¨Ð/Ñ/Ô/Ð ð €Ô˜$¨E¸$Ð?Ñ?Ô?ðð ð ð ð ñ ô ñ @Ô?ðð Ôð(ð (ð (ð (ð (ñ (ô (ñ Ôð(ð( €Ô˜$¨D¸Ð>Ñ>Ô>ð.Xð .Xð .Xð .Xð .X�ñ .Xô .Xñ ?Ô>ð.Xðb(Nð (Nð (Nð (NðVð ð ð ðð ð ð ðð ð ð ðoð oð oð oð oñ oô oð oðd
"ð 
"ð 
"ð 
"ð 
"ñ 
"ô 
"ð 
"ðG!ð G!ð G!ð G!ð G!ñ G!ô G!ð G!ðT €ÔÑÔð
$ð 
$ð 
$ð 
$ð 
$ñ 
$ô 
$ñ Ôð
$ð])ð ])ð ])ð ])ð ])ñ ])ô ])ð ])ð@s)ð s)ð s)ð s)ð s)ñ s)ô s)ð s)ðl ÔðKð Kð Kð Kð Kñ Kô Kñ ÔðKð Ôð
ð 
ð 
ð 
ð 
ñ 
ô 
ñ Ôð
ð>Eð Eð Eð Eð Eñ Eô Eð EðP
]ð ]ð ]ð ]ð ]ñ ]ô ]ð ]ð ]ð ]r$   