From 03b09bd6e852949bc87aee3866e9ac113ea1eec3 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Mon, 13 Dec 2021 19:14:00 +0800 Subject: [PATCH] fix can not find eager attr, test=develop (#38071) --- python/paddle/fluid/eager/eager_tensor_patch_methods.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/eager/eager_tensor_patch_methods.py b/python/paddle/fluid/eager/eager_tensor_patch_methods.py index b61bf78116a..547a948da40 100644 --- a/python/paddle/fluid/eager/eager_tensor_patch_methods.py +++ b/python/paddle/fluid/eager/eager_tensor_patch_methods.py @@ -20,4 +20,5 @@ def monkey_patch_eagertensor(): from paddle.tensor.to_string import eager_tensor_to_string return eager_tensor_to_string(self) - setattr(core.eager.EagerTensor, "__str__", __str__) + if hasattr(core, "eager"): + setattr(core.eager.EagerTensor, "__str__", __str__) -- GitLab