Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

implement a c++ operator using other outside functions in 'so' file #17539

Closed
a550461053 opened this issue Feb 7, 2020 · 7 comments
Closed

Comments

@a550461053
Copy link

When I write a c++ operator, I want to use functions of my 'so' file. I have add -L /usr/lib -lmy_so_file -ldl to g++, nvcc line of 'config.mk'. But when I build mxnet, got error undefined reference to xxx_function. The 'xxx_function' is added in xxx-inl.h. And the 'so' file test right independently.

@a550461053
Copy link
Author

How can we insert a pre-define function to dmlc-core?

@rondogency
Copy link
Contributor

@a550461053 are you using the c++ custom operator? if yes, you need to use the mx.library.load(*.so) api to have your .so file dynamically loaded.

@a550461053
Copy link
Author

@a550461053 are you using the c++ custom operator? if yes, you need to use the mx.library.load(*.so) api to have your .so file dynamically loaded.

No, I use the c++ operator in mxnet backend according to . Because I have implement a operator and I need to reuse mshadow op.

@stu1130
Copy link
Contributor

stu1130 commented Feb 24, 2020

[@mxnet-label-bot add custom]

@rondogency
Copy link
Contributor

Hi @a550461053 are you able to resolve the problem based on the discussion in #17486 (comment)

@a550461053
Copy link
Author

Hi @a550461053 are you able to resolve the problem based on the discussion in #17486 (comment)

I implement a mxnet backend operator and use 'dlopen' to load 'so' file in 'xxx-inl.h' first forward function. It's ok.
But I have another problem: I inherit the mxnet operator to implement my XXX op, it's ok. But I want to use 'NDArray' as the input of forward function instead of 'TBlob' for using the dependencies. When I try the NNVM_REGISTER_OP(_contrib_xxx).set_attr<FComputeEx>("FComputeEx<cpu>", XXX<cpu>);, test the XXX operator in python, got _contrib_XXX is not implemented for CPU. Do you have any ideas?

@a550461053
Copy link
Author

Hi @a550461053 are you able to resolve the problem based on the discussion in #17486 (comment)

I implement a mxnet backend operator and use 'dlopen' to load 'so' file in 'xxx-inl.h' first forward function. It's ok.
But I have another problem: I inherit the mxnet operator to implement my XXX op, it's ok. But I want to use 'NDArray' as the input of forward function instead of 'TBlob' for using the dependencies. When I try the NNVM_REGISTER_OP(_contrib_xxx).set_attr<FComputeEx>("FComputeEx<cpu>", XXX<cpu>);, test the XXX operator in python, got _contrib_XXX is not implemented for CPU. Do you have any ideas?

This new problem has been found: NNVM_REGISTER_OP should assign DispatchMode::kFComputeEx when using FComputeEx .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants