a
    h(                     @   s   d dl Z d dlZd dlZd dlmZ dd Zdd Zdd Zd	d
 Z	dd Z
dd Zd"ddZdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Ze ZdS )#    N)_find_builtinc                 C   s   |  do|  d S )N___)
startswith)name r   E/var/www/auris/lib/python3.9/site-packages/torch/jit/supported_ops.py_hidden   s    r	   c                 C   s   t | S N)str)typer   r   r   
_emit_type   s    r   c                 C   sT   |j  dt|j }|j}|d ur6| dt| }|dkrPdd|   | }|S )Nz : =r   
 )r   r   r   default_valuer   )indentiargvdefaultr   r   r   	_emit_arg   s    r   c                    s   d  fddt|D S )N,c                 3   s   | ]\}}t  ||V  qd S r
   )r   ).0r   r   r   r   r   	<genexpr>!       z_emit_args.<locals>.<genexpr>)join	enumerate)r   	argumentsr   r   r   
_emit_args    s    r    c                 C   s
   t | jS r
   )r   r   )retr   r   r   	_emit_ret$   s    r"   c                 C   s4   t | dkrt| d S dddd | D  dS )N   r   zTuple[z, c                 s   s   | ]}t |V  qd S r
   )r"   )r   rr   r   r   r   +   r   z_emit_rets.<locals>.<genexpr>])lenr"   r   )returnsr   r   r   
_emit_rets(   s    r(      c                 C   sV   | d u r|}n|  d| }| dt t|d | |j|d   dt|j }|S )N.(r#   z) -> )r    r&   r   r(   r'   )modr   schema	arg_startpaddingZqualified_name
schema_strr   r   r   _emit_schema.   s    r1   c               
   C   sd   dd } g }t tjD ]D}t|stjd| }|D ]"}| |r6|td||dd q6qd|fS )Nc                 S   sF   t | jdkrdS | jd }|jdkr*dS |jtjj sBdS dS )Nr   FselfT)	r&   r   r   r   ZisSubtypeOftorch_CZ
TensorTypeget)r-   r2   r   r   r   is_tensor_method<   s    

z)_get_tensor_ops.<locals>.is_tensor_methodaten::Tensorr#   )r.   zSupported Tensor Methods)dirr3   r8   r	   r4   _jit_get_schemas_for_operatorappendr1   )r6   methodselemschemasr-   r   r   r   _get_tensor_ops;   s    
r?   c               	   C   s  g } t jj}|j}tt jjD ]}t||}t|rt|d rDqt	|}|sbt
d| dd|jvrnqz(t j|}|j}| t||| W q   Y q0 qt jjjD ]^}|j}t|D ]J}tt||}|d urt j|}	|	D ]}
t|s| t|||
 qqqd| fS )Nr   Module for 
 not foundztorch.nn.functionalzSupported PyTorch Functions)r3   nnZ
functional__name__r9   getattrinspect
isfunctionr	   	getmoduleRuntimeErrorjitscriptr-   r;   r1   	_builtinsZ_modules_containing_builtinsr   r4   r:   )	functionsr,   r   r=   attrZattr_moduleZscriptedZscripted_schemabuiltinr>   r-   r   r   r   _get_nn_functional_opsR   s8    


rO   c                  C   sr   g } t jjjD ]^\}}t|}t|ds,q|s2qt|jst|j	st|jrRqd|jv r^q| 
||f q| S )NrC   ztorch._C)r3   rI   rK   Z_builtin_opsrE   rG   hasattrr	   rC   __qualname__r;   )builtinsfn_builtin_namer,   r   r   r   _get_builtins_helper}   s    


rU   c                 C   s(   t | }|std|  d|jdkS )Nr@   rA   math)rE   rG   rH   rC   )rS   r,   r   r   r   _is_math_fn   s    
rW   c            	      C   s   g } t dd t }t|}|D ]b\}}t|}|sFtd| dt|}|d ur tj	|}|D ]}| 
t|j|j| qfq d| fS )Nc                 S   s   t | d  S Nr   rW   rS   r   r   r   <lambda>   r   z+_get_torchscript_builtins.<locals>.<lambda>r@   rA   zTorchScript Builtin Functions)filterrU   listrE   rG   rH   r   r3   r4   r:   r;   r1   rC   )	rL   rR   builtins_listrS   rT   r,   rN   r>   r-   r   r   r   _get_torchscript_builtins   s    
r_   c            
      C   s   g } t dd t }t|}|D ]p\}}t|}|sFtd| dt|}|d ur tj	|}|D ](}t
|j|j|}	d|	v rqf| | qfq d| fS )Nc                 S   s   t | d S rX   rY   rZ   r   r   r   r[      r   z$_get_math_builtins.<locals>.<lambda>r@   rA   r8   z``math`` Module)r\   rU   r]   rE   rG   rH   r   r3   r4   r:   r1   rC   r;   )
rL   rR   r^   rS   rT   r,   rN   r>   r-   r0   r   r   r   _get_math_builtins   s     
r`   c               
   C   sX  g d} dddddddd	d
}ddddddddd}g d}g }|D ] \}}| d| d| d qDg }g }| D ]}d| }	||v r|| }	tj|	}
|
D ]}| td ||dd qt|
dkr| d qrd| d||  d}| | qrd|}d|}d|}t|d}t|d}t|d}d| d| d | d!}d"|fS )#N)printtuplefloatcomplexintboolr   rD   rP   
isinstancer&   hexoctroundhashminmaxabsalldivmodr]   ordchrbinrangezipr   sortedz
aten::Boolz	aten::Intzaten::Floatzaten::Complexz	prim::absz	prim::maxz	prim::minzfake::does_not_exist)rf   re   rc   rd   rn   rm   rl   rt   zPrint any valuez]Lists cannot be converted to tuples with this method since their size is not statically knownz'Attribute name must be a literal stringzResult is staticzMArguments must be iterable. See :ref:`Iterables <jit_iterables>` for details.z-Can only be used as an iterator in a for loop)ra   rb   rD   rP   rg   ru   r   rt   ))rd   __complex__)rc   	__float__)re   __int__)rf   __bool__)r   __str__)r&   __len__)rh   Z__hex__)ri   Z__oct__"z", "``z``"r7   r   )r/    z":external+python:py:obj:`z`", "r   	z
The functions in the following table are supported but do not have a static schema

.. csv-table::
    :header: "Function", "Note"

z

The following functions will use the corresponding magic method on :any:`TorchScript classes`

.. csv-table::
    :header: "Function", "Magic Method"

zX

These built-in functions use the schema

.. rst-class:: codeblock-height-limiter

::

z
    zPython Built-in Functions)	r;   r3   r4   r:   r1   r&   r   textwrapr   )Zsupported_builtinsZ
op_renamesZschemaless_op_explanationsZmagic_methodsZmagic_methods_rowsrS   Zmagic_methodZschematized_opsZschemaless_opsZop_namer>   sZ	table_rowZschematized_ops_strZschemaless_ops_strZmagic_methods_rows_strsectionr   r   r   _get_global_builtins   sf     



r   c                  C   s   dd } d}t ttttf}|D ]}| \}}|dddd dd}t|trv| ddt	|  d| d}n | ddt	|  d| | }d	| d
d | }||7 }q|S )Nc                 S   s   d ddd | D S )Nz1
.. rst-class:: codeblock-height-limiter

::

{}
r~   c                 s   s   | ]}d | dV  qdS )z    

Nr   )r   dr   r   r   r   @  r   z:_list_supported_ops.<locals>.emit_block.<locals>.<genexpr>)formatr   )Zdeclsr   r   r   
emit_block>  s    z'_list_supported_ops.<locals>.emit_blockr~   `-r   r   ~z.. _:r   )
r?   rO   r_   r   r`   replacelowerrg   r   r&   )r   bodyZop_gathering_fnsrS   headeritemsZlink_targetr   r   r   r   _list_supported_ops=  s"    
 
  
r   )r   r)   )rE   r   Z	torch.jitr3   Ztorch.jit._builtinsr   r	   r   r   r    r"   r(   r1   r?   rO   rU   rW   r_   r`   r   r   __doc__r   r   r   r   <module>   s&   

+y