未验证 提交 f0a40630 编写于 作者: J Jiaqi Liu 提交者: GitHub

supports string var lod_level property (#39077)

上级 3bf3a6ee
......@@ -1763,7 +1763,10 @@ class Variable(object):
Examples:
.. code-block:: python
import paddle
import paddle.fluid as fluid
paddle.enable_static()
cur_program = fluid.Program()
cur_block = cur_program.current_block()
new_variable = cur_block.create_var(name="X",
......@@ -1773,7 +1776,8 @@ class Variable(object):
"""
if self.type == core.VarDesc.VarType.SELECTED_ROWS:
raise Exception("SelectedRows DO NOT supprt lod")
if self.type == core.VarDesc.VarType.STRINGS:
return None
return self.desc.lod_level()
@property
......
......@@ -63,6 +63,12 @@ class TestVariable(unittest.TestCase):
self.assertRaises(ValueError,
lambda: b.create_var(name="fc.w", shape=(24, 100)))
w = b.create_var(
dtype=paddle.fluid.core.VarDesc.VarType.STRINGS,
shape=[1],
name="str_var")
self.assertEqual(None, w.lod_level)
def test_element_size(self):
with fluid.program_guard(Program(), Program()):
x = paddle.static.data(name='x1', shape=[2], dtype='bool')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册