
    ёi                        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J	r	J
r
  SSKJr  / r " S	 S
\5      r " S S\5      rg)    )annotationsN)_C_ops   )core	framework)_current_expected_placein_dygraph_modein_dynamic_or_pir_mode   )Initializerc                  N   ^  \ rS rSrSrSSU 4S jjjr S     S	S jjrSrU =r$ )
ConstantInitializer    zImplements the constant initializer

Args:
    value (float32, optional): constant value to initialize the variable. Default: 0.0.

c                D   > Uc   e[         TU ]  5         Xl        X l        g N)super__init___value
_force_cpu)selfvalue	force_cpu	__class__s      ^/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/nn/initializer/constant.pyr   ConstantInitializer.__init__(   s$       #    c                   U R                  U5      n[        U[        R                  [        R                  [
        R                  R                  [
        R                  R                  R                  45      (       d   e[        U[        R                  [
        R                  R                  45      (       d   e[        5       (       Ga  [        5       nU R                  (       a  [        R                  " 5       n[        5       (       Ga  [        U[        R                  5      (       a  UR!                  5       (       a  ["        R$                  " UR&                  [)        U R*                  5      UR,                  U5      n[
        R.                  R0                  R2                  R5                  XAR6                  UR8                  5      nUR;                  U5        g["        R<                  " XR>                  [)        U R*                  5      UR,                  U5        g["        R$                  " UR>                  [)        U R*                  5      UR,                  U5      $ URA                  SSU0UR>                  [C        UR,                  5      [)        U R*                  5      [E        [)        U R*                  5      5      U R                  S.SS9nXQl#        U$ )a  Initialize the input tensor with constant.

Args:
    var(Tensor): Tensor that needs to be initialized.
    block(Block, optional): The block in which initialization ops
           should be added. Used in static graph only, default None.

Returns:
    The initialization op
Nfill_constantOut)shapedtyper   	str_valuer   T)typeoutputsattrsstop_gradient)$_check_block
isinstancer   VariableEagerParamBasepaddlepirValuer   ParameterMetaBlockr
   r   r   CPUPlacer	   is_distr   full_local_shapefloatr   r!   distributedauto_parallelapidtensor_from_localprocess_mesh
placements_share_underline_tensor_tofull_r    	append_opintstrop)r   varblockplaceout_varr@   s         r   forwardConstantInitializer.forward.   s     !!%(""((

  

--	
 
 	
 
 %)//6::3C3C!DEEEE!##+-E  c9#;#;<<$kk((%*<ciiG **88<<OO#%5%5s~~ 
 66s;
  LLYYdkk(:CIIu {{IIuT[[1399e  $ YY ^"4;;/!$U4;;%7!8!% # ! B FIr   )r   r   )        F)r   r4   r   boolreturnNoner   )rA   zpaddle.TensorrB   zpaddle.pir.Block | NonerI   zpaddle.Tensor | None)	__name__
__module____qualname____firstlineno____doc__r   rE   __static_attributes____classcell__r   s   @r   r   r       sB    $ $ *.DD 'D 
	D Dr   r   c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )Constantu   a  Implement the constant initializer.

Args:
    value (float32|float64, optional): constant value to initialize the parameter. Default: 0.0.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> import paddle.nn as nn

        >>> paddle.seed(2023)
        >>> data = paddle.rand([30, 10, 2], dtype='float32')
        >>> linear = nn.Linear(2,
        ...                     4,
        ...                     weight_attr=nn.initializer.Constant(value=2.0))
        >>> res = linear(data)
        >>> print(linear.weight)
        Parameter containing:
        Tensor(shape=[2, 4], dtype=float32, place=Place(cpu), stop_gradient=False,
        [[2., 2., 2., 2.],
         [2., 2., 2., 2.]])

c                >   > Uc  [        S5      e[        TU ]	  USS9  g )Nzvalue must not be none.F)r   r   )
ValueErrorr   r   )r   r   r   s     r   r   Constant.__init__   s&    =677u6r    )rG   )r   r4   rI   rJ   )rK   rL   rM   rN   rO   r   rP   rQ   rR   s   @r   rT   rT   u   s    27 7r   rT   )
__future__r   r+   r   baser   r   base.frameworkr   r	   r
   initializerr   __all__r   rT   rY   r   r   <module>r_      sC    #   #  %
R+ Rj7" 7r   