Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uTVM] fix crt building and running error #6231

Merged
merged 1 commit into from
Aug 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/tvm/runtime/crt/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <tvm/runtime/c_backend_api.h>
#include <tvm/runtime/crt/func_registry.h>

#ifdef __cplusplus
extern "C" {
#endif

/*!
* \brief Module container of TVM.
*/
Expand All @@ -38,4 +42,7 @@ typedef struct TVMModule {
/*! \brief Entry point for the system lib module. */
const TVMModule* TVMSystemLibEntryPoint(void);

#ifdef __cplusplus
}
#endif
#endif // TVM_RUNTIME_CRT_MODULE_H_
4 changes: 3 additions & 1 deletion src/support/str_escape.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ inline std::string StrEscape(const char* data, size_t size, bool use_octal_escap
break;
default:
if (use_octal_escape) {
stream << '0' + ((c >> 6) & 0x03) << '0' + ((c >> 3) & 0x07) << '0' + (c & 0x03);
stream << static_cast<unsigned char>('0' + ((c >> 6) & 0x03))
<< static_cast<unsigned char>('0' + ((c >> 3) & 0x07))
<< static_cast<unsigned char>('0' + (c & 0x07));
} else {
const char* hex_digits = "0123456789ABCDEF";
stream << 'x' << hex_digits[c >> 4] << hex_digits[c & 0xf];
Expand Down
7 changes: 4 additions & 3 deletions src/target/source/codegen_c_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ void CodeGenCHost::GenerateFuncRegistry() {
decl_stream << "#include <tvm/runtime/crt/module.h>\n";
stream << "static TVMBackendPackedCFunc _tvm_func_array[] = {\n";
for (auto f : function_names_) {
stream << " " << f << ",\n";
stream << " (TVMBackendPackedCFunc)" << f << ",\n";
}
stream << "};\n";
auto registry = target::GenerateFuncRegistryNames(function_names_);
stream << "static const TVMFuncRegistry _tvm_func_registry = {\n"
<< " \"" << ::tvm::support::StrEscape(registry.data(), registry.size(), true) << "\","
Expand All @@ -290,10 +291,10 @@ void CodeGenCHost::GenerateFuncRegistry() {

void CodeGenCHost::GenerateCrtSystemLib() {
stream << "static const TVMModule _tvm_system_lib = {\n"
<< " &system_lib_registry,\n"
<< " &_tvm_func_registry,\n"
<< "};\n"
<< "const TVMModule* TVMSystemLibEntryPoint(void) {\n"
<< " return &system_lib;\n"
<< " return &_tvm_system_lib;\n"
<< "}\n";
}

Expand Down