Created by: Xreki
feed_op报错信息增强 [仅C++端]
OP_INOUT_CHECK
,增加输入、输出是否设置的检查。
1. 使用由于feed_op继承的是OperatorBase
,当输入或者输出没有设置时,在进入RunImpl
函数之前就会报错,因此修改前后报错信息一样,具体如下:
-
没有设置输入
Error: Operator feed's input, X, is not set at (/paddle/paddle/fluid/framework/operator.cc:382)
-
没有设置输出
Error: Operator feed's output, Out, is not set at (/paddle/paddle/fluid/framework/operator.cc:390)
2. 增强scope中,输入、输出变量是否存在的检查
-
检查scope中输入变量是否存在
- 修改前
Error: Cannot find feed_var in scope, feed_var_name is feed at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:39) [operator < feed > error]
- 修改后
NotFoundError: Input varibale(feed) cannot be found in scope for operator 'Feed'. [Hint: feed_var should not be null.] at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:40) [operator < feed > error]
-
检查scope中输出变量是否存在
- 修改前
Error: Cannot find out_var in scope, out_var_name is out_0 at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:45) [operator < feed > error]
- 修改后
NotFoundError: Output variable(out_0) cannot be found in scope for operator 'Feed' [Hint: out_var should not be null.] at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:48) [operator < feed > error]
3. 增强属性值是否合法的检查
-
增加
col >= 0
的检查- 设置
col = -1
,修改前
Error: An error occurred here. There is no accurate error hint for this error yet. We are continuously in the process of increasing hint for this kind of error check. It would be helpful if you could inform us of how this conversion went by opening a github issue. And we will resolve it with high priority. - New issue link: https://github.com/PaddlePaddle/Paddle/issues/new - Recommended issue content: all error stack information [Hint: Expected static_cast<size_t>(col) < feed_list.size(), but received static_cast<size_t>(col):18446744073709551615 >= feed_list.size():0.] at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:53) [operator < feed > error]
- 设置
col = -1
,修改后
InvalidArgumentError: Expected the column index (the attribute 'col' of operator 'Feed') of current feeding variable to be no less than 0. But received column index = -1. [Hint: Expected col >= 0, but received col:-1 < 0:0.] at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:56) [operator < feed > error]
- 设置
-
增强col < feed列表长度的报错信息
- 修改前
Error: An error occurred here. There is no accurate error hint for this error yet. We are continuously in the process of increasing hint for this kind of error check. It would be helpful if you could inform us of how this conversion went by opening a github issue. And we will resolve it with high priority. - New issue link: https://github.com/PaddlePaddle/Paddle/issues/new - Recommended issue content: all error stack information [Hint: Expected static_cast<size_t>(col) < feed_list.size(), but received static_cast<size_t>(col):1 >= feed_list.size():0.] at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:53) [operator < feed > error]
- 修改后
InvalidArgumentError: The column index of current feeding variable is expected to be less than the length of feeding list. But received column index = 1, the length of feeding list = 1 [Hint: Expected static_cast<size_t>(col) < feed_list.size(), but received static_cast<size_t>(col):1 >= feed_list.size():1.] at (/paddle/paddle/fluid/operators/controlflow/feed_op.cc:68) [operator < feed > error]
说明
feed op不是普通op,使用executor执行时,由executor根据用户的feed需求自动插入feed_op来填充用户数据。没有Python API,错误示例难以构造,因此不提供错误示例。