mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

cpp-package OpWrapperGenerator.py exists some bug?

Open chenjunweii opened this issue 9 years ago • 4 comments

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

chenjunweii avatar Apr 08 '17 13:04 chenjunweii

@lx75249

piiswrong avatar Apr 08 '17 17:04 piiswrong

@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?

conopt avatar Apr 09 '17 16:04 conopt

its probably better to change src to data in add argument

piiswrong avatar Apr 09 '17 17:04 piiswrong

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!

szha avatar Sep 29 '17 18:09 szha