
    wi                        d dl mZ d dlZd dlmZmZ d Z G d de          Z G d de          Z	 G d	 d
e	          Z
 G d de          Z G d de          ZdS )    )annotationsN)OpRunRefAttrNamec                    | j         }t          |t          j                   s#t          d| dt	          |           d          d S )NzType (z, z+) is not a numpy type (operator 'Constant'))dtype
isinstancenp	TypeErrortype)valr   s     n/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/onnx/reference/ops/op_constant.py_check_dtyper      sU    IEeRX&& 
VUVVd5kkVVV
 
 	

 
    c                      e Zd Zd ZdS )ConstantCommonc                p    t          |t                    r t          dt          |           d          |S )NzUnexpected type z for a constant.)r   tupler
   r   )selfcsts     r   _checkzConstantCommon._check   s:    c5!! 	LJtCyyJJJKKK
r   N)__name__
__module____qualname__r    r   r   r   r      s#            r   r   c                      e Zd Zd Zd ZdS )
Constant_1c                ~    t                               | ||           | j        | _        t	          | j                   d S N)r   __init__valuer   r   r   	onnx_node
run_paramss      r   r   zConstant_1.__init__   s9    i<<<:TXr   c                    |rQt          |          dk    s/d|vs+t          |d                   t          | j                  k    rt          d          |                     | j                  fS N   r    zHFunction attributes are not implemented for opset <= 11. Use opset > 12.lenidr    RuntimeErrorr   r   r   overridden_attributess     r   _runzConstant_1._run    y      	%&&**333'011R
^^CCZ   DH%%''r   Nr   r   r   r   r-   r   r   r   r   r      s2          
	( 	( 	( 	( 	(r   r   c                      e Zd Zd ZdS )
Constant_9c                >    t                               | ||           d S r   )r   r   r!   s      r   r   zConstant_9.__init__-   s     D)Z88888r   N)r   r   r   r   r   r   r   r1   r1   ,   s#        9 9 9 9 9r   r1   c                      e Zd Zd Zd ZdS )Constant_11c                    t                               | ||           t          | dd           | j        | _        n| j        | _        t          | j                   d S )Nsparse_value)r   r   getattrr    r   r6   r   r!   s      r   r   zConstant_11.__init__2   sW    i<<<4..6zDHH(DHTXr   c                    |rQt          |          dk    s/d|vs+t          |d                   t          | j                  k    rt          d          |                     | j                  fS r%   r'   r+   s     r   r-   zConstant_11._run:   r.   r   Nr/   r   r   r   r4   r4   1   s2          	( 	( 	( 	( 	(r   r4   c                      e Zd Zd Zd ZdS )Constant_12c                    t                               | ||           t          | d          r$| j        d| _        | j        | _        d | _        nt          | d          r#| j        d| _        | j        | _        d | _        nt          j	        t          j	        t          j
        t          j
        t          j        t          j        d                                D ]z\  }}t          | |          ret          | |          U|| _        t          | |          }t          |t                    r|nt          j        ||          | _        |fd| _         n{t          | d          st#          d	|j         d
          d S )Nr6   c                    | S r   r   vs    r   <lambda>z&Constant_12.__init__.<locals>.<lambda>L        r   r    c                    | S r   r   r=   s    r   r?   z&Constant_12.__init__.<locals>.<lambda>P   r@   r   )value_floatvalue_floats	value_int
value_intsvalue_stringvalue_stringsr   c                .    t          j        | |          S )NrH   )r	   array)r>   np_dtypes     r   r?   z&Constant_12.__init__.<locals>.<lambda>`   s    BHE E E r   cst_namez<No constant is defined for operator 'Constant', outputs are .)r   r   hasattrr6   rL   r   cst_convertr    r	   float32int64str_itemsr7   r   r   rJ   AttributeErroroutput)r   r"   r#   attrrK   r>   s         r   r   zConstant_12.__init__G   s   i<<<4(( 	T->-J*DM(DH*{DT7## 	
(>#DMzDH*{D  "z "
X h "!## # egg h 4&& 	74+>+>+J$(DMd++A';77XRXax=X=X=X H ;C ( ( (D$ EtZ(( 	 byO_bbb  	 	r   c                \   | j         r|t          d| j        d          | j        |vr(t          d| j        dt	          |          d          || j                 }t          |t          j                  r|fS |                     |          fS | 	                    | j                  fS )Nz0Attributes are empty, cannot retrieve value for rM   zCannot find attribute z in )
has_linked_attributer*   r   rL   listr   r	   ndarrayrO   r   )r   r,   r    s      r   r-   zConstant_12._runi   s    $ 	.$,"TtxTTT   }$999"bT]bb$G\B]B]bbb   *$-8E%,,  x$$U++--DH%%''r   Nr/   r   r   r   r:   r:   F   s3             D( ( ( ( (r   r:   )
__future__r   numpyr	   onnx.reference.op_runr   r   r   r   r   r1   r4   r:   r   r   r   <module>r^      s(   # " " " " "     4 4 4 4 4 4 4 4
 
 
    U   ( ( ( ( ( ( ( ($9 9 9 9 9 9 9 9
( ( ( ( (. ( ( (*1( 1( 1( 1( 1(. 1( 1( 1( 1( 1(r   