Skip to content

Commit be44a8f

Browse files
[NPU] Fix unittests in PIR mode (#1667)
1 parent f1ecd43 commit be44a8f

8 files changed

Lines changed: 11 additions & 13 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ version.info
3535

3636
# ignore Paddle change
3737
Paddle/
38+
39+
# ignore clangd cache
40+
.cache/

Paddle

Submodule Paddle updated 1207 files

backends/npu/tests/unittests/test_activation_op.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ def test_api(self):
499499

500500
out1 = paddle.log2(data_x)
501501
exe = paddle.static.Executor(place=self.place)
502-
exe.run(paddle.static.default_startup_program())
503502
(res1,) = exe.run(
504503
paddle.static.default_main_program(),
505504
feed={"data_x": input_x},

backends/npu/tests/unittests/test_compare_op_npu.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def set_device(self):
6161
paddle.set_device(self.device)
6262
paddle.enable_static()
6363
exe = paddle.static.Executor(self.place)
64-
exe.run(paddle.static.default_startup_program())
6564
paddle.disable_static()
6665

6766
def test_output(self):
@@ -104,7 +103,6 @@ def build_op(case):
104103
op(x=inputs[case["x"]], y=inputs[case["y"]], **case["args"])
105104
exe = paddle.static.Executor(self.place)
106105

107-
exe.run(paddle.static.default_startup_program())
108106
exe.run(paddle.static.default_main_program())
109107

110108
for case in cases:

backends/npu/tests/unittests/test_elementwise_add_op_npu.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323

2424
paddle.enable_static()
2525

26-
# Initialize NPU device
27-
exe = paddle.static.Executor(paddle.CustomPlace("npu", 0))
28-
exe.run(paddle.static.default_startup_program())
29-
3026

3127
class TestElementwiseAddOp(OpTest):
3228
def setUp(self):

backends/npu/tests/unittests/test_elementwise_sub_op_npu.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,13 @@ def test_errors(self):
192192
)
193193
self.assertRaises(TypeError, paddle.subtract, x1, y1)
194194

195+
# TypeError won't be raised on X86_64 when uint8-supported onednn kernel
196+
# is available, but will be raised on ARM due to lack of uint8 kernel support.
197+
195198
# the input dtype must be float16 or float32 or float64 or int32 or int64
196-
x2 = paddle.static.data(name="x2", shape=[3, 4, 5, 6], dtype="uint8")
197-
y2 = paddle.static.data(name="y2", shape=[3, 4, 5, 6], dtype="uint8")
198-
self.assertRaises(TypeError, paddle.subtract, x2, y2)
199+
# x2 = paddle.static.data(name="x2", shape=[3, 4, 5, 6], dtype="uint8")
200+
# y2 = paddle.static.data(name="y2", shape=[3, 4, 5, 6], dtype="uint8")
201+
# self.assertRaises(TypeError, paddle.subtract, x2, y2)
199202

200203

201204
class TestSubtractNet(unittest.TestCase):

backends/npu/tests/unittests/test_randperm_op_npu.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def test_invalid_n():
115115
with program_guard(Program(), Program()):
116116
paddle.randperm(-3)
117117
exe = paddle.static.Executor()
118-
exe.run(paddle.static.default_startup_program())
119118
exe.run(paddle.static.default_main_program())
120119

121120
self.assertRaises(RuntimeError, test_invalid_n)
@@ -124,7 +123,6 @@ def test_invalid_dtype():
124123
with program_guard(Program(), Program()):
125124
paddle.randperm(10, "int8")
126125
exe = paddle.static.Executor()
127-
exe.run(paddle.static.default_startup_program())
128126
exe.run(paddle.static.default_main_program())
129127

130128
self.assertRaises(TypeError, test_invalid_dtype)

backends/npu/tests/unittests/test_unbind_op_npu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def test_unbind_static_fp16_npu(self):
5151
y = paddle.unbind(x)
5252

5353
exe = paddle.static.Executor(place)
54+
5455
res = exe.run(
5556
paddle.static.default_main_program(),
5657
feed={

0 commit comments

Comments
 (0)