未验证 提交 7c73a68f 编写于 作者: J Jiabin Yang 提交者: GitHub

test=release/1.5, cherry-pick hide not_support for dygraph (#18528)

* test=release/1.5, cherry-pick hide not_support for dygraph

* test=release/1.5, cherry-pick hide not_support for dygraph
上级 856536b9
......@@ -21,7 +21,7 @@ import functools
from . import layers
from . import framework
from . import core
from .dygraph import not_support
from .dygraph.base import _not_support
__all__ = [
'ErrorClipByValue',
......@@ -336,7 +336,7 @@ class GradientClipByGlobalNorm(BaseGradientClipAttr):
return param, new_grad
@not_support
@_not_support
def set_gradient_clip(clip, param_list=None, program=None):
"""
To specify parameters that require gradient clip.
......
......@@ -24,7 +24,6 @@ import logging
__all__ = [
'enabled',
'no_grad',
'not_support',
'guard',
'to_variable',
]
......@@ -91,7 +90,7 @@ def _no_grad_(func):
no_grad = wrap_decorator(_no_grad_)
not_support = wrap_decorator(_dygraph_not_support_)
_not_support = wrap_decorator(_dygraph_not_support_)
@signature_safe_contextmanager
......
......@@ -15,6 +15,7 @@
import paddle.fluid as fluid
import paddle.fluid.framework as framework
import unittest
from test_imperative_base import new_program_scope
class TestTracerMode(unittest.TestCase):
......@@ -29,6 +30,18 @@ class TestTracerMode(unittest.TestCase):
self.assertEqual(self.tracer._train_mode, False)
return a
@fluid.dygraph.base._not_support
def not_support_func(self):
return True
def check_not_support_rlt(self, ans):
try:
rlt = self.not_support_func()
except AssertionError:
rlt = False
finally:
self.assertEqual(rlt, ans)
def test_main(self):
with fluid.dygraph.guard():
self.tracer = framework._dygraph_tracer()
......@@ -38,6 +51,12 @@ class TestTracerMode(unittest.TestCase):
self.assertEqual(self.tracer._train_mode, self.init_mode)
with fluid.dygraph.guard():
self.check_not_support_rlt(False)
with new_program_scope():
self.check_not_support_rlt(True)
class TestTracerMode2(TestTracerMode):
def setUp(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册