OpRegistry::CreateOp调用,输入/输出名字写错,报错信息难以理解
Created by: Xreki
FCOp
,通过组合MulOp
, Row
,RowwiseAddOp
, SoftmaxOp
等实现,在C++实现中通过调用OpRegistry::CreateOp
来创建相应的Op
。
FCOp
的输入为X
和W
,MulOp
的输入为X
和Y
,在创建MulOp
将输入误写为:
AppendOp(framework::OpRegistry::CreateOp(
"mul", {{"X", {Input("X")}}, {"W", {Input("W")}}},
{{"Out", {Output("mul_out")}}}, {}));
单测时报错信息如下:
133: ======================================================================
133: ERROR: test_all (__main__.TestFCOp)
133: ----------------------------------------------------------------------
133: Traceback (most recent call last):
133: File "/home/liuyiqun01/github/Paddle/python/paddle/v2/framework/tests/op_test_util.py", line 55, in test_all
133: op = Operator(self.type, **kwargs)
133: File "/home/liuyiqun01/github/Paddle/build_paddle/build/python/build/lib-python/paddle/v2/framework/op.py", line 161, in __call__
133: return self.get_op_info(t).method(**kwargs)
133: File "/home/liuyiqun01/github/Paddle/build_paddle/build/python/build/lib-python/paddle/v2/framework/op.py", line 132, in __impl__
133: return core.Operator.create(opdesc.SerializeToString())
133: RuntimeError: basic_string::_S_construct null not valid
133:
133: ----------------------------------------------------------------------
这个报错信息太难以理解了,花了很多时间才发现是MulOp
输入的名字写错了,正确的写法应该是:
AppendOp(framework::OpRegistry::CreateOp(
"mul", {{"X", {Input("X")}}, {"Y", {Input("W")}}},
{{"Out", {Output("mul_out")}}}, {}));
重构后的Paddle,需要更友好、直观的错误提示。