Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/dygraph_to_static/test_to_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ class TestStatic(Dy2StTestBase):
def test_static(self):
paddle.enable_static()
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
if core.is_compiled_with_cuda():
place = paddle.CUDAPlace(0)
else:
Expand All @@ -208,7 +208,7 @@ def test_static(self):
sgd.minimize(paddle.mean(out))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[x, out])


Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_activation_nn_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,16 @@ def _check_cos_double_static(self, place):
x_data = np.random.randn(64, 64).astype("float32")
with static_guard():
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
x = paddle.assign(x_data)
x.stop_gradient = False
y = paddle.cos(x)
dx = paddle.static.gradients(y, x)
dxx = paddle.static.gradients(dx, x)[0]

exe = paddle.static.Executor(place)
exe.run(starup_prog)
exe.run(startup_prog)
(dxx_result,) = exe.run(main_prog, fetch_list=[dxx])
dxx_expected = -np.cos(x_data)
np.testing.assert_allclose(dxx_result, dxx_expected, 1e-6, 1e-6)
Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_adaptive_avg_pool2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ def init_info(self):
def test_static(self):
paddle.enable_static()
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(6, 6)
x = paddle.randn(self.shapes[0])
x.stop_gradient = False
Expand All @@ -367,7 +367,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[out1, out2])
np.testing.assert_allclose(res[0], res[1])
paddle.static.save_inference_model(
Expand Down
12 changes: 6 additions & 6 deletions test/legacy_test/test_arg_min_max_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def init_info(self):

def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -310,7 +310,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out])
paddle.static.save_inference_model(
self.save_path, [x], [feat, out], exe
Expand Down Expand Up @@ -338,8 +338,8 @@ def call_func(self, x):
class TestArgMinTensorAxis(TestArgMaxTensorAxis):
def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -352,7 +352,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out])
paddle.static.save_inference_model(
self.save_path, [x], [feat, out], exe
Expand Down
18 changes: 9 additions & 9 deletions test/legacy_test/test_attribute_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def init_info(self):

def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(10, 10)
x = paddle.randn(self.shapes[0])
x.stop_gradient = False
Expand All @@ -88,7 +88,7 @@ def test_static(self):
self.assertTrue("Var[" in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[x, out])
# export model
paddle.static.save_inference_model(self.save_path, [x], [out], exe)
Expand All @@ -110,8 +110,8 @@ def init_info(self):

def _test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -126,7 +126,7 @@ def _test_static(self):
self.assertTrue("Vars[" in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[x, out])
self.assertEqual(res[1].shape, (6, 6, 10))

Expand All @@ -143,8 +143,8 @@ def init_info(self):

def _test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -158,7 +158,7 @@ def _test_static(self):
self.assertTrue("Var[" in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[x, out])
self.assertEqual(res[1].shape, (6, 6, 10))

Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_bincount_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def test_static_and_infer(self):
paddle.enable_static()
np_x = np.random.randn(100).astype('float32')
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
# run static
x = paddle.static.data(shape=np_x.shape, name='x', dtype=np_x.dtype)
linear = paddle.nn.Linear(np_x.shape[0], np_x.shape[0])
Expand All @@ -272,7 +272,7 @@ def test_static_and_infer(self):
)

exe = paddle.static.Executor(self.place)
exe.run(starup_prog)
exe.run(startup_prog)
static_out = exe.run(feed={'x': np_x}, fetch_list=[out])

# run infer
Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_conv2d_transpose_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,8 @@ def call_func(self, x):

def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(8, 8)
x = paddle.randn([2, 3, 8, 8])
x.stop_gradient = False
Expand All @@ -1369,7 +1369,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out])
np.testing.assert_allclose(res[1].shape, (2, 6, 17, 17))

Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_cumsum_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,8 @@ def test_static_and_infer(self):
paddle.enable_static()
np_x = np.random.randn(9, 10, 11).astype('float32')
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
# run static
x = paddle.static.data(shape=np_x.shape, name='x', dtype=np_x.dtype)
linear = paddle.nn.Linear(np_x.shape[-1], np_x.shape[-1])
Expand All @@ -548,7 +548,7 @@ def test_static_and_infer(self):
sgd.minimize(paddle.mean(out))

exe = paddle.static.Executor(self.place)
exe.run(starup_prog)
exe.run(startup_prog)
static_out = exe.run(feed={'x': np_x}, fetch_list=[out])

# run infer
Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_eye_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def init_info(self):

def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -165,7 +165,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[tmp, out])
gt = np.eye(3, 10)
np.testing.assert_allclose(res[0], gt)
Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_multinomial_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ def call_func(self, x):
def test_static(self):
paddle.enable_static()
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([3, 4])
x.stop_gradient = False
Expand All @@ -469,7 +469,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out])
paddle.static.save_inference_model(
self.save_path, [x], [feat, out], exe
Expand Down
18 changes: 9 additions & 9 deletions test/legacy_test/test_pad_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def init_info(self):
def test_static(self):
with static_guard():
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 4])
x.stop_gradient = False
Expand All @@ -168,7 +168,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out])
gt = np.pad(
res[0], [1, 1], 'constant', constant_values=[1.0, 1.0]
Expand All @@ -191,8 +191,8 @@ def test_static(self):
def test_pir_static(self):
with paddle.pir_utils.IrGuard():
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 4])
x.stop_gradient = False
Expand All @@ -204,7 +204,7 @@ def test_pir_static(self):
sgd.minimize(paddle.mean(out))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out])
gt = np.pad(
res[0], [1, 1], 'constant', constant_values=[1.0, 1.0]
Expand Down Expand Up @@ -240,8 +240,8 @@ def test_static(self):
with static_guard():
np_x = np.random.random((16, 16)).astype('float32')
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
x = paddle.assign(np_x).astype('float32')
pad_value = paddle.assign([0.0]).astype('float64')
y = paddle.nn.functional.pad(x, [0, 1, 2, 3], value=pad_value)
Expand All @@ -251,7 +251,7 @@ def test_static(self):
).minimize(loss)

exe = paddle.static.Executor(paddle.CPUPlace())
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(
main_prog, fetch_list=[y] + [g for p, g in params_grads]
)
Expand Down
12 changes: 6 additions & 6 deletions test/legacy_test/test_squeeze2_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def init_info(self):

def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -214,7 +214,7 @@ def test_static(self):
self.assertTrue("Var[" in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out, out2])
self.assertEqual(res[0].shape, (1, 2, 1, 3, 10))
self.assertEqual(res[1].shape, (2, 3, 10))
Expand All @@ -233,8 +233,8 @@ def init_info(self):

def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -253,7 +253,7 @@ def test_static(self):
self.assertTrue("Vars[" in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[feat, out, out2])
self.assertEqual(res[0].shape, (1, 2, 1, 3, 10))
self.assertEqual(res[1].shape, (2, 3, 10))
Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_sum_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ def test_dygraph(self):
def test_static_and_infer(self):
paddle.enable_static()
main_prog = paddle.static.Program()
starup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, starup_prog):
startup_prog = paddle.static.Program()
with paddle.static.program_guard(main_prog, startup_prog):
# run static
x = paddle.static.data(
shape=self.x.shape, name='x', dtype='float32'
Expand All @@ -606,7 +606,7 @@ def test_static_and_infer(self):
sgd = paddle.optimizer.SGD(learning_rate=0.0)
sgd.minimize(paddle.mean(out))
exe = paddle.static.Executor(self.place)
exe.run(starup_prog)
exe.run(startup_prog)
static_out = exe.run(
feed={'x': self.x.numpy().astype('float32')}, fetch_list=[out]
)
Expand Down
6 changes: 3 additions & 3 deletions test/legacy_test/test_uniform_random_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,8 @@ def init_info(self):

def test_static(self):
main_prog = Program()
starup_prog = Program()
with program_guard(main_prog, starup_prog):
startup_prog = Program()
with program_guard(main_prog, startup_prog):
fc = paddle.nn.Linear(4, 10)
x = paddle.randn([2, 3, 4])
x.stop_gradient = False
Expand All @@ -758,7 +758,7 @@ def test_static(self):
self.assertTrue(self.var_prefix() in str(main_prog))

exe = paddle.static.Executor()
exe.run(starup_prog)
exe.run(startup_prog)
res = exe.run(fetch_list=[out])
np.testing.assert_array_equal(res[0].shape, [2, 3, 10])

Expand Down
Loading