o
    ‡ZŽhê  ã                   @   sŽ  d Z ddlZddlmZmZmZmZ ddlmZm	Z	m
Z
 ddlmZmZmZ ddlmZ ddlmZ dd	lmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dd
lm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z8 g d¢Z9ej: ;ej<jj=g¡ ej>ej?j>u r»ddl@Ze Aej>¡e_>ejBjC Dej>d¡ ddd„ZEddd„ZFdS )až  
TorchDynamo is a Python-level JIT compiler designed to make unmodified PyTorch programs faster.
TorchDynamo hooks into the frame evaluation API in CPython (PEP 523) to dynamically modify Python
bytecode right before it is executed. It rewrites Python bytecode in order to extract sequences of
PyTorch operations into an FX Graph which is then just-in-time compiled with a customizable backend.
It creates this FX Graph through bytecode analysis and is designed to mix Python execution with
compiled backends to get the best of both worlds: usability and performance. This allows it to
seamlessly optimize PyTorch programs, including those using modern Python features.
é    Né   )ÚconfigÚconvert_frameÚ
eval_frameÚresume_execution)Úlist_backendsÚlookup_backendÚregister_backend)Úcallback_handlerÚon_compile_endÚon_compile_start)Úcode_context)Úreplay)Úallow_in_graphÚassume_constant_resultÚdisableÚdisallow_in_graphÚforbid_in_graphÚgraph_breakÚmark_dynamicÚmark_staticÚmark_static_addressÚmaybe_mark_dynamicÚnonstrict_traceÚrunÚ
set_stanceÚsubstitute_in_graph)	Ú_reset_guarded_backend_cacheÚexplainÚexportÚis_dynamo_supportedÚis_inductor_supportedÚoptimizeÚoptimize_assertÚOptimizedModuleÚ
reset_code)Úis_compiling)ÚGenerationTracker)Úreset_code_state)ÚTensorifyState)Úgraph_break_reasonsÚguard_failuresÚorig_code_mapÚreset_frame_count)Úloader)r   r   r   r   r   r   r   r   r   r   r   r"   r#   r   r   r   r   r   r   Úresetr$   r&   r	   r   r   r   zaten::manual_seedÚreturnc                  C   sö   ddl } |  t¡}| d¡ tj` tƒ  tj ¡  t	ƒ  tj
 ¡  t ¡  t ¡  t ¡  tjj ¡  tƒ  tƒ  tjj ¡  dt_tj ¡  t ¡  t ¡  t ¡  tjjj ¡  tjjj ¡  tjj  !d¡ W d  ƒ dS 1 stw   Y  dS )a±  
    Clear all compile caches and restore initial state.  This function is intended
    to reset Dynamo's state *as if* you had started a fresh process invocation, which
    makes it good for testing scenarios where you want to behave as if you started
    a new process.  It does NOT affect any file system caches.

    NB: this does NOT reset logging state.  Don't use this to test logging
    initialization/reinitialization.
    r   Nztorch._dynamo.resetF)"ÚloggingÚ	getLoggerÚ__name__Úinfor   Úcompile_lockÚreset_code_cachesÚinput_codesÚclearr(   Úoutput_codesr,   r+   r*   r   ZContinueExecutionCacheÚcacher   r-   ÚtorchÚ_dynamoZcompiled_autogradr/   ZFRAME_COUNTERZFRAME_COMPILE_COUNTERr
   r'   r)   ÚutilsZwarn_once_cacheZuser_obj_id_to_weakrefZ_CZ	_autogradZ _saved_tensors_hooks_set_tracing)r1   Úlog© r?   úE/var/www/auris/lib/python3.10/site-packages/torch/_dynamo/__init__.pyr/   b   s0   




"ír/   c                  C   s€   ddl } |  t¡}| d¡ 	 tj$ tƒ  tjjtj	j D ]}|ƒ }|r)t
|ƒ qt ¡  W d  ƒ dS 1 s9w   Y  dS )z¯
    Clears in-memory code cache, which is what stores compiled products.  This
    resets less state than :func:`reset` and is mostly only used for testing
    purposes.
    r   Nztorch._dynamo.reset_code_caches)r1   r2   r3   r4   r   r5   r(   r7   Úseenr9   r%   r   r8   )r1   r>   Z	weak_codeÚcoder?   r?   r@   r6   ‡   s   

ÿ€
"ør6   )r0   N)GÚ__doc__r;   Ú r   r   r   r   Zbackends.registryr   r   r	   Úcallbackr
   r   r   r   r   Z
decoratorsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   Zexternal_utilsr&   Zmutation_guardr'   Zpgor(   Zsymbolic_convertr)   r=   r*   r+   r,   r-   Z	polyfillsr.   Ú_Ú__all__ZserializationZadd_safe_globalsr<   Z	_DimRangeZmanual_seedÚrandomZtorch.jit._builtinsZ_disable_dynamoZjitZ	_builtinsZ_register_builtinr/   r6   r?   r?   r?   r@   Ú<module>   s.    
@,
%