o
    fi(                     @   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   a/var/www/addictedbytheproject.nl/epg/venv/lib/python3.10/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r| dt| }|dkr(d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>!   s    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   +   s    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paddingqualified_name
schema_strr   r   r   _emit_schema.   s   r1   c               
   C   sj   dt fdd} g }ttjD ]"}t|s0tjd| }|D ]}| |r/|td||dd qqd|fS )	Nreturnc                 S   sF   t | jdkr	dS | jd }|jdkrdS |jtjj s!dS dS )Nr   FselfT)	r%   r   r   r   isSubtypeOftorch_C
TensorTypeget)r,   r3   r   r   r   is_tensor_method<   s   

z)_get_tensor_ops.<locals>.is_tensor_methodaten::Tensorr"   )r-   zSupported Tensor Methods)	booldirr5   r;   r	   r6   _jit_get_schemas_for_operatorappendr1   )r9   methodselemschemasr,   r   r   r   _get_tensor_ops;   s   
rC   c               	   C   s  g } t jj}|j}tt jjD ]A}t||}t|r!t|d r"qt	|}|s1t
d| dd|jvr7qzt j|}|j}| t||| W q   Y qt jjjD ]/}|j}t|D ]%}tt||}|d urt j|}	|	D ]}
t|s| t|||
 qtq_qVd| fS )Nr   Module for 
 not foundztorch.nn.functionalzSupported PyTorch Functions)r5   nn
functional__name__r=   getattrinspect
isfunctionr	   	getmoduleRuntimeErrorjitscriptr,   r?   r1   	_builtins_modules_containing_builtinsr   r6   r>   )	functionsr+   r   rA   attrattr_modulescriptedscripted_schemabuiltinrB   r,   r   r   r   _get_nn_functional_opsR   s<   


rX   c                  C   sr   g } t jjjD ]/\}}t|}t|dsq|sqt|js(t|j	s(t|jr)qd|jv r/q| 
||f q| S )NrH   ztorch._C)r5   rN   rP   _builtin_opsrJ   rL   hasattrr	   rH   __qualname__r?   )builtinsfn_builtin_namer+   r   r   r   _get_builtins_helper}   s   


r_   c                 C   s(   t | }|std|  d|jdkS )NrD   rE   math)rJ   rL   rM   rH   )r]   r+   r   r   r   _is_math_fn   s   

ra   c            	      C   s   g } t dd t }t|}|D ]1\}}t|}|s#td| dt|}|d urAtj	|}|D ]}| 
t|j|j| q3qd| fS )Nc                 S   s   t | d  S Nr   ra   r]   r   r   r   <lambda>   s    z+_get_torchscript_builtins.<locals>.<lambda>rD   rE   zTorchScript Builtin Functions)filterr_   listrJ   rL   rM   r   r5   r6   r>   r?   r1   rH   )	rR   r\   builtins_listr]   r^   r+   rW   rB   r,   r   r   r   _get_torchscript_builtins   s   
ri   c            
      C   s   g } t dd t }t|}|D ]8\}}t|}|s#td| dt|}|d urHtj	|}|D ]}t
|j|j|}	d|	v rBq3| | q3qd| fS )Nc                 S   s   t | d S rb   rc   rd   r   r   r   re      s    z$_get_math_builtins.<locals>.<lambda>rD   rE   r;   z``math`` Module)rf   r_   rg   rJ   rL   rM   r   r5   r6   r>   r1   rH   r?   )
rR   r\   rh   r]   r^   r+   rW   rB   r,   r0   r   r   r   _get_math_builtins   s"   
rj   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 q"g }g }| D ]A}d| }	||v rH|| }	tj|	}
|
D ]}| td ||dd qPt|
dkrj| d q9d| d||  d}| | q9d|}d|}d|}t|d}t|d}t|d}d| d| d | d!}d"|fS )#N)printtuplefloatcomplexintr<   r   rI   rZ   
isinstancer%   hexoctroundhashminmaxabsalldivmodrg   ordchrbinrangezipr   sortedz
aten::Boolz	aten::Intzaten::Floatzaten::Complexz	prim::absz	prim::maxz	prim::minzfake::does_not_exist)r<   ro   rm   rn   rw   rv   ru   r}   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 staticzArguments must be iterable.z-Can only be used as an iterator in a for loop)rk   rl   rI   rZ   rp   r~   r   r}   ))rn   __complex__)rm   	__float__)ro   __int__)r<   __bool__)r   __str__)r%   __len__)rq   __hex__)rr   __oct__"z", "``z``"r:   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 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?   r5   r6   r>   r1   r%   r   textwrapr   )supported_builtins
op_renamesschemaless_op_explanationsmagic_methodsmagic_methods_rowsr]   magic_methodschematized_opsschemaless_opsop_namerB   s	table_rowschematized_ops_strschemaless_ops_str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 ]J}| \}}|dddd dd}t|tr;| 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   B  s    z:_list_supported_ops.<locals>.emit_block.<locals>.<genexpr>)formatr   )declsr   r   r   
emit_block@  s   z'_list_supported_ops.<locals>.emit_blockr   `-r   r   ~z.. _:r   )
rC   rX   ri   r   rj   replacelowerrp   r   r%   )r   bodyop_gathering_fnsr]   headeritemslink_targetr   r   r   r   _list_supported_ops?  s"   
 
  
r   )r   r(   )rJ   r   	torch.jitr5   torch.jit._builtinsr   r	   r   r   r   r!   r'   r1   rC   rX   r_   ra   ri   rj   r   r   __doc__r   r   r   r   <module>   s(   

+{
