未验证 提交 afb2cb7c 编写于 作者: myq406450149's avatar myq406450149 提交者: GitHub

lod_tensor_to_array error message enhance. (#23615)

* lod_tensor_to_array error message enhance. test=develop
上级 12ba05ce
......@@ -1169,6 +1169,16 @@ def lod_tensor_to_array(x, table):
table = fluid.layers.lod_rank_table(x, level=0)
array = fluid.layers.lod_tensor_to_array(x, table)
"""
check_type(x, 'x', (Variable, list), 'lod_tensor_to_array')
if isinstance(x, (list)):
for i, input_x in enumerate(x):
check_type(input_x, 'input[' + str(i) + ']', Variable,
'lod_tensor_to_array')
check_type(table, 'table', (Variable, list), 'lod_tensor_to_array')
if isinstance(table, (list)):
for i, table_x in enumerate(table):
check_type(table_x, 'table[' + str(i) + ']', Variable,
'lod_tensor_to_array')
helper = LayerHelper("lod_tensor_to_array", **locals())
array = helper.create_variable(
name=unique_name.generate("lod_tensor_to_array"),
......@@ -1204,6 +1214,17 @@ def array_to_lod_tensor(x, table):
array = fluid.layers.lod_tensor_to_array(x, table)
lod_tensor = fluid.layers.array_to_lod_tensor(array, table)
"""
check_type(x, 'x', (Variable, list), 'array_to_lod_tensor')
if isinstance(x, (list)):
for i, input_x in enumerate(x):
check_type(input_x, 'input[' + str(i) + ']', Variable,
'array_to_lod_tensor')
check_type(table, 'table', (Variable, list), 'array_to_lod_tensor')
if isinstance(table, (list)):
for i, table_x in enumerate(table):
check_type(table_x, 'table[' + str(i) + ']', Variable,
'array_to_lod_tensor')
helper = LayerHelper("array_to_lod_tensor", **locals())
tmp = helper.create_variable_for_type_inference(dtype=x.dtype)
helper.append_op(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册