
    ёi                        S SK rS SKrS SKJr  0 S\R
                  R                  _S\R
                  R                  _S\R
                  R                  _S\R
                  R                  _S\R
                  R                  _S\R
                  R                  _S	\R
                  R                  _S
\R
                  R                  _S\R
                  R                  _S\R
                  R                  _S\R
                  R                   _S\R
                  R"                  _S\R
                  R$                  _S\R
                  R&                  _S\R
                  R(                  _S\R
                  R*                  _S\R
                  R,                  _\R
                  R.                  \R
                  R0                  S.Er\R
                  R                  \R
                  R                  \R
                  R                  /r\R
                  R6                  R8                  \R
                  R6                  R:                  \R
                  R6                  R<                  \R
                  R6                  R>                  \R
                  R6                  R@                  /r!\RD                  \RF                  \RH                  \RJ                  /r&\RN                  \RP                  \RR                  \RT                  \RV                  /r,\R
                  R                  \R
                  R                  /r-/ SQr./ SQr/S r0S r1S r2S r3S r4S r5S r6g)    N)quant_layersConv2DTransposeConv2DLinearAdaptiveAvgPool2DAdaptiveMaxPool2D	AvgPool2D	MaxPool2D	Hardswish	LeakyReLUPReLUReLUReLU6SigmoidSoftmaxSwishTanh	BatchNorm)	GroupNorm	LayerNorm)conv2ddepthwise_conv2dmatmulconv2d_transposedepthwise_conv2d_transpose) fake_quantize_dequantize_abs_max-fake_channel_wise_quantize_dequantize_abs_max/fake_quantize_dequantize_moving_average_abs_maxc                     U R                  U5      nUc   SU-   S-   5       e[        R                  " UR                  5       5      $ )z 
Load variable value from scope
zCan not find z in the scope.)find_varnparray
get_tensor)scopevar_namevar_nodes      d/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/quantization/imperative/utils.pyload_variable_datar(   ]   sF     ~~h'HN8!;>N!NN88H'')**    c                 P    U R                    H  nXR                  ;   d  M  Us  $    g)z.
Find the previous op for the input variable.
N)opsoutput_arg_names)blockr%   ops      r'   find_previous_opr/   f   s(     ii***I  r)   c                 t    / nU R                    H%  nXR                  ;   d  M  UR                  U5        M'     U$ )z/
Find all followed ops for the input variable.
)r+   input_arg_namesappend)r-   r%   res_opsr.   s       r'   find_next_opsr4   p   s6     Gii)))NN2  Nr)   c                 J   [        U [        R                  R                  5      (       d   S5       e[	        U5      S:  d   S5       eSnSnU nU[	        U5      :  aB  X   S:X  a$  XU n[        XE5      (       a  [        XE5      nUS-   nUS-  nU[	        U5      :  a  MB  XU nXE4$ )a^  
Given the model and the name of a layer, find the parent layer and
the sub_name of the layer.
For example, if name is 'block_1/convbn_1/conv_1', the parent layer is
'block_1/convbn_1' and the sub_name is `conv_1`.
Args:
    model(paddle.nn.Layer): the model to be quantized.
    name(string): the name of a layer

Returns:
    parent_layer, subname
z2The model must be the instance of paddle.nn.Layer.r   z%The input (name) should not be empty..   )
isinstancepaddlennLayerlenhasattrgetattr)modelnamelast_idxidxparent_layersub_names         r'   find_parent_layer_and_sub_namerE   {   s     eVYY__-- <- t9q=AAA=H
CL
D	/9S)H|..&|>7q D	/ S!H!!r)   c                 x    / nU R                    H'  nUR                   H  nUR                  U5        M     M)     U$ )z'
Return all ops for the input program.
)blocksr+   r2   )programall_opsr-   r.   s       r'   program_all_opsrJ      s8     G))BNN2    Nr)   c                     [        U [        R                  R                  5      =(       a    [	        U R                  5       5      S:H  $ )z"
Whether the layer is leaf layer.
r   )r8   r9   r:   r;   r<   	sublayers)layers    r'   is_leaf_layerrN      s/     eVYY__-M#eoo6G2HA2MMr)   c                 X    U R                   S:X  a  [        U 5      $ U R                  5       $ )z!
Convert numpy to float or list.
r7   )sizefloattolist)x_nps    r'   fp_numpy_to_naiverT      s%     yyA~T{{{}r)   )7numpyr!   r9   paddle.nn.quantr   r:   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   layer_name_mapfake_quant_input_layersquantaddsubtractmultiplydivider   fake_quant_output_layersFakeQuantAbsMaxFakeQuantChannelWiseAbsMaxFakeQuantMovingAverageAbsMaxMovingAverageAbsMaxScalefake_quant_leaf_layersQuantizedConv2DQuantizedLinearQuantizedConv2DTransposeQuantizedColumnParallelLinearQuantizedRowParallelLinearfake_quant_wrap_layersspec_channel_axis_layersweight_op_types!fake_quantize_dequantize_op_typesr(   r/   r4   rE   rJ   rN   rT    r)   r'   <module>rn      s     (vyy00fii fii 44	
 44 $$ $$ $$ $$ VYY__ FIINN VYY__ vyy   vyy   VYY__  FIINN!" $$#$ $$$$'0 II
II
II  IIOO
IIOO
IIOO
IIOO
IIOO    ++--))	      ))..++  #II55vyy7G7GH % !+"@Nr)   