o
    r::jn                     @  s   d dl mZ d dlZd dlmZ d dlmZmZ d dl	m
Z
 d dlmZ G dd de
ZG d	d
 d
eZG dd deZG dd deZG dd deZdS )    )annotationsN)TensorProto)np_dtype_to_tensor_dtypetensor_dtype_to_np_dtype)OpRun)reshape_inputc                   @  s    e Zd Z				ddddZdS )_CommonDequantizeLinearN   r   x
np.ndarrayx_scalex_zero_pointnp.ndarray | Noneaxisint
block_sizeoutput_dtype
int | Nonec                 C  s  t |j}|tjtjtjtjhv }|d ur?|s?|tjkr?t |j}	||	kr0td| d|	 d|	t
jt||j|| }
n)|rb|d urb|	t
j}| }| }||ks^|t
dkrbtd|	t
j}
|
t||j|| }|	|r|t|fS |jfS )NzType mismatch z != z in DequantizeLinear.r   z=x_zero_point is not null but should be zero for float8 types.)r   dtyper   FLOAT8E4M3FNFLOAT8E4M3FNUZ
FLOAT8E5M2FLOAT8E5M2FNUZ
FLOAT4E2M1
ValueErrorastypenpfloat32_reshape_inputshapeuint8minmaxr   )selfr
   r   r   r   r   r   x_typefp8_type	zero_typedxu_x_zero_pointumiumay r,   n/home/nk/hobo-godmode/plappi-mvp/.venv/lib/python3.10/site-packages/onnx/reference/ops/op_dequantize_linear.py_run   sJ   
	


z_CommonDequantizeLinear._run)Nr	   r   N)r
   r   r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname__r.   r,   r,   r,   r-   r      s    r   c                      s    e Zd Zdd fddZ  ZS )	DequantizeLinear_19Nr	   r   r   c                   s(   t |jdkrtdt ||||S )Nr	   z%Input 2 must be a vector or a number.)lenr   r   superr.   )r#   r
   r   r   r   	__class__r,   r-   r.   B   s   zDequantizeLinear_19._run)Nr	   )r   r   r/   r0   r1   r.   __classcell__r,   r,   r5   r-   r2   A   s    r2   c                      s&   e Zd Zdddd	 fddZ  ZS )
DequantizeLinear_21r	   r   r   r   r   r   r   c                  s   t  j|||dS )Nr:   r4   r.   )r#   r   r   argsr5   r,   r-   r.   I   s   zDequantizeLinear_21._runr   r   r   r   r7   r,   r,   r5   r-   r9   H   s    r9   c                      (   e Zd Zddddd
 fdd	Z  ZS )DequantizeLinear_23r	   r   Nr   r   r   r   r   r   c                     t  j||||dS Nr@   r;   r#   r   r   r   r<   r5   r,   r-   r.   O      zDequantizeLinear_23._runr=   r7   r,   r,   r5   r-   r?   N        r?   c                      r>   )DequantizeLinear_25r	   r   Nr@   r   r   r   c                  rA   rB   r;   rC   r5   r,   r-   r.   W   rD   zDequantizeLinear_25._runr=   r7   r,   r,   r5   r-   rF   V   rE   rF   )
__future__r   numpyr   onnxr   onnx.helperr   r   onnx.reference.op_runr   onnx.reference.ops._quant_utilsr   r   r   r2   r9   r?   rF   r,   r,   r,   r-   <module>   s   3