Created by: wangchaochaohu
we need to fix the error message according the to some standard
检查Input变量类型 检查Input中dtype的类型 本次紧急修复只检查Input,其他输入参数可以参数不做检查 此项需要增加相应的单测监控到所有异常分支,以通过CI覆盖率测试
报错信息变化
1.对于input 维度信息 Code
import paddle.fluid as fluid
x = fluid.layers.data(name="x",shape=[1, 2, 3, 4, 5, 6, 7], append_batch_size=False, dtype='float32')
y = fluid.layers.reduce_sum(x)
报错信息:
PaddleCheckError: Expected x_rank <= 6, but received x_rank:7 > 6:6.
ShapeError: The input tensor X's dimensions of Reduce should be less equal than 6. But received X's dimensions = 7, X's shape = [1, 2, 3, 4, 5, 6, 7]. at [/workspace/codegen/Paddle/paddle/fluid/operators/reduce_ops/reduce_op.h:172]
[operator < reduce_sum > error]
2.对于reduce的dim 信息报错信息进行变更 Code
import paddle.fluid as fluid
x = fluid.layers.data(name="x",shape=[2, 3], append_batch_size=False, dtype='float32')
y = fluid.layers.reduce_sum(x, [3])
报错信息:
PaddleCheckError: Expected dims[i] < x_rank, but received dims[i]:3 >= x_rank:2.
ShapeError: The reduce dim index 0 should be in the range [-dimension(X), dimension(X)].which dimesion = 2, But received dim index = 3 at [/workspace/codegen/Paddle/paddle/fluid/operators/reduce_ops/reduce_op.h:187]
[operator < reduce_sum > error]
Python 端:(以reduce sum为例子)
1添加了对Input类型的检查
code:
import paddle.fluid as fluid
import numpy as np
x = fluid.create_lod_tensor(
np.array([[-1]]), [[1]], fluid.CPUPlace())
y = fluid.layers.reduce_sum(x,)
报错信息:
TypeError: The type of 'input' in reduce_sum must be Variable, but received <class 'paddle.fluid.core_avx.LoDTensor'>
2.添加了对输入Tensor的数据类型的检查
code
import paddle.fluid as fluid
x = fluid.layers.data(name="x",shape=[2, 3], append_batch_size=False, dtype='uint8')
y = fluid.layers.reduce_sum(x, [1])
报错信息:
TypeError: The data type of 'input' in reduce_sum must be float32 or float64 or int32 or int64, but received uint8.