Created by: liym27
select_input/select_output op报错信息增强
def select_input(inputs, mask)
def select_output(input, outputs, mask)
因为这2个接口的单测在同一文件,且通用之处较多,所以在同一个PR中修改。
Op shape报错检查增强
一、 Python API的input类型检查
1. 「select_input」的输入「inputs」的类型是tuple/list
- 修改后报错:
TypeError: The type of 'inputs' in select_input must be (<type 'list'>, <type 'tuple'>), but received <type 'int'>.
2. 「select_input」的输入「mask」的类型是Variable,dtype是int32/int64
- 修改后报错:
TypeError: The type of 'mask' in select_input must be <class 'paddle.fluid.framework.Variable'>, but received <type 'int'>.
TypeError: The data type of 'mask' in select_input must be ['int32'], but received float32.
3. 「select_output」的输入「input」的类型是Variable
- 修改后报错:
TypeError: The type of 'input' in select_output must be <class 'paddle.fluid.framework.Variable'>, but received <type 'int'>.
4. 「select_output」的输入「mask」的类型是Variable,dtype是int32/int64
- 修改后报错:
TypeError: The type of 'mask' in select_output must be <class 'paddle.fluid.framework.Variable'>, but received <type 'int'>.
TypeError: The data type of 'mask' in select_output must be ['int32'], but received float32.
5. 「select_output」的输入「outputs」的类型是list/tuple
- 修改后报错:
TypeError: The type of 'outputs' in select_output must be (<type 'list'>, <type 'tuple'>), but received <class 'paddle.fluid.framework.Variable'>.
二、 c++不合规报错检查增强
1.Mask数据比Inputs的size大时:
- 修改前报错:报错内容没有打印数据信息
Selected branch number is greater than actual branch num in SelectInputOp
- 修改后报错
InvalidArgumentError: Input 'Mask' in SelectInputOp is invalid. 'Mask' must be less than the size of input vector 'X'. But received Mask = 10, X's size = 2.
2. Mask的数据元素个数不等于1时:
- 修改前报错:报错内容没有打印数据信息
Mask in SelectOutputOp must have numel 1.
- 修改后报错:
InvalidArgumentError: Mask in SelectInputOp or SelectOutputOp must have numel 1. But received 2, and it's shape is [2].
3.Mask数据比Out的size大时:
- 修改前报错:报错内容没有打印数据信息
Selected branch number is greater than actual branch num in num in SelectOutputOp
- 修改后报错
InvalidArgumentError: Input 'Mask' in SelectOutputOp is invalid. 'Mask' must be less than the size of output vector 'Out'. But received Mask = 10, Out's size = 2.