
    Vh                        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jt                  jw                  ejx                  j"                  jz                  g       ej|                  ej~                  j|                  u rUddl@Z ej                  ej|                        e_>        ej                  j                  j                  ej|                  d       ddZEddZFy)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_seedc                  f   ddl } | j                  t              }|j                  d       t        j
                  5  t                t        j                  j                          t                t        j                  j                          t        j                          t        j                          t        j                          t        j                  j                   j                          t#                t%                t&        j(                  j*                  j-                          dt        _        t        j0                  j                          t3        j                          t5        j                          t7        j                          t&        j(                  j8                  j:                  j                          t&        j(                  j8                  j<                  j                          t&        j>                  j@                  jC                  d       ddd       y# 1 sw Y   yxY w)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   ContinueExecutionCachecacher   r.   torch_dynamocompiled_autogradr0   FRAME_COUNTERFRAME_COMPILE_COUNTERr   r(   r*   utilswarn_once_cacheuser_obj_id_to_weakref_C	_autograd _saved_tensors_hooks_set_tracing)r2   logs     F/home/dcms/DCMS/lib/python3.12/site-packages/torch/_dynamo/__init__.pyr0   r0   b   sb    


H
%CHH"#		#	# C!!'')""((*!!#//55;;=$&''--/&'#++113 !++1132288:;;EB'C C Cs   G#H''H0c                  ~   ddl } | j                  t              }|j                  d       	 t        j
                  5  t                t        j                  j                  t        j                  j                  z   D ]  } |       }|st        |        t        j                          ddd       y# 1 sw Y   yxY w)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)r2   r3   r4   r5   r   r6   r)   r8   seenr:   r&   r   r9   )r2   rH   	weak_codecodes       rI   r7   r7      s     


H
%CHH./=		#	# %%**]-G-G-L-LL	!I ;D4 	! 	  s   AB3	!B33B<)returnN)G__doc__r=    r   r   r   r   backends.registryr   r	   r
   callbackr   r   r   r   r   
decoratorsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   external_utilsr'   mutation_guardr(   pgor)   symbolic_convertr*   rB   r+   r,   r-   r.   	polyfillsr/   ___all__serializationadd_safe_globalsr>   	_DimRangemanual_seedrandomtorch.jit._builtins_disable_dynamojit	_builtins_register_builtinr0   r7        rI   <module>rg      s     A A N N H H & !    
 
 
 ) - ! , X X #<    $ $emm&>&>&H&H%I J000 .--e.?.?@E	II))%*;*;=PQ"CJrf   