
    9i                     |    S SK r S SKrS SKrSSKJrJrJr  SSKJr  S r	S r
S rS rS	 rS
 r\S:X  a  \" 5         gg)    N   )startfinalize_select_backend)set_command_linec            	         [         R                  " SS[         R                  S9n U R                  SS[        SS9  U R                  SS	[        S
S / SQS9  U R                  SS[        SSSS/S9  U R                  SS[        SS S9  U R                  SS[        SSSS/S9  U R                  SS[        SS S S/S9  U R                  S[         R
                  S S!9  U R                  5       nXR                  4$ )"NzBThe proton command utility for profiling scripts and pytest tests.z
    proton [options] script.py [script_args] [script_options]
    proton [options] pytest [pytest_args] [script_options]
    python -m triton.profiler.proton [options] script.py [script_args] [script_options]
)descriptionusageformatter_classz-nz--namezName of the profiling session)typehelpz-bz	--backendzProfiling backend)cupti	roctracerinstrumentation)r   r   defaultchoicesz-cz	--contextzProfiling contextshadowpythonz-mz--modezProfiling mode)r   r   r   z-dz--datazProfiling datatreetracez-kz--hookzProfiling hooklaunchtarget_argszSubcommand and its arguments)nargsr   )argparseArgumentParserRawTextHelpFormatteradd_argumentstr	REMAINDER
parse_argsr   )parserargss     V/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/triton/profiler/proton.pyparse_argumentsr$      s&   $$X a 224F hS7VW
k:MW[ I  K
k:MW_!)8 4  6
hS7GQUV
hS7GQWbhjqars
hS7GQU`dfn_op
X-?-?FdeD!!!!    c                 F    [         R                  R                  U 5      S:H  $ )Npytest)ospathbasename)scripts    r#   	is_pytestr,      s    77F#x//r%   c                    [         R                  R                  U 5      nSSSUS[        [        R
                  [        0n[        R                  nU /U-   [        l        [        R                  R                  [         R                  R                  U5      5         [        US5       n[        UR                  5       US5      nS S S 5        [        WU5        U[        l        g ! , (       d  f       N&= f! [         a.  n[        SU 35        [        R                  " S5         S nANPS nAff = f! U[        l        f = f)	N__name____main____file____builtins__rbexecz.An error occurred while executing the script: r   )r(   r)   abspathr1   sysr.   argvappenddirnameopencompilereadr3   	Exceptionprintexit)r+   r"   script_pathclean_globalsoriginal_argvfilecodees           r#   execute_as_mainrE       s    ''//&)K 	JKc	M HHMx$CHHHOOBGGOOK01!+t$499;V<D %T=!
 ! %$  >qcBC !sB   C5 (C$C5 $
C2.C5 5
D-?$D(#D0 (D--D0 0D=c                     [        5         U S   n[        U 5      S:  a  U SS  O/ n[        U5      (       a  SS KnUR	                  U5        g [        X5        g )Nr   r   )r   lenr,   r'   mainrE   )r   r+   script_argsr'   s       r#   do_setup_and_executerJ   ;   sL    ^F%(%5%9+ab/rKK ,r%   c                     U R                   (       a  U R                   O	[        5       n[        U R                  U R                  U R
                  X R                  S9  [        U5        [        5         g )N)contextdatabackendhook)	rN   r   r   namerL   rM   rO   rJ   r   )r"   r   rN   s      r#   run_profilingrQ   H   sC    "lldll0AG	$))T\\		7QZQZ[%Jr%   c                  2    [        5       u  p[        X5        g )N)r$   rQ   )r"   r   s     r#   rH   rH   R   s    ')D$$r%   r/   )r   r5   r(   profiler   r   r   flagsr   r$   r,   rE   rJ   rQ   rH   r.    r%   r#   <module>rV      sI     
 	 5 5 #"(0!6
-%
 zF r%   