31
31
32
32
class InitCallback (Callback ):
33
33
"""Callback class for:
34
- 1. Parse config dict from given yaml file and check its validity, complete missing items by its' default values .
34
+ 1. Parse config dict from given yaml file and check its validity.
35
35
2. Fixing random seed to 'config.seed'.
36
36
3. Initialize logger while creating output directory(if not exist).
37
+ 4. Enable prim mode if specified.
37
38
38
39
NOTE: This callback is mainly for reducing unnecessary duplicate code in each
39
40
examples code when runing with hydra.
@@ -60,8 +61,6 @@ class InitCallback(Callback):
60
61
"""
61
62
62
63
def on_job_start (self , config : DictConfig , ** kwargs : Any ) -> None :
63
- # check given cfg using pre-defined pydantic schema in 'SolverConfig', error(s) will be raised
64
- # if any checking failed at this step
65
64
if importlib .util .find_spec ("pydantic" ) is not None :
66
65
from pydantic import ValidationError
67
66
else :
@@ -76,8 +75,6 @@ def on_job_start(self, config: DictConfig, **kwargs: Any) -> None:
76
75
# error(s) will be printed and exit program if any checking failed at this step
77
76
try :
78
77
_model_pydantic = config_module .SolverConfig (** dict (config ))
79
- # complete missing items with default values pre-defined in pydantic schema in
80
- # 'SolverConfig'
81
78
full_cfg = DictConfig (_model_pydantic .model_dump ())
82
79
except ValidationError as e :
83
80
print (e )
@@ -100,7 +97,7 @@ def on_job_start(self, config: DictConfig, **kwargs: Any) -> None:
100
97
101
98
# enable prim if specified
102
99
if "prim" in full_cfg and bool (full_cfg .prim ):
103
- # Mostly for dy2st running, will be removed in the future
100
+ # Mostly for compiler running with dy2st.
104
101
from paddle .framework import core
105
102
106
103
core .set_prim_eager_enabled (True )
0 commit comments