Skip to content

Commit

Permalink
add check_grad in gelu unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
pangyoki committed Jul 2, 2021
1 parent 2b30114 commit 13741a1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions python/paddle/fluid/tests/unittests/npu/test_gelu_op_npu.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ def init_dtype(self):
def test_check_output(self):
self.check_output_with_place(self.place, check_dygraph=False, atol=1e-3)

# TODO(ascendrc): Add grad test
# def test_check_grad(self):
# if self.dtype == np.float16:
# return
# self.check_grad(['X'], 'Out')
#
def test_check_grad(self):
self.check_grad_with_place(
self.place, ['X'], 'Out', check_dygraph=False)


@unittest.skipIf(not paddle.is_compiled_with_npu(),
Expand Down Expand Up @@ -115,10 +112,10 @@ def _test(self, run_npu=True):
name="label", shape=[32, 1], dtype='int64')

c = paddle.multiply(a, b)
d = fluid.layers.gelu(c)

fc_1 = fluid.layers.fc(input=d, size=128)
prediction = fluid.layers.fc(input=fc_1, size=2, act='softmax')
fc_1 = fluid.layers.fc(input=c, size=128)
fc_1_gelu = fluid.layers.gelu(fc_1)
prediction = fluid.layers.fc(input=fc_1_gelu, size=2, act='softmax')

cost = fluid.layers.cross_entropy(input=prediction, label=label)
loss = fluid.layers.reduce_mean(cost)
Expand Down

1 comment on commit 13741a1

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.