
    Ǆgca                      	   d dl 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 d dlm	Z	 d dl
mZ d dlZd dlZd dlZ ed      Zg dZdLdZed        ZdMdZd	 Zd
 ZdNdZd ZefdZefdZefdZd Z G d d      Zd Zd ZdZd ee       dZ d Z!d Z"dZ#d Z$dOdZ%d Z&dNdZ'dNde	fd Z(e)d!k(  rd dl*ZejV                  jY                  ejV                  j[                  e.            Z/e/ejV                  v rejV                  ja                  e/       d dl1Z1d"Z2d#e2 Z3 e1jh                  d$e2 %      Z5e5jm                  d&'      Z7d( Z8d)Z9e7ju                  d*e9%      Z;e;jy                  d+e3,       d-Z9e7ju                  d.e9%      Z=e=jy                  d+e3,       d/Z9e7ju                  d0e9%      Z>e>jy                  d+e3,        e8e>       d1Z9e7ju                  d2e9%      Z?e?jy                  d+e3,        e8e?       d3Z9e7ju                  d4e9%      Z@e@jy                  d5e3,       e@jy                  d6e3,        e8e@       d7ZAeAD ]w  \  ZBZ9e7ju                  eBe9%      ZCeCjy                  d+e3,       d8ZDeCjy                  d9d:eEdeD;       d<ZDeCjy                  d=d>d?eD@       eBdAk(  sadBZDeCjy                  dCdDdEeDF       y e5j                         ZGdG ZHdH ZIeGj                  d0k(  r, eHeGj                        ZL eIeGj                   eeL             yeGj                  d2k(  r, eHeGj                        ZL eIeGj                   eeL             yeGj                  d*k(  r! eHeGj                        ZL eN e!eL             yeGj                  d.k(  r! eHeGj                        ZL eN e"eL             yeGj                  d4k(  r? eHeGj                        ZO eHeGj                        ZP eIeGj                   eeOeP             yeGj                  dAk(  rC eHeGj                        ZL eIeGj                   e%eLeGj                  eGj0                  I             yeGj                  dJk(  r8 eHeGj                        ZL eIeGj                   e(eLeGj                  K             yyy)P    N)	lru_cache)Any)groupby)format_flamegraphsegmentsmemorycomparec                 `    | d   }| d   }|s|j                  d      d   }| d   }| d| d| S )Nlinefilename/name:)split)ffull_filenameifnamefuncs        ^/home/mcse/projects/flask_80/flask-venv/lib/python3.12/site-packages/torch/cuda/_memory_viz.py
_frame_fmtr      sJ    	&	AjMEC $V9DWAaS$      c                 H    g d}g d}|D ]  }|| v s y |D ]  }||v s y y)N)zunwind::unwindzCapturedTraceback::gathergather_with_cpp_start__libc_start_mainPyEval_	PyObject_PyFunction_)
zcore/boxingz	/Registerz/Redispatchzpythonrun.czModules/main.czObjects/call.czObjects/methodobject.czpycore_ceval.hzceval.czcpython/abstract.hFT )r   r   omit_functionsomit_filenamesofs        r   _frame_filterr%      sK    	NN  :  > r   c                     |rt        |       } | D cg c]!  }t        |d   |d         st        ||      # c}S c c}w )Nr   r   )reversedr%   r   )framesr   reverser   s       r   _frames_fmtr*   ;   s>    &!28dQM!F)UVWaUb<cJq-(ddds   ;;c                     d| v r'| d   d   j                  dg       }| d   d   d   }||fS | j                  d| d         }g }||fS )Nhistoryr   r(   	real_sizerequested_sizesize)get)br(   r-   s      r   _block_extra_legacyr2   @   si    A~9a$$Xr2iLOK0	 9 EE*AfI6	9r   c                 4    d| vrt        |       S | d   | d   fS )Nr(   r.   )r2   )r1   s    r   _block_extrar4   I   s*    q"1%%X;*+++r   c                    |dt        j                          d}t         j                  j                  |      sFdd l}t        d|        |j                  j                  d|       t        j                  dd|g       |dd	g}t        j                  |t        j                  t        j                  d
      }|j                  J |j                  J |j                  j                  |        |j                  j                          |j                  j!                         }|j                  j                          |j#                          |j#                         dk(  sJ |S )Nz/tmp/z_flamegraph.plr   zDownloading flamegraph.pl to: zNhttps://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.plchmodz+xz--countnamebytesutf-8)stdinstdoutencoding)osgetuidpathexistsurllib.requestprintrequesturlretrieve
subprocess
check_callPopenPIPEr9   r:   writeclosereadwait)flamegraph_linesflamegraph_scripturllibargspresults         r   r   r   O   s    #BIIK=?77>>+,./@.ABC""\^o	qw.?@A}g6DZ__Z__W^_A7788GGMM"#GGMMOXX]]_FHHNNFFH668q==Mr   c                    d }|D ]  }d|vr5t        |      \  }}| j                  | d|d    d ||       d| d       ncd}|d   D ]Y  }|d   }||z  }d	|v r,|d	   }| j                  | d|d    d ||       d| d       =| j                  | d|d    d
| d       [ |d   |z
  }	|	s| j                  | d|d    d|	 d        y )Nc                 @    | sydj                  t        | d            S )Nz<non-python>;T)r)   )joinr*   )r(   s    r   frames_fragmentz&_write_blocks.<locals>.frames_fragmente   s    !xxFD9::r   r,   rT   state 
r   r-   r(   z;<no-context> r/   z;<gaps> )r4   rH   )
r   prefixblocksrV   r1   r(   accounted_for_sizehszgapss
             r   _write_blocksr`   d   s*   ;  >A)5a&F&GGvha'
|1_V-D,EQGYFZZ\]^!"y\ J{^"b("q=x[FGGvha'
|1_V5L4MQrdRTUVGGvha'
|>"RHIJ y--GGvha'
|8D6<=!>r   c                     t        j                         }| d   D ]   }d|d    d|d    }t        |||d          "  ||j                               S )Nr   stream_stream;seg_addressr[   ioStringIOr`   getvaluesnapshotr   r   segrZ   s        r   r   r   {   s_    
A
# 03x=/s9~.>?aX/0 QZZ\**r   c                     t        j                         }| d   D ]  }d|d    }t        |||d            ||j                               S )Nr   rb   rc   r[   rf   rj   s        r   r   r      sT    
A
# 03x=/*aX/0 QZZ\**r   c           	         d }d }t        j                         }| D ch c]
  } ||       }}|D ch c]
  } ||       }}t        d||z
  D 	
cg c]  \  }	}
|		 c}
}	        t        d||z
  D 	
cg c]  \  }	}
|		 c}
}	        | D ]&  } ||      |vst        |d ||       |d          ( |D ]&  } ||      |vst        |d ||       |d          (  ||j	                               S c c}w c c}w c c}
}	w c c}
}	w )Nc                     | d   | d   fS )Nre   
total_sizer!   rl   s    r   _seg_keyzcompare.<locals>._seg_key   s    IL 122r   c                     d| d    d| d    S )Nrb   rc   rd   re   r!   rq   s    r   	_seg_infozcompare.<locals>._seg_info   s    XuS^,<==r   zonly_before = zonly_after = zonly_before;r[   zonly_after;)rg   rh   rA   r`   ri   )beforeafterr   rr   rt   r   rl   before_segs
after_segsa_s              r   r	   r	      s$   3> 	A,23S8C=3K3+01C(3-1J1	N;+CE$!QAEF
GH	M*{*BDA1DE
FG MC=
*!|IcN+;<c(mLM  LC=+!{9S>*:;S]KL QZZ\** 41EDs   C9C>D7D	c                 V    dD ]  }t        |       dk  r
| d| dc S | dz  } ! | ddS )N) KiMiGiTiPiEiZig      @z3.1fB.1fYiB)abs)numunits     r   _format_sizer      sI    > s8f$ZvQ''v #Yc?r   c                       e Zd Zd Zd Zd Zy)Bytesc                     || _         y N)value)selfr   s     r   __init__zBytes.__init__   s	    
r   c                 2    t        | j                  |z         S r   )r   r   )r   rhss     r   __add__zBytes.__add__   s    TZZ#%&&r   c                 ,    t        | j                        S r   )r   r   )r   s    r   __repr__zBytes.__repr__   s    DJJ''r   N)__name__
__module____qualname__r   r   r   r!   r   r   r   r      s    '(r   r   c                 ,    t        d | d   D              S )Nc              3   8   K   | ]  }|d    dk(  s|d     yw)rW   active_allocatedr/   Nr!   ).0r1   s     r   	<genexpr>zcalc_active.<locals>.<genexpr>   s      TQ1W:AS3SqyTs   
r[   )sumrq   s    r   calc_activer      s    T#h-TTTr   c                 V    | |z   }d}|dk7  r||z  dz  }d|dd}t        |       | S )Nr|   r   d    (r   z% internal))r   )free_externalfree_internaltotalsuffixpcts        r   _report_freer      sJ    M)EFzu$+c#Yk*El^F8$$r   i  @zC
Legend:
    [a     ] - a segment in the allocator
     ^-- a page aU   of memory in the segment
    a-z: pages filled with a single block's content
    ' ': page is completely free
    *: page if completely full with multiple blocks
    0-9: page is partially full with tensors of multiple blocks (9 == 90% full)
    (X% internal) - of the free memory, X% is free because we rounded the size of the allocation.
c                    g }t        j                         }|j                  dt        t               d       d}d}d}d}t        | d   d       D ]  }||d   z  }d}d}	d}
g }d}|d   D ]O  }|d	   d
k(  }|r3t        |      \  }}|j                  ||df       |
|z  }
|	|d   |z
  z  }	n||d   z  }||d   z  }Q ||
z  }||z  }||	z  }|d   dz
  t        z  dz   }t        |      D cg c]  }d }}t        |      D cg c]  }d }}d}t        |      D ]  \  }\  }}}||z  }||z   }|t        z  }|dz
  t        z  dz   }t        t        |rdnd      |dz  z         }t        ||      D ]g  }t        ||t        z        }t        ||dz   t        z        }||xx   ||z
  t        z  z  cc<   ||   dk7  rdt        ||   dz           ||<   c|||<   i  |d   dk(  rdnd|d    }dj                  |      } ||	z   |
z   |d   k(  sJ |d   dk7  rd|d    nd}|d   t        k\  s|j                  d|  dt        |d          dt!        ||	       d| d	        |j                  dt#        | d          d       |j                  dt        |       d       |j                  d t        |       d       |rd!t        |       d"t        |       d#nd}!|j                  d$t!        ||       d       |j                  t$               ||z   |z   |k(  sJ |j'                         S c c}w c c}w )%a  Visually reports how the allocator has filled its segments.

    This printout can help debug fragmentation issues since free fragments
    will appear as gaps in this printout.  The amount of free space is reported
    for each segment.
    We distinguish between internal free memory which occurs because the
    allocator rounds the allocation size, and external free memory, which are
    the gaps between allocations in a segment.
    Args:
        data: snapshot dictionary created from _snapshot()
    zSummary of segments >= z	 in size
r   r   c                 "    | d   t        |       fS )Nrp   )r   )xs    r   <lambda>zsegsum.<locals>.<lambda>   s    qTU6W r   keyrp   r[   rW   r   Tr/      rX   g        ry   A   z0123456789*
   rc   r|   z	, stream_z stream_[z] z allocated, z freerY   z
segments: ztotal_reserved: ztotal_allocated: r   z internal + z
 external)ztotal_free: )rg   rh   rH   r   	PAGE_SIZEsortedr4   appendrange	enumeratechrordmaxminintrU   r   lenlegendri   )"datar   outtotal_reservedtotal_allocatedr   r   rl   seg_free_externalseg_free_internalseg_allocated
all_rangesboffsetr1   activerz   allocated_sizensegoccupiedfracactive_sizer   start_r/   finish_startfinishmjserc   bodyinternal_externals"                                     r   segsumr      s    H
++-CII'i(8'9DENOMMd:&,WX 0^#l++
X 
	!AwZ#55F$0O!>!!7ND"AB/!QvY%??!!QvY.!qy G
	! 	=(****L!A%)3a7!&t-AC--"4[))))2:)> 	$%A%f4K}Gi'Eki/!3FCv3/1r6:;A5&) $I.!a%9!45QAEY..A;#%"/DGbL0A"BHQK"#HQK$	$ 8})3x=//Jwwx  #44}DLHYYYY/28}/A8CM?+r|	)II$r%L(9":!;<%&79JKLERXQYY[] ^_0^b II
3tJ/0145II ~!6 7r:;II!%"8!9<=cp"U=12,u]?S>TT^_vxII\-GHKLIIf=(?:nLLL<<>? .)s   -	L6	L;c                      t        j                          fd}t         d         D ]%  \  }}|s	j                  d| d        ||       ' j	                         S )Nc                 R   g i }i }g dfd}fd}d}j                  t        |        d       d}d   D ]
  }||d   z  } t        |       D ].  \  }}|d   dk(  r\|d	   |d
   }
}	 |       } ||	      \  }}|d}|	}n|	|z
  }j                  | d| d| dt        |
       d       ||
|f||	<   ||
z  }k|d   dk(  rE|d	   |d
   }
}	|j	                  |	|	d d f      \  }}}j                  d| dt        |
       d       |d   dk(  re|d	   |d
   }
}	||
z  }|j	                  |	|	d d f      \  }}}j                  d| dt        |
       d       ||v sj                  |       ||= %|d   dk(  rO|d	   |d
   }
}	 |       }j                  | d|	 dt        |
       d       j                  ||	|
f       |||	<   ||d   dk(  rY|d	   |d
   }
}	|j	                  |	|	      }j                  d| dt        |
       d       ||v sǉj                  |       ||= |d   dk(  r6|d
   }
|d   }j                  d t        |
       d!t        |       d"       j                  | d       1 j                  d#t        |              y )$Nr   c                      rj                         S dz  dz  }} dz  t        t        d      |z          | dk(  rd S |  S )Nr   r   ry   r   r|   )popr   r   )rr   
free_names	next_names     r   _namez$trace.<locals>.format.<locals>._name$  s\    !~~''?INqANI#c(Q,'(qAv(=>>1(=>>r   c                     D ]  \  }}}| |k\  s| ||z   k  s||fc S  t        d         D ]&  \  }}|d   }|d   }| |k\  s| ||z   k  sd| |fc S  y)Nr   re   r   seg_)NN)r   )addrr   saddrr/   r   rl   r   segment_intervalss         r   find_segmentz+trace.<locals>.format.<locals>.find_segment,  s    %6 '!eT5=TEDL%8;&' $D$45 -3I+,5=TEDL%8!!:u,,	-
 r   z	 entries
r   rp   actionallocr   r/   MEMz = r   r   z]
free_requestedzdel z # rY   free_completedz# free completed for rX   segment_allocz = cudaMalloc(z, z)
segment_freez	cudaFree(z) # oomdevice_freezraise OutOfMemoryError # z requested, z free in CUDA
zTOTAL MEM: )rH   r   r   r   r0   r   )entriessegment_addr_to_nameallocation_addr_to_namer   r   countr   rl   r   r   r/   nseg_nameseg_addroffsetr   rz   freer   r   r   r   r   s                     @@@r   formatztrace.<locals>.format  sB   #%!"$
		?		 		S\N*-. 
# 	0Cc,//N	0 "'* +	$HE1{g%vY&	dG%1$%7"(#$H!F!H_F		QCs8*AfXQuT{m3GH12D%0@'-8 00vY&	d488dD?QR
a		Dc%+b9:8 00vY&	d488dD?QR
a		1$qtRHI22%%d+/58/vY&	dw		TF.btSIJ!(($d);<-1$T*8.vY&	d+//d;		IdV4d}B?@//%%d+,T28%y'		5eDk],uUY{m[jkl		QCr(#W+	$X 			Ke~./r   device_traceszDevice z ----------------
)rg   rh   r   rH   ri   )r   r   r   dr   s   `   @r   tracer     sb    
++-CN0^ $/0 1IIs"5671I <<>r   a  
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="module">
import {add_local_files} from "https://cdn.jsdelivr.net/gh/pytorch/pytorch@main/torch/utils/viz/MemoryViz.js"
const local_files = $SNAPSHOT
add_local_files(local_files, $VIZ_KIND)
</script>
</body>
c                 n   |t        j                  dt        d       t        j                  |       }|ddt        |      dz  z
  z  z  }t        j                  |      j                  d      }t        j                  d|dg      }t        j                  dt        |            j                  d	|      S )
Nz;device argument is deprecated, plots now contain all device   )
stacklevel    r8   zsnapshot.pickle)r   base64z	$VIZ_KINDz	$SNAPSHOT)warningswarnFutureWarningpickledumpsr   r  	b64encodedecodejson_memory_viz_templatereplacerepr)r   viz_kinddevicebufferencoded_bufferjson_formats         r   _format_vizr    s    I	

 \\$F
gS[1_,--F%%f-44W=N**'8NSTUK''T(^D '[ ABr   c                 .    t        | |sd|      S d|      S )a  Generate a visualization over time of the memory usage recorded by the trace as an html file.

    Args:
        data: Memory snapshot as generated from torch.cuda.memory._snapshot()
        device (torch.device, optional): Generate the trace for this device, needed if multiple devices have allocations.
        plot_segments (bool, optional): Plots memory returned from cudaMalloc, rather than individual allocations.
                                        Defaults to False.

    Returns:
        str: HTML of visualization
    Active Memory TimelinezActive Cached Memory Timeliner  )r   r  plot_segmentss      r   
trace_plotr    s#     t]5qwxxPoqwxxr   c           
      X   dd l }ddlm}m} ddlm} | j                         i j                  j                  D ]  }|j                  |j                  k(  s|j                  }g }|rD|j                  |j                  |j                  fv r|j                  |       |j                  }|rD|j                  |j                         }|s|j                   j"                  dkD  s||<    |j$                  j'                         t)        dz         D 	cg c]  }	g  c}	t)        dz         D 
cg c]
  }
|
d ddg d c}
dfddfd	}fd	}i }j*                  D ]  \  }}\  }}}t-        ||      s||j.                  k(  r ||||      |||f<   7||j0                  k(  r+ ||j3                  ||f       |j4                               q||j6                  k(  r@ ||j3                  ||f       |j4                                ||||dz         |||dz   f<   ||j8                  k(  s ||||d
      |||f<    |j;                         D cg c]'  \  \  }}} |j4                        |d   |d   |d   f) }}}}t=        t?        |      tA        jB                  d            D ]  \  }
}d   |
   }|d   }|D ]D  \  }	}}}||k  r|d   j                  ||z
  dd       |d   j                  |d||d       ||z   }F ||d   k  se|d   j                  |d   |z
  dd        d   D cg c]
  }|d   s	| c}d<   d   D ]2  }|dxx   |d   z  cc<   |d   r|d   j                  |d   dd       4 S c c}	w c c}
w c c}}}w c c}w )Nr   )Action	TensorKey)
_EventTyper   )r  re   rp   rc   r[   )r   r   c                 >    | j                   dk(  r| j                  S S )Ncuda)typeindex)r  device_counts    r   	to_devicez'_profile_to_snapshot.<locals>.to_device  s    ;;& <<r   c                     |j                         }|j                  j                  }d   |   }|d   |d   |kD  r||d<   t        |d   || z         |d<   j                  j                  ||      }||j                  j                         nd}j                  |d      }|D 	cg c]  }	dd|	j                  d }}	d	|| d||d
}
|rd   |   j                  |
       |
S c c}	w )Nr   re   rp   unknownr!   noner   )r   r   r   r   )r   r   r/   rc   r(   categoryr   )	r  storageptrr   _categoriesr0   r   lowerr   )r/   
tensor_keyversionduring_tracer  r   rl   r'  stackrP   r   allocation_stacksmemory_profilerk   r#  s              r   allocatez&_profile_to_snapshot.<locals>.allocate  s   :,,-!!%%z"6*y>!S^d%:!C	NL 14$;?L!--11*gF,4,@8==&&(i!%%j"5JOPQfa@PPdaSXfno_%f-44Q7	 Qs   )C&c           	      `    dD ](  }d   |   j                  || d   | d   d| d   d       * y )N)r   r   r   r   r/   r   r(   )r   r   r/   rc   r(   )r   )r   r  r   rk   s      r   r   z"_profile_to_snapshot.<locals>.free  sM    5 	RA_%f-44>CFm>CFm@A@Eh	6Q R	Rr   F)r.  r   r/   r(   r   r   re   r[   inactive)r/   rW   r   )r/   rW   r.   r(   rp   )T)"torchtorch.profiler._memory_profilerr  r  torch._C._profilerr  _memory_profile_op_treesorted_nodestag
AllocationparentPyCallPyCCallr   from_allocationextra_fields
alloc_sizer  r"  r   timeline
isinstanceCREATEDESTROYr   r  INCREMENT_VERSIONPREEXISTINGitemsr   r   operator
itemgetter)profiler5  r  r  r  eventr=  python_parentsr   rz   r  r2  r   
kv_to_elemtimer   r,  r-  r/   blocks_at_endr[   rl   	last_addrr   r(   r0  r"  r1  rk   r#  s                            @@@@@r   _profile_to_snapshotrS    s!   A-,,.N((55 899
---\\FN::*"3"3Z5G5G!HH"))&1  ++E,>,>?C u))44q8)7!#&8  ::**,L&+L1,<&=>">
 38q8H2I	K )/	 !'!%$% ! "	$ KH  "R J
 6D5L5L h1f+z7T*i0V]]"08z70SJ
G,-v~~%W 56	*BSBS8TUv///W 56	*BSBS8TU4<T:wYZ{4[J
GaK01v)))08z7af0gJ
G,-h  :D9I9I9KM M5.*g  
 1 12E&M5=RWX`Rab MM M!&"7X=P=PQR=ST 	_z"6*	N	%+ 	$!AtT64H$$dY.>%TUM  $9K_cou!vwtI		$
 s<((M  #l*;i*GR\!]^	_ ,4J+?QC3x=CQHZ
# SLS^+8}M  #l*;j!QRS
 O] ?KtM Rs   	N5N!,N 
N'N'c                 2    t        |       }t        |d|      S )a}  Generate a visualization over time of the memory usage recorded by kineto memory profiling as an html file.

    Args:
        profile: profile as generated by `torch.profiler.profile(profile_memory=True)`
        device (torch.device, optional): Generate the trace for this device, needed if multiple devices have allocations.

    Returns:
        str: HTML of visualization
    r  )rS  r  )rL  r  rk   s      r   profile_plotrU    s     $G,Hx!96BBr   r   c                     t        | d|      S )NzAllocator State Historyr  )r   r  s     r   segment_plotrW    s    t6??r   __main__ztorch.cuda.memory._snapshot()zpickled memory statistics from z#Visualize memory dumps produced by )descriptionr   )destc                 .    | j                  dddd       y )N-o--outputz
output.svgz$flamegraph svg (default: output.svg)defaulthelp)add_argument)rP   s    r   _outputrb  '  s    	tZDjkr   zmPrints overall allocation statistics and a visualization of how the allocators segments are currently filled.statsinput)r`  z`Prints buffer of the most recent allocation events embedded in the snapshot in a Pythonic style.r   zaGenerate a flamegraph that visualizes what memory is stored in each allocator segment (aka block)r   zNGenerate a flamegraph the program locations contributing to CUDA memory usage.r   zGenerate a flamegraph that shows segments (aka blocks) that have been added or removed between two different memorys snapshots.r	   ru   rv   ))r  z]Generate a visualization over time of the memory usage recorded by the trace as an html file.)rW  zfVisualize how allocations are packed into allocator segments at each point in a trace as an html file.z]visualize trace from this device (default: chooses the only device with trace info or errors)z-dz--device)r   r_  r`  z4path to save the visualization(default: output.html)r\  r]  zoutput.htmlr^  r  z?visualize change to segments rather than individual allocationsz-sz
--segments
store_true)r   r`  c                     | dk(  rt         j                  j                  }nt        | d      }t	        j
                  |      }t        |t              r|g d}|S )N-rb)r   traces)sysr9   r  openr  loadrD  list)r   r   r   s      r   _readrn  U  sJ    3;		  AT4 A{{1~dD! $3Dr   c                 h    t        | d      5 }|j                  |       d d d        y # 1 sw Y   y xY w)Nw)rk  rH   )r   r   r   s      r   _writerq  _  s-    $_ 	GGDM	 	 	s   (1)r  r  rW  )r  )F)FFr   )NF)Rr  rj  r<   rg   rD   r  	functoolsr   typingr   	itertoolsr   r  r  rJ  cache__all__r   r%   r*   r2   r4   r   r`   r   r   r	   r   r   r   r   r   r   r   r   r  r  r  rS  rU  rW  r   os.pathr>   realpathdirname__file__thedirremoveargparsefn_namepickledArgumentParserparseradd_subparsers
subparsersrb  rY  
add_parserstats_ara  trace_a
segments_amemory_a	compare_aplotscmdtrace_plot_ar`  r   
parse_argsrO   rn  rq  r   rd  r   outputrA   ru   rv   r  r!   r   r   <module>r     s    
 	 	        $
@!  >e
,*>. *; + (9 + .? +2( (U% 	 y!" #	

KZVr B ygRC@s @ zWWbggooh78F-G/y9G$X$$3VW^V_1`aF&&H&5Jl BK##G#EGw/tK##G#EGw/uK&&z{&KJG'2JbK$$X;$GH'0H>K%%i[%II8'271IE " 	Z[!,,Sk,J!!'!8n!!$
dQU!VE!!$
MPT!U,TD%%dLTX%Y	Z D {{j TZZ t{{HTN+		 TZZ t{{F4L)		TZZ fTl		TZZ eDk			!t{{#djj!t{{GFE23		$TZZ t{{JtDKKt}}]^		&TZZ t{{LdkkBC 
'{ r   