19
19
20
20
import paddle
21
21
import paddle .base as base
22
- from paddle .base import Program , program_guard
22
+
23
+ from paddle .pir_utils import OldIrGuard
23
24
24
25
paddle .enable_static ()
25
26
SEED = 2021
@@ -29,8 +30,11 @@ class TestMemcpy_FillConstant(unittest.TestCase):
29
30
def get_prog (self ):
30
31
self .__class__ .use_custom_device = True
31
32
paddle .enable_static ()
32
- main_program = Program ()
33
- with program_guard (main_program ):
33
+
34
+ with OldIrGuard ():
35
+ main_program = base .Program ()
36
+ old_program_guard = base .program_guard
37
+ with old_program_guard (main_program ):
34
38
cpu_var_name = "tensor@Cpu"
35
39
npu_var_name = "tensor@Npu"
36
40
cpu_var = main_program .global_block ().create_var (
@@ -79,9 +83,8 @@ def test_npu_cpoy_to_cpu(self):
79
83
)
80
84
place = paddle .CustomPlace ("npu" , 0 )
81
85
exe = base .Executor (place )
82
- npu_ , cpu_ = exe .run (
83
- main_program , feed = {}, fetch_list = [npu_var .name , cpu_var .name ]
84
- )
86
+ with OldIrGuard ():
87
+ npu_ , cpu_ = exe .run (main_program , feed = {}, fetch_list = [npu_var , cpu_var ])
85
88
np .testing .assert_allclose (npu_ , cpu_ )
86
89
np .testing .assert_allclose (cpu_ , np .ones ((10 , 10 )))
87
90
@@ -96,9 +99,8 @@ def test_cpu_cpoy_npu(self):
96
99
)
97
100
place = paddle .CustomPlace ("npu" , 0 )
98
101
exe = base .Executor (place )
99
- npu_ , cpu_ = exe .run (
100
- main_program , feed = {}, fetch_list = [npu_var .name , cpu_var .name ]
101
- )
102
+ with OldIrGuard ():
103
+ npu_ , cpu_ = exe .run (main_program , feed = {}, fetch_list = [npu_var , cpu_var ])
102
104
np .testing .assert_allclose (npu_ , cpu_ )
103
105
np .testing .assert_allclose (npu_ , np .zeros ((10 , 10 )))
104
106
0 commit comments