From b59b6d7ae6903d5b894d57c13d7ebff0e7369b5a Mon Sep 17 00:00:00 2001 From: chentianyu03 Date: Fri, 18 Dec 2020 14:24:36 +0800 Subject: [PATCH] Complex op test (#29753) * delete no need to calculate inputs in dygraph op_test * delete no need to calculate inputs in dygraph op_test --- python/paddle/fluid/tests/unittests/op_test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index bd38bae42e..f077a0286d 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -1544,6 +1544,10 @@ class OpTest(unittest.TestCase): grad_outputs = [] for grad_out_value in user_defined_grad_outputs: grad_outputs.append(paddle.to_tensor(grad_out_value)) + # delete the inputs which no need to calculate grad + for no_grad_val in no_grad_set: + del (inputs[no_grad_val]) + grad_inputs = paddle.grad( outputs=fluid.layers.utils.flatten(outputs), inputs=fluid.layers.utils.flatten(inputs), -- GitLab