diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index ae8f64987898d35c7f1960c4f10b5628edfd6f51..a7169befc10cf188039de3f6e35e2bd04bf338a4 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -1419,7 +1419,8 @@ class OpTest(unittest.TestCase): # 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