diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index ae8f64987898d..a7169befc10cf 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -1419,7 +1419,8 @@ def check_grad_with_place(self, # FIXME: Replace numeric_place with place to calculate numeric_grads. # NOTE(liym27): There is an unknown error when call op.run() on NPUPlace, which # needs to be fixed. - if self.__class__.use_npu == True: + if hasattr(self.__class__, + "use_npu") and self.__class__.use_npu == True: numeric_place = paddle.CPUPlace() else: numeric_place = place