Skip to content

Commit

Permalink
[Cleanup][C-15]Replace Program.random_seed (#61527)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
  • Loading branch information
co63oc and SigureMo authored Feb 3, 2024
1 parent 31eacdb commit cd1ba95
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions test/ipu/test_optimizer_ipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def _test_optimizer(self, run_ipu=True):
scope = paddle.static.Scope()
main_prog = paddle.static.Program()
startup_prog = paddle.static.Program()
main_prog.random_seed = self.SEED
startup_prog.random_seed = self.SEED
paddle.seed(self.SEED)
np.random.seed(self.SEED)

with paddle.static.scope_guard(scope):
Expand Down
6 changes: 2 additions & 4 deletions test/legacy_test/test_optimizer_in_control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def static(
):
startup_program = Program()
main_program = Program()
startup_program.random_seed = SEED
main_program.random_seed = SEED
paddle.seed(SEED)

with program_guard(main_program, startup_program):

Expand Down Expand Up @@ -175,8 +174,7 @@ def forward(self, inputs):
def dynamic(train_data, use_cuda=False, use_parallel_exe=False):
place = base.CUDAPlace(0) if use_cuda else base.CPUPlace()
with base.dygraph.guard(place):
base.default_startup_program().random_seed = SEED
base.default_main_program().random_seed = SEED
paddle.seed(SEED)
dy_layer = DygraphLayer()
adam = paddle.optimizer.Adam(
learning_rate=LR, parameters=dy_layer.parameters()
Expand Down
3 changes: 1 addition & 2 deletions test/quantization/test_quantization_mkldnn_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def isinteger(self, x):
return np.equal(np.mod(x, 1), 0)

def build_program(self, main, startup, is_test, seed):
main.random_seed = seed
startup.random_seed = seed
paddle.seed(seed)
with paddle.utils.unique_name.guard():
with paddle.static.program_guard(main, startup):
img = paddle.static.data(
Expand Down
3 changes: 1 addition & 2 deletions test/quantization/test_quantization_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ def freeze_graph(
quant_skip_pattern='skip_quant',
):
def build_program(main, startup, is_test):
main.random_seed = seed
startup.random_seed = seed
paddle.seed(seed)
with paddle.utils.unique_name.guard():
with paddle.static.program_guard(main, startup):
img = paddle.static.data(
Expand Down

0 comments on commit cd1ba95

Please sign in to comment.