From cbbe1274839be0223d7be61406f58ca667598186 Mon Sep 17 00:00:00 2001 From: Huihuang Zheng Date: Thu, 18 Feb 2021 17:05:08 +0800 Subject: [PATCH] Refine fake_interface Error Message (#30981) Refine fake_interface Error Message --- python/paddle/fluid/framework.py | 5 +++-- python/paddle/fluid/tests/unittests/test_detach.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 43e27331622..8ed5add5548 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -248,8 +248,9 @@ def _fake_interface_only_(func): raise AssertionError( "'%s' should be called by imperative Varible in imperative mode, please run it in dygraph " "mode. You can turn off paddle.enable_static() if you are in static mode, or turn off " - "ProgramTranslator if you are using @paddle.jit.to_static" % - func.__name__) + "ProgramTranslator if you are using @paddle.jit.to_static. If you have to run ProgramTranslator, " + "please use other API to replace '%s'" % (func.__name__, + func.__name__)) return __impl__ diff --git a/python/paddle/fluid/tests/unittests/test_detach.py b/python/paddle/fluid/tests/unittests/test_detach.py index 9a535f9e00a..38cdd9b727f 100644 --- a/python/paddle/fluid/tests/unittests/test_detach.py +++ b/python/paddle/fluid/tests/unittests/test_detach.py @@ -162,7 +162,8 @@ class Test_Detach(unittest.TestCase): "in imperative mode, please run it in dygraph mode. You can " "turn off paddle.enable_static() if you are in static mode, " "or turn off ProgramTranslator if you are using " - "@paddle.jit.to_static") + "@paddle.jit.to_static. If you have to run ProgramTranslator, " + "please use other API to replace 'detach'") class TestInplace(unittest.TestCase): -- GitLab