
    i                         S r SSKJr  SSKJrJr  SSKrSSKJr  \ " S S5      5       r	\S\\
\	4   4   rS	\R                  R                  S
\\/\4   4S jrS\R                  R                  4S jrg)z.
This module contains APIs to manipulate ops.
    )	dataclass)CallableDictN)
TensorSpecc                       \ rS rSr% \R
                  \S'   \R                  \S'   \R                  r	\R                  \S'   \R                  " S5      r
\R                  \S'   Sr\\S'   S	rg
)ScratchTensorMetadata   dtypeshapelayoutcpudeviceF	is_sparse N)__name__
__module____qualname____firstlineno__torchr
   __annotations__Sizestridedr   r   r   bool__static_attributes__r       ]/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/executorch/exir/operator/manip.pyr   r      sI    ;;:: ==FELL( <<.FELL.Itr   r   .out_variantreturnc                    ^ ^^ S[         S[        4S jmS[        S[        S[        [
        [        4   4   4U4S jjmS[        S[        4UU 4S jjnU$ )a  
Apply this decorator to the get_scratch_metas methods for `out_variant` op.
The decorator will do the job to attach the get_scratch_metas method
to the out variant op.

The get_scratch_metas method has the same signature as the out variant op.
There are 2 difference though:
- the Tensor input arguments are all replaced with TensorSpec
- the output is a dictionary of ScratchTensorMetadata
metar   c           	      n    [        SSU R                  U R                  U R                  U R                  S9$ )NF)constrequires_gradr
   r   r   r   )r   r
   r   r   r   )r    s    r   to_tensor_spec3attach_get_scratch_metas_fn.<locals>.to_tensor_spec-   s1    ****;;nn
 	
r   get_scratch_metas_fn.c                 Z   >^  S[         S[         S[        [        [         4   4U U4S jjnU$ )zA
Adapt return value from a ScratchTensorMetadata to a TensorSpec
argskwargsr   c                  x   > T" U 0 UD6nUR                  5        VVs0 s H  u  p4UT" U5      _M     snn$ s  snnf N)items)r(   r)   	meta_dictkvr&   r$   s        r   wrapperHattach_get_scratch_metas_fn.<locals>.adapt_return_value.<locals>.wrapper?   s?    ,d=f=I5>__5FG5FTQA~a((5FGGGs   6)r   r   str)r&   r0   r$   s   ` r   adapt_return_value7attach_get_scratch_metas_fn.<locals>.adapt_return_value8   s7    	H: 	H 	HS*_@U 	H 	H r   c                 "   > T" U 5      Tl         U $ r+   )get_scratch_metas)r&   r3   r   s    r   r0   ,attach_get_scratch_metas_fn.<locals>.wrapperE   s    (:;O(P%##r   )r   r   ScratchCallableTyper   r   r2   )r   r0   r3   r$   s   ` @@r   attach_get_scratch_metas_fnr9      s`    	
2 	
z 	
1	#tCO,,	-$&9 $>Q $ $
 Nr   func_opc                    ^  U 4S jnU$ )z4
The input is the OpOverload for the functional op.
c                    > U Tl         U $ r+   )calculate_upper_bound_shape)calculate_upper_bound_shape_fnr:   s    r   r0   6attach_calculate_upper_bound_shape_fn.<locals>.wrapperT   s    .L+--r   r   )r:   r0   s   ` r   %attach_calculate_upper_bound_shape_fnr@   N   s    .
 Nr   )__doc__dataclassesr   typingr   r   r   executorch.exir.tensorr   r   r2   r8   _ops
OpOverloadr9   r@   r   r   r   <module>rG      s    " !  -    sD.C)C$DDE +&&+"#%889+^5::3H3H r   