terryzhao127 / tensorflow-windows-build-script

A script to automate building Tensorflow on Windows and solve some problems
GNU General Public License v3.0
102 stars 35 forks source link

How to load custom op dll using c++? #37

Open 7oud opened 5 years ago

7oud commented 5 years ago

@guikarist I wrote a very simple op zero_out, and compile it to zero_out.dll using bazel. It worked well when using python tf.load_op_library('./zero_out.dll'), Now I want to use this op(dll) in c++, how to load the dll, I try to use TF_LoadLibrary in c/c_api.h, but TF_NOT_FOUND = 5 is returned, zero_out.dll is not found? May some dependency are needed? I placed built tensorflow_cc.dll with zero_out.dll in the same directory. Could you give some advice?

TF_Status* status_load = TF_NewStatus();
TF_Library* lib_handle = TF_LoadLibrary("C:\\test_cc\\test_cc\\zero_out.dll", status_load);
TF_Code code = TF_GetCode(status_load); // code is 5