Created by: zhiqiu
PR types
Others
PR changes
APIs
Describe
As Paddle-2.0 set dynamic graph as default in #27443, we need to add some checks for the static only
APIs.
Typically, paddle.static.data() / paddle.fluid.data() / paddle.fluid.layers.data()
needs to be checked since it is the entrance of static graph model.
>>> import paddle
>>> a = paddle.fluid.data('a', [2,3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<decorator-gen-25>", line 2, in data
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
return wrapped_func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/framework.py", line 229, in __impl__
), "We only support %s in static graph mode, please call 'paddle.enable_static()' to enter static graph mode." % func.__name__
AssertionError: We only support 'data()' in static graph mode, please call 'paddle.enable_static()' to enter static graph mode.