11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
+ from __future__ import annotations
14
15
16
+ import paddle
15
17
from paddle import _C_ops
16
18
17
19
from ...base import core , framework
@@ -35,13 +37,17 @@ class ConstantInitializer(Initializer):
35
37
36
38
"""
37
39
38
- def __init__ (self , value = 0.0 , force_cpu = False ):
40
+ def __init__ (self , value : float = 0.0 , force_cpu : bool = False ) -> None :
39
41
assert value is not None
40
42
super ().__init__ ()
41
43
self ._value = value
42
44
self ._force_cpu = force_cpu
43
45
44
- def forward (self , var , block = None ):
46
+ def forward (
47
+ self ,
48
+ var : paddle .Tensor ,
49
+ block : paddle .pir .Block | None = None ,
50
+ ):
45
51
"""Initialize the input tensor with constant.
46
52
47
53
Args:
@@ -52,7 +58,6 @@ def forward(self, var, block=None):
52
58
Returns:
53
59
The initialization op
54
60
"""
55
- import paddle
56
61
57
62
block = self ._check_block (block )
58
63
@@ -135,7 +140,7 @@ class Constant(ConstantInitializer):
135
140
136
141
"""
137
142
138
- def __init__ (self , value = 0.0 ):
143
+ def __init__ (self , value : float = 0.0 ) -> None :
139
144
if value is None :
140
145
raise ValueError ("value must not be none." )
141
146
super ().__init__ (value = value , force_cpu = False )
0 commit comments