
    קg                     r    d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	 dddded	e
d
ee         fdZdefdZdS )    )CallableOptional)TorchRefsMode)GraphModule)make_fxwrapper_and_args_for_make_fxatenN)executorexecutor_parametersgmr
   r   c                L    |dk    r
 | j         | S d| d}t          |          )zJ
    Prototype ATen executor.

    Just executes the context's graph.
    r	   z*Received unexpected value for 'executor': z. Allowed values are: aten.)forward
ValueError)r   r
   r   argsmsgs        Q/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/_prims/executor.pyexecuter   	   s:     6rz4  
\x
\
\
\C
S//    fnc                      dd fd
}|S )a  
    Returns a function that, when called, will
    trace its torch operations to prims and then
    execute those prims on the requested trace executor
    (possibly lowering them to that trace executor first).

    Only supports the torch operations defined in _torch_to_reference_map
    in context.py and operations with positional args. All args must
    be tensors.
    In the near future all these restrictions will be lifted.

    Example usage:

    def foo(a, b):
      return torch.add(a, b)

    traced_foo = make_traced(foo)

    a = torch.randn((1, 2, 3, 4, 5), device='cuda')
    b = torch.randn((1, 2, 3, 4, 5), device='cuda')
    result = traced_foo(a, b, executor='aten')
    r	   r
   c                     t          ||          \  }}t                      5   t          |          |          }d d d            n# 1 swxY w Y   t          |||           S )Nr   )r   r   r   r   )r
   r   kwargswrappedall_argsr   r   s         r   _tracedzmake_traced.<locals>._traced4   s    8T6JJ__ 	, 	,!!!(++B	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,r8h7777s   A		AA )r   r   s   ` r   make_tracedr      s2    0 !' 8 8 8 8 8 8 8 Nr   )typingr   r   torch._prims.contextr   torch.fxr   "torch.fx.experimental.proxy_tensorr   r   strdictr   r   r   r   r   <module>r%      s    % % % % % % % % . . . . . .             T T T T T T T T *.	    "$	   & H            r   