Created by: wangchaochaohu
API fluid.layers.array_read/array_write报错信息增强 [仅涉及Python端]
- C++端已在https://github.com/PaddlePaddle/Paddle/pull/23468 进行修改。
- API接口
def array_write(x, i , array=None):
def array_read(array, i):
对输入(x i arrary等输入变量)是否是Variable 进行检查
###Pytho 端测试代码
import paddle.fluid as fluid
import numpy as np
arr = fluid.layers.create_array(dtype='float32')
tmp = np.random.randn(2, 1).astype('float32')
i = fluid.layers.fill_constant(shape=[1], dtype='float32', value=10)
arr = fluid.layers.array_write(tmp, i, array=arr)
item = fluid.layers.array_read(arr, i)
input = fluid.layers.Print(item, message="The LoDTensor of the i-th position:")
main_program = fluid.default_main_program()
exe = fluid.Executor(fluid.CPUPlace())
exe.run(main_program)
报错信息
TypeError: The data type of 'i' in array_write must be ['int32', 'int64'], but received float32.