
    Si                        S SK Jr  S SKrS SKJr  S SKJrJr  S SK	J
r
   S         SS jjr " S S\
5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      rg)    )annotationsN)TensorProto)np_dtype_to_tensor_dtypetensor_dtype_to_np_dtype)OpRunc           
        [        U R                  5      S:X  a  U $ [        U R                  5      S:  a  U R                  S:X  a  U S   $ U(       dS  [        U R                  5      S:X  d   eS/[        U5      -  n U R                  XB'   U R                  [	        U5      5      $ US::  a  [        S5      e[        R                  " XUS	9n X   U R                  U   :w  a  U R                  [        X   5      US
9n U R                  U:w  a  [        S5      e[        R                  " XR                  5      U:X  d   eU $ ! [
         a%  n[        SU SU R                   SU S35      UeSnAff = f)a  Reshape/Replicate scale/zero-point to be broadcastable to shape.

Args:
    value: the array to be reshaped/replicated
    shape: the target shape
    axis: quantization axis, applicable for per-axis and blocked quantization
    block_size: size of quantization block, applicable only for blocked quantization

Returns:
    value array after reshape/replicate according to quantization mode.
r      zaxis is out of boundary, axis=z, value.shape=z, shape=.Nz&block_size must be a positive integer.)repeatsaxis)indicesr   zInvalid shapes for Blocked Quantization. Input 2 shape should identical to Input 1 shape, except for one dimension, in which blocking is performed)lenshapesizereshapetuple
IndexError
ValueErrornprepeattakerangebroadcast_shapes)valuer   r   
block_sizedimses         f/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx/reference/ops/op_dequantize_linear.py_reshape_inputr      sg   " 5;;1
5;;!

aQx5;;1$$$sSZ	DJ==t-- QABB IIed;Eu{{4((

5#5D
A{{e a
 	
 ukk2e;;;L)  	0 7${{m8E7!= 	s   <'D= =
E, E''E,c                  @    \ rS rSr    S           SS jjrSrg)_CommonDequantizeLinear?   Nc                l   [        UR                  5      nU[        R                  [        R                  [        R
                  [        R                  1;   nUb~  U(       dw  U[        R                  :w  ac  [        UR                  5      n	Xy:w  a  [        SU SU	 S35      eUR                  [        R                  5      [        X1R                  XE5      -
  n
OU(       al  Ubi  UR                  [        R                  5      nUR                  5       nUR!                  5       nX:w  d  U[        R                  " S5      :w  a  [        S5      eUR                  [        R                  5      n
U
[        X!R                  XE5      -  nUR                  U(       a  [#        U5      5      4$ UR                  5      4$ )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
FLOAT4E2M1r   astyper   float32r   r   uint8minmaxr   )selfxx_scalex_zero_pointr   r   output_dtypex_typefp8_type	zero_typedxu_x_zero_pointumiumays                  r   _run_CommonDequantizeLinear._run@   s    *!''2$$&&""&&	
 
 $+00001C1CDI" $VHD;PQ  "**%ggt) B L4!-!4!4RXX!>$((*$((*:!3$W  "**%B$CCHH )6
 	
 ]]
 	
     )Nr	   r   N)r0   
np.ndarrayr1   r@   r2   znp.ndarray | Noner   intr   rA   r3   
int | None)__name__
__module____qualname____firstlineno__r<   __static_attributes__r?   r>   r   r!   r!   ?   sT    
 +/#'/
/
 /
 (	/

 /
 /
 !/
 /
r>   r!   c                  0   ^  \ rS rSrSSU 4S jjjrSrU =r$ )DequantizeLinear_19r   c                l   > [        UR                  5      S:  a  [        S5      e[        TU ]  XX45      $ )Nr	   z%Input 2 must be a vector or a number.)r   r   r   superr<   )r/   r0   r1   r2   r   	__class__s        r   r<   DequantizeLinear_19._runs   s1    w}}!DEEw|A;;r>   r?   )Nr	   )r   rA   rC   rD   rE   rF   r<   rG   __classcell__rM   s   @r   rI   rI   r   s    < <r>   rI   c                  6   ^  \ rS rSrSSS.SU 4S jjjrSrU =r$ )DequantizeLinear_21y   r	   r   r   r   c               $   > [         TU ]  " X1US.6$ )NrU   rL   r<   )r/   r   r   argsrM   s       r   r<   DequantizeLinear_21._runz   s    w|TDDr>   r?   r   rA   r   rA   rO   rQ   s   @r   rS   rS   y   s    &'1 E E Er>   rS   c                  8   ^  \ rS rSrSSSS.SU 4S jjjrSrU =r$ )	DequantizeLinear_23   r	   r   Nr   r   r3   c               $   > [         TU ]  " XAX#S.6$ Nr^   rW   r/   r   r   r3   rX   rM   s        r   r<   DequantizeLinear_23._run       w|
 	
r>   r?   rZ   rO   rQ   s   @r   r\   r\          &'14 
 
 
r>   r\   c                  8   ^  \ rS rSrSSSS.SU 4S jjjrSrU =r$ )	DequantizeLinear_25   r	   r   Nr^   c               $   > [         TU ]  " XAX#S.6$ r`   rW   ra   s        r   r<   DequantizeLinear_25._run   rc   r>   r?   rZ   rO   rQ   s   @r   rf   rf      rd   r>   rf   )N)
r   r@   r   ztuple[int, ...]r   rA   r   rB   returnr@   )
__future__r   numpyr   onnxr   onnx.helperr   r   onnx.reference.op_runr   r   r!   rI   rS   r\   rf   r?   r>   r   <module>rp      s    #   J ' "	/// / 	/
 /d0
e 0
f<1 <E1 E
1 

1 
r>   