Export_library from Linux for Windows?

Hi,

Is it possible to export a module built by relay as a shared library for deployment in non-native format? That is, to create a Windows .DLL instead of .SO with a call to “export_library” while running on Linux? Any example would be greatly appreciated.

Thank you.

1 Like

Welcome @myuniqueusername.

I have no experience in cross-compiling Windows binaries/libraries on Linux. I noticed it was asked before (a while ago) here: [Cross compilation] Ubuntu for tvm generation and windows for executing in tvm runtime

It might worth testing it with newer versions and see what happens.

Thank you! I hope it may help. In the meantime, I’m trying to create a native Windows build, but there are some problems:

I followed the build from source instructions and got tvm.dll and tvm_runtime.dll. But when the tvm.dll is being loaded an exception is thrown like follows:

From file tvm\src\relay\transforms\simplify_expr.cc:

static Op reshape_op = Op::Get(“reshape”);

which calls to tvm\src\ir\op.cc:

const Op& Op::Get(const String& name) { const OpRegEntry* reg = OpRegistry::Global()->Get(name); CHECK(reg != nullptr) << “AttributeError: Operator " << name << " is not registered”; return reg->op(); }

which in turn calls to tvm\src\node\attr_registry.h:

const EntryType* Get(const String& name) const { auto it = entry_map_.find(name); if (it != entry_map_.end()) return it->second; return nullptr; }

And here no reshape operator in the entry_map_ is found. Do you have any idea what could go wrong, please?

Answering my own question regarding problems with Windows build (may be someone gets there by googling):

There are following definition in file src/relay/transforms/simplify_expr.cc:

static Op reshape_op = Op::Get("reshape");

static Op reverse_reshape_op = Op::Get("contrib_reverse_reshape");

Their Op:Get are failing as in Windows statics are initialized before the dll entry point is called.

As a workaround I moved the initializations inside SimplifyReshape ctor (several lines down).

BTW, I don’t see any reason to declare these two variables as static and outside of the SimplifyReshape class.