samskalicky commented on a change in pull request #17270: [WIP] Dynamic custom operator GPU support URL: https://github.com/apache/incubator-mxnet/pull/17270#discussion_r367697443
########## File path: include/mxnet/lib_api.h ########## @@ -566,16 +609,20 @@ typedef MXReturnValue (*createOpState_t)(std::map<std::string, std::string>, class CustomOp { public: explicit CustomOp(const char* op_name) : name(op_name), - forward(NULL), backward(NULL), parse_attrs(NULL), infer_type(NULL), - infer_shape(NULL), mutate_inputs(NULL), create_opstate(NULL), - isSGop(false) {} - ~CustomOp() {} - CustomOp& setForward(fcomp_t fcomp) { - forward = fcomp; + parse_attrs(NULL), infer_type(NULL), infer_shape(NULL), mutate_inputs(NULL), + create_opstate(NULL), isSGop(false) {} + CustomOp& setForward(fcomp_t fcomp, std::string ctx) { + char* cstr = new char[ctx.length()+1]; + strncpy(cstr, ctx.c_str(), ctx.length()+1); + forward_ctx_cstr.push_back(cstr); Review comment: i think we should use `const char*` here like we do for the `op_name`. This function is being called statically in the global scope. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services