1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14+ from __future__ import annotations
1415
16+ import paddle
1517from paddle import _C_ops
1618
1719from ...base import core , framework
@@ -35,13 +37,17 @@ class ConstantInitializer(Initializer):
3537
3638 """
3739
38- def __init__ (self , value = 0.0 , force_cpu = False ):
40+ def __init__ (self , value : float = 0.0 , force_cpu : bool = False ) -> None :
3941 assert value is not None
4042 super ().__init__ ()
4143 self ._value = value
4244 self ._force_cpu = force_cpu
4345
44- def forward (self , var , block = None ):
46+ def forward (
47+ self ,
48+ var : paddle .Tensor ,
49+ block : paddle .pir .Block | None = None ,
50+ ):
4551 """Initialize the input tensor with constant.
4652
4753 Args:
@@ -52,7 +58,6 @@ def forward(self, var, block=None):
5258 Returns:
5359 The initialization op
5460 """
55- import paddle
5661
5762 block = self ._check_block (block )
5863
@@ -135,7 +140,7 @@ class Constant(ConstantInitializer):
135140
136141 """
137142
138- def __init__ (self , value = 0.0 ):
143+ def __init__ (self , value : float = 0.0 ) -> None :
139144 if value is None :
140145 raise ValueError ("value must not be none." )
141146 super ().__init__ (value = value , force_cpu = False )
0 commit comments