o
    toiZ@                     @  sf  d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	Z
d dlmZmZ d dlmZ d dlmZ d dlmZmZ erBd d	lmZ e Ze Zeed
dk ZdEddZdFddZdGddZdHddZdId!d"Z dJd$d%Z!dKd&d'Z"dKd(d)Z#dLd,d-Z$dMd0d1Z%dNd4d5Z&dOd8d9Z'G d:d; d;eZ(dPd>d?Z)e*d@krere)e(dAdB e)e(dCdD dS dS )Q    )annotationsNdefaultdict)TYPE_CHECKINGAny
NamedTuple)defshelper)collect_sample_implementations)collect_snippets)ONNX_ML_DOMAINOpSchema)SequenceONNX_ML0vintreturnstrc                 C  s   t j| rdS t| S )Nz&#8734;)r   r   is_infiniter   )r    r   E/home/ubuntu/.local/lib/python3.10/site-packages/onnx/defs/gen_doc.pydisplay_number   s   r   domainoutputboolc                 C  s   d|v }| t kr
|S | S )Nz-ml)r   )r   r   is_mlr   r   r   should_render_domain!   s   r   schema_namec                 C  s   | r	|  d| S |S )N.r   )r   r   r   r   r   format_name_with_domain(   s   r    function_versionsSequence[int]c                 C  s   d dd | D  S )N, c                 S  s   g | ]}t |qS r   )r   .0r   r   r   r   
<listcomp>/       z,format_function_versions.<locals>.<listcomp>join)r!   r   r   r   format_function_versions.   s   r*   versionsSequence[OpSchema]	changelogc                   s$   d  fdd| d d d D  S )Nr#   c                 3  (    | ]}t t|j|j|j V  qd S Ndisplay_version_linkr    r   namesince_versionr$   r-   r   r   	<genexpr>3   s   & z"format_versions.<locals>.<genexpr>r(   )r+   r-   r   r4   r   format_versions2   s   $r7   OpSchema.AttrTypec                 C  sJ   t | tjsJ t| }||dd d   }|d dkr#d| }|S )Nr      r6   szlist of )
isinstancer   AttrTyper   rfindlower)r   r:   r   r   r   display_attr_type6   s   r?   c                 C  s   | rd|  dS dS )Nzthe 'z' operator setzthe default ONNX operator setr   r   r   r   r   display_domain?   s   rA   c                 C  s   | r| S dS )Nzai.onnx (default)r   r@   r   r   r   display_domain_shortE   s   rB   r2   versionc                 C  s&   |  d| }d| d| d| dS )N-z	<a href="#z">z</a>r   )r2   rC   r-   name_with_verr   r   r   r1   K   s   r1   formal_parameterOpSchema.FormalParameterc                 C  s   g }t jj| jkrdg}nt jj| jkr| jrdg}nddg}t jj}t jj}|| j	kr2|
d n
|| j	kr<|
d t|dkrDdS dd	| d
 S )Noptionalvariadicheterogeneousdifferentiableznon-differentiabler     (r#   ))r   FormalParameterOptionOptionaloptionVariadicis_homogeneousDifferentiationCategoryDifferentiableNonDifferentiabledifferentiation_categoryappendlenr)   )rG   tagsrL   non_differentiabler   r   r   generate_formal_parameter_tagsP   s    


"r]   schemar   c              	     s  d}| j r|d7 }|ddd | j   D 7 }|d7 }|d7 }| jtjjkr.|d7 }n7|d| jr5dnd	 d
| j	  7 }|dt
| j d7 }t|dkre|dd fdd|d d D 7 }| jrj|S | jr|d7 }|d7 }t| j D ][\}}d}|jrd}n-|jjrt|j}|jj}d.ddt|trfdd|D }n|}d| | }|d|j dt|j |rd | d!nd d"7 }|d#|j d$7 }q||d%7 }|d&7 }| j| jkr|d t| j d't| j d!7 }|d(7 }| jr+|d7 }| jD ] }	t |	}
|d|	j d)|
 d*|	j! d"7 }|d#|	j d$7 }q|d%7 }|d+7 }| j"| j#krG|d t| j" d't| j# d!7 }|d(7 }| j$r{|d7 }| j$D ] }t |}
|d|j d)|
 d*|j! d"7 }|d#|j d$7 }qV|d%7 }|d,7 }|d(7 }| j%r|d7 }| j%D ]6}|j&}t|d-kr|d- }|dd  D ]	}|d| 7 }q|d|j' d| d"7 }|d#|j d$7 }q|d%7 }|S )/NrM   
c                 s  s    | ]	}d |   V  qdS )z  N)rstrip)r%   liner   r   r   r5   o   s    
z!display_schema.<locals>.<genexpr>z
#### Version
z/
No versioning maintained for experimental ops.z'
This version of the operator has been 
deprecated	availablez since version  of z.
r9   z%
Other versions of this operator: {}
r#   c                 3  r.   r/   r0   r$   r4   r   r   r5      s    
r6   z
#### Attributes

z<dl>
requiredvaluer   r   r   c                 S  s`   t | trtt| d}t|dkrtd| dd}|S t | ttfr,t| dS t| S )N   
   (erO   utf-8)	r;   floatr   nproundrZ   bytes	bytearraydecode)rf   	formattedr   r   r   format_value   s   
z$display_schema.<locals>.format_valuec                   s   g | ]} |qS r   r   )r%   val)rs   r   r   r&      r'   z"display_schema.<locals>.<listcomp>zdefault is z<dt><tt>z</tt> : rN   rO   z</dt>
z<dd>z</dd>
z</dl>
z
#### Inputsz - 

z</tt>z : z
#### Outputsz
#### Type Constraintsr   )rf   r   r   r   )(docr)   lstrip
splitlinessupport_levelr   SupportTypeEXPERIMENTALrb   r3   rA   r   rZ   format
attributessorteditemsre   default_valuer2   r	   get_attribute_value
doc_stringr;   listr?   typedescription	min_input	max_inputr   inputsr]   type_str
min_output
max_outputoutputstype_constraintsallowed_type_strstype_param_str)r^   r+   r-   r:   _attroptr   r   input_
option_strr   type_constraintallowedTypesallowedTypeStrallowedTyper   )r-   rs   r   display_schemag   s   





2"
 "
 
r   levelOpSchema.SupportTypec                 C  s   | t jjkrdS dS )Nz<sub>experimental</sub> rM   )r   rz   r{   )r   r   r   r   support_level_str   s   r   c                   @  s   e Zd ZU ded< ded< dS )Argsr   r   r-   N)__name__
__module____qualname____annotations__r   r   r   r   r      s   
 r   argsNonec                 C  s  t jt jt jt jt}t j|d}tt j|| jdddd}|d |d |d t	d	d
 }t
 D ]}||j |j | qA|d t| D ]f\}}t|| jseqZdt| d}t| D ]G\}	}
|d|	 dt| d7 }t|
dd
 dD ]-}t||j d|j }|d|jrdnd d ||7 }|t||g| j7 }|d7 }qqs|| qZW d    n1 sw   Y  tt j|| jdddd}|d |d |d t	dd
 }t
 D ]}||j t|j |j | q|d g }t }t| D ]Z\}}t|| js)qg }t| D ]<\}}g }t| D ]'\}}t|dd
 d}|d }|j|v rUq=||j ||||f q=|||f q1|||f q|D ]\}}dt| d}|| |d |d g }|D ]E\}}|D ]=\}}}|js|jr|j }|||||f qdt!|jt||t|||jrdndt"|| j}|| qq|r|d |D ]$\}}}}dt!|jt||t||t"|| jt#|}|| q|d qy|d |D ]\}}dt| d}|| |D ]\}}|D ]\}}}d |jr@dnd d t!|jt||t||$ t||}|t||| j7 }|d!7 }|t%v r|d"7 }tt%| D ]!\}}|d#7 }|d$| d%7 }|d&| d'7 }|d(7 }|d!7 }qu|$ t&v r|d)7 }|d#7 }|d$| d%7 }|d&t&|$   d'7 }|d(7 }|d!7 }|| q4q.qW d    d S 1 sw   Y  d S )*NdocswrM   rk   )newlineencodingz.<!--- SPDX-License-Identifier: Apache-2.0 -->
z## Operator Changelog
a  *This file is automatically generated from the
            [def files](/onnx/defs) via [this script](/onnx/defs/gen_doc.py).
            Do not modify directly and instead edit operator definitions.*

For an operator input/output's differentiability, it can be differentiable,
            non-differentiable, or undefined. If a variable's differentiability
            is not specified, that variable has undefined differentiability.
c                   S     t tS r/   r   r   r   r   r   r   <lambda>      zmain.<locals>.<lambda>r_   z# z## Version rd   c                 S     | j S r/   )r2   r:   r   r   r   r         )keyrD   z### <a name="{}"></a>**{}**z (deprecated)z</a>
z## Operator Schemas
c                   S  s   t dd S )Nc                   S  r   r/   r   r   r   r   r   r   3  r   z(main.<locals>.<lambda>.<locals>.<lambda>r   r   r   r   r   r   3  s    c                 S  r   r/   )r3   r   r   r   r   r   H  r   r6   z### z"|**Operator**|**Since version**||
z|-|-|-|
z|{}<a href="#{}">{}</a>{}|{}|
z6|**Function**|**Since version**|**Function version**|
z|{}<a href="#{}">{}</a>|{}|{}|
z## z*### {}<a name="{}"></a><a name="{}">**{}**ru   z#### Examples

z
<details>
z	<summary>z</summary>

z
```python
z
```

z</details>
z#### Sample Implementation

)'ospathdirnamerealpath__file__r)   openr-   writer   r   get_all_schemas_with_historyr   r3   rY   r~   r   r   r   rB   rA   r    r2   rb   r|   r   r   ry   setaddhas_functionhas_context_dependent_functionall_function_opset_versionsr   r7   r*   r>   SNIPPETSSAMPLE_IMPLEMENTATIONS)r   base_dirdocs_dirfoutdv_indexr^   r   
versionmapr:   rC   unsorted_schemasrF   indexoperator_schemasexisting_ops_supportmapprocessed_supportmap_support_namemapprocessed_namemapnunsorted_versionsr+   
supportmapfunction_opsr   namemapr!   op_typesummarycoder   r   r   main   s&  




,

"









$r   __main__zOperators-ml.mdzChangelog-ml.mdzOperators.mdzChangelog.md)r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r!   r"   r   r   )r+   r,   r-   r   r   r   )r   r8   r   r   )r   r   r   r   )r2   r   rC   r   r-   r   r   r   )rG   rH   r   r   )r^   r   r+   r,   r-   r   r   r   )r   r   r   r   )r   r   r   r   )+
__future__r   r   collectionsr   typingr   r   r   numpyrm   onnxr   r	   onnx.backend.sample.opsr
   onnx.backend.test.caser   	onnx.defsr   r   collections.abcr   r   r   r   getenvr   r   r   r    r*   r7   r?   rA   rB   r1   r]   r   r   r   r   r   r   r   r   r   <module>   sX   






	




~
 2