File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -594,7 +594,7 @@ void BindProgram(py::module *m) {
594
594
})
595
595
.def (" num_ops" , [](Program &self) { return self.num_ops (); })
596
596
.def (
597
- " state_dict " ,
597
+ " _state_dict " ,
598
598
[](std::shared_ptr<Program> self,
599
599
const std::string &mode = " all" ,
600
600
const framework::Scope &scope = framework::Scope ()) {
Original file line number Diff line number Diff line change @@ -27,8 +27,22 @@ def _lr_schedule_guard(self, is_with_opt=False):
27
27
# be fixed in the future.
28
28
yield
29
29
30
+ def state_dict (self , mode = "all" , scope = None ):
31
+ from paddle .base import core
32
+ from paddle .base .executor import global_scope
33
+
34
+ if scope is not None and not isinstance (scope , core ._Scope ):
35
+ raise TypeError (
36
+ f"`scope` should be None or `paddle.static.Scope'` type, but received { type (scope )} ."
37
+ )
38
+
39
+ if scope is None :
40
+ scope = global_scope ()
41
+ return self ._state_dict (mode , scope )
42
+
30
43
program_attrs = {
31
44
"_lr_schedule_guard" : _lr_schedule_guard ,
45
+ "state_dict" : state_dict ,
32
46
}
33
47
34
48
global _already_patch_program
You can’t perform that action at this time.
0 commit comments