Skip to content

Commit 42e50dc

Browse files
authored
[NPU]remove fluid apis accoring to Paddle (PaddlePaddle#231)
1 parent 81d5ba2 commit 42e50dc

File tree

3 files changed

+9
-30
lines changed

3 files changed

+9
-30
lines changed

backends/npu/tests/unittests/test_conv2d_transpose_op_npu.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,47 +513,47 @@ def test_case1(self):
513513
name='data1', shape=[3, 5, 5], dtype='float32')
514514
data2 = fluid.layers.data(
515515
name='data2', shape=[5, 5, 3], dtype='float32')
516-
out1 = fluid.layers.conv2d_transpose(
516+
out1 = paddle.static.nn.conv2d_transpose(
517517
input=data1,
518518
groups=1,
519519
num_filters=6,
520520
filter_size=3,
521521
data_format='NCHW')
522-
out2 = fluid.layers.conv2d_transpose(
522+
out2 = paddle.static.nn.conv2d_transpose(
523523
input=data2,
524524
groups=1,
525525
num_filters=6,
526526
filter_size=3,
527527
data_format='NHWC')
528-
out3 = fluid.layers.conv2d_transpose(
528+
out3 = paddle.static.nn.conv2d_transpose(
529529
input=data1,
530530
groups=1,
531531
num_filters=6,
532532
filter_size=3,
533533
padding=[[0, 0], [1, 1], [1, 1], [0, 0]],
534534
data_format='NHWC')
535-
out4 = fluid.layers.conv2d_transpose(
535+
out4 = paddle.static.nn.conv2d_transpose(
536536
input=data1,
537537
groups=3,
538538
num_filters=6,
539539
filter_size=3,
540540
padding=[[0, 0], [0, 0], [2, 1], [0, 0]],
541541
data_format='NCHW')
542-
out5 = fluid.layers.conv2d_transpose(
542+
out5 = paddle.static.nn.conv2d_transpose(
543543
input=data2,
544544
groups=1,
545545
num_filters=6,
546546
filter_size=3,
547547
padding='SAME',
548548
data_format='NCHW')
549-
out6 = fluid.layers.conv2d_transpose(
549+
out6 = paddle.static.nn.conv2d_transpose(
550550
input=data1,
551551
groups=1,
552552
num_filters=6,
553553
filter_size=3,
554554
padding='VALID',
555555
data_format='NHWC')
556-
out7 = fluid.layers.conv2d_transpose(
556+
out7 = paddle.static.nn.conv2d_transpose(
557557
input=data1,
558558
groups=1,
559559
num_filters=6,

backends/npu/tests/unittests/test_hard_sigmoid_op_npu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ def test_dygraph_api(self):
125125
def test_fluid_api(self):
126126
with fluid.program_guard(fluid.Program()):
127127
x = fluid.data('X', self.x_np.shape, self.x_np.dtype)
128-
out = fluid.layers.hard_sigmoid(x)
128+
out = paddle.nn.functional.hardsigmoid(x, slope=0.2)
129129
exe = fluid.Executor(self.place)
130130
res = exe.run(feed={'X': self.x_np}, fetch_list=[out])
131131
out_ref = ref_hardsigmoid(self.x_np, 0.2, 0.5)
132132
self.assertTrue(np.allclose(out_ref, res[0]))
133133

134134
paddle.disable_static(self.place)
135135
x = paddle.to_tensor(self.x_np)
136-
out = paddle.fluid.layers.hard_sigmoid(x)
136+
out = paddle.nn.functional.hardsigmoid(x, slope=0.2)
137137
self.assertTrue(np.allclose(out_ref, out.numpy()))
138138
paddle.enable_static()
139139

backends/npu/tests/unittests/test_huber_loss_op_npu.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,5 @@ def init_dtype(self):
116116
self.dtype = np.float16
117117

118118

119-
class TestHuberLossOpError(unittest.TestCase):
120-
def test_errors(self):
121-
with program_guard(Program(), Program()):
122-
# the input and label must be Variable
123-
xw = np.random.random((6, 6)).astype("float32")
124-
xr = fluid.data(name='xr', shape=[None, 6], dtype="float32")
125-
lw = np.random.random((6, 6)).astype("float32")
126-
lr = fluid.data(name='lr', shape=[None, 6], dtype="float32")
127-
delta = 1.0
128-
self.assertRaises(TypeError, fluid.layers.huber_loss, xr, lw, delta)
129-
self.assertRaises(TypeError, fluid.layers.huber_loss, xw, lr, delta)
130-
131-
# the dtype of input and label must be float32 or float64
132-
xw2 = fluid.data(name='xw2', shape=[None, 6], dtype="int32")
133-
lw2 = fluid.data(name='lw2', shape=[None, 6], dtype="int32")
134-
self.assertRaises(TypeError, fluid.layers.huber_loss, xw2, lr,
135-
delta)
136-
self.assertRaises(TypeError, fluid.layers.huber_loss, xr, lw2,
137-
delta)
138-
139-
140119
if __name__ == '__main__':
141120
unittest.main()

0 commit comments

Comments
 (0)