cpp-package OpWrapperGenerator.py exists some bug?
recently i try to use cpp version to write some code
code :
int main(){
auto x = Symbol::Variable("x");
auto y = topk(x);
}
but got following error :
Symbol.ComposeKeyword argument name src not found.
Candidate arguments:
[0]data
i look into "op.h" in "cpp-package/include/mxnet-cpp"
return Operator("topk")
.SetParam("axis", axis)
.SetParam("k", k)
.SetParam("ret_typ", TopkRetTypValues[int(ret_typ)])
.SetParam("is_ascend", is_ascend)
.SetInput("src", src)
.CreateSymbol();
and i modified my code to:
int main(){
auto x = Symbol::Variable("x");
auto y= Operator("topk")
.SetParam("axis", 0)
.SetParam("k", 1)
.SetParam("ret_typ", "value")
.SetParam("is_ascend", false)
.SetInput("data", x) // change "src" to "data"
.CreateSymbol("symbol_topk");
}
and it works
it seems "op.h" is generate by "OpWrapperGenerator.py", but there are some bug existed
@lx75249
@piiswrong To fully fix this bug, it will be a big patch. All ops that forget to set FListInputNames properly suffer from this problem, because the default implementation of FListInputNames is return {"data"}. The basic idea of the patch is to separate parameters from inputs in op arguments. (add_arguments() to add_input(), add_arguments() to add_params()). In this way, we don't need set_num_inputs() and FListInputNames any more. What's your opinon?
its probably better to change src to data in add argument
This issue is closed due to lack of activity in the last 90 days. Feel free to ping me to reopen if this is still an active issue. Thanks!