Unverified Commit a1d50f0f authored by Lingfan Yu's avatar Lingfan Yu Committed by GitHub
Browse files

[Refactor] Rename before release (#261)

* include/dgl/runtime

* include

* src/runtime

* src/graph

* src/scheduler

* src

* clean up CMakeLists

* further clean up in cmake

* install commands

* python/dgl/_ffi/_cython

* python/dgl/_ffi/_ctypes

* python/dgl/_ffi

* python/dgl

* some fix

* copy right
parent aabba9d4
/*!
* Copyright (c) 2017 by Contributors
* \file module.cc
* \brief TVM module system
* \brief DGL module system
*/
#include <dgl/runtime/module.h>
#include <dgl/runtime/registry.h>
......@@ -12,7 +12,7 @@
#include "file_util.h"
#endif
namespace tvm {
namespace dgl {
namespace runtime {
void Module::Import(Module other) {
......@@ -134,42 +134,42 @@ bool RuntimeEnabled(const std::string& target) {
return runtime::Registry::Get(f_name) != nullptr;
}
TVM_REGISTER_GLOBAL("module._Enabled")
.set_body([](TVMArgs args, TVMRetValue *ret) {
DGL_REGISTER_GLOBAL("module._Enabled")
.set_body([](DGLArgs args, DGLRetValue *ret) {
*ret = RuntimeEnabled(args[0]);
});
TVM_REGISTER_GLOBAL("module._GetSource")
.set_body([](TVMArgs args, TVMRetValue *ret) {
DGL_REGISTER_GLOBAL("module._GetSource")
.set_body([](DGLArgs args, DGLRetValue *ret) {
*ret = args[0].operator Module()->GetSource(args[1]);
});
TVM_REGISTER_GLOBAL("module._ImportsSize")
.set_body([](TVMArgs args, TVMRetValue *ret) {
DGL_REGISTER_GLOBAL("module._ImportsSize")
.set_body([](DGLArgs args, DGLRetValue *ret) {
*ret = static_cast<int64_t>(
args[0].operator Module()->imports().size());
});
TVM_REGISTER_GLOBAL("module._GetImport")
.set_body([](TVMArgs args, TVMRetValue *ret) {
DGL_REGISTER_GLOBAL("module._GetImport")
.set_body([](DGLArgs args, DGLRetValue *ret) {
*ret = args[0].operator Module()->
imports().at(args[1].operator int());
});
TVM_REGISTER_GLOBAL("module._GetTypeKey")
.set_body([](TVMArgs args, TVMRetValue *ret) {
DGL_REGISTER_GLOBAL("module._GetTypeKey")
.set_body([](DGLArgs args, DGLRetValue *ret) {
*ret = std::string(args[0].operator Module()->type_key());
});
TVM_REGISTER_GLOBAL("module._LoadFromFile")
.set_body([](TVMArgs args, TVMRetValue *ret) {
DGL_REGISTER_GLOBAL("module._LoadFromFile")
.set_body([](DGLArgs args, DGLRetValue *ret) {
*ret = Module::LoadFromFile(args[0], args[1]);
});
TVM_REGISTER_GLOBAL("module._SaveToFile")
.set_body([](TVMArgs args, TVMRetValue *ret) {
DGL_REGISTER_GLOBAL("module._SaveToFile")
.set_body([](DGLArgs args, DGLRetValue *ret) {
args[0].operator Module()->
SaveToFile(args[1], args[2]);
});
} // namespace runtime
} // namespace tvm
} // namespace dgl
......@@ -11,7 +11,7 @@
#include <string>
#include "module_util.h"
namespace tvm {
namespace dgl {
namespace runtime {
void ImportModuleBlob(const char* mblob, std::vector<Module>* mlist) {
......@@ -45,14 +45,14 @@ void ImportModuleBlob(const char* mblob, std::vector<Module>* mlist) {
PackedFunc WrapPackedFunc(BackendPackedCFunc faddr,
const std::shared_ptr<ModuleNode>& sptr_to_self) {
return PackedFunc([faddr, sptr_to_self](TVMArgs args, TVMRetValue* rv) {
return PackedFunc([faddr, sptr_to_self](DGLArgs args, DGLRetValue* rv) {
int ret = (*faddr)(
const_cast<TVMValue*>(args.values),
const_cast<DGLValue*>(args.values),
const_cast<int*>(args.type_codes),
args.num_args);
CHECK_EQ(ret, 0) << TVMGetLastError();
CHECK_EQ(ret, 0) << DGLGetLastError();
});
}
} // namespace runtime
} // namespace tvm
} // namespace dgl
......@@ -18,7 +18,7 @@ typedef int (*BackendPackedCFunc)(void* args,
int num_args);
} // extern "C"
namespace tvm {
namespace dgl {
namespace runtime {
/*!
* \brief Wrap a BackendPackedCFunc to packed function.
......@@ -40,22 +40,22 @@ void ImportModuleBlob(const char* mblob, std::vector<Module>* module_list);
*/
template<typename FLookup>
void InitContextFunctions(FLookup flookup) {
#define TVM_INIT_CONTEXT_FUNC(FuncName) \
#define DGL_INIT_CONTEXT_FUNC(FuncName) \
if (auto *fp = reinterpret_cast<decltype(&FuncName)*> \
(flookup("__" #FuncName))) { \
*fp = FuncName; \
}
// Initialize the functions
TVM_INIT_CONTEXT_FUNC(TVMFuncCall);
TVM_INIT_CONTEXT_FUNC(TVMAPISetLastError);
TVM_INIT_CONTEXT_FUNC(TVMBackendGetFuncFromEnv);
TVM_INIT_CONTEXT_FUNC(TVMBackendAllocWorkspace);
TVM_INIT_CONTEXT_FUNC(TVMBackendFreeWorkspace);
TVM_INIT_CONTEXT_FUNC(TVMBackendParallelLaunch);
TVM_INIT_CONTEXT_FUNC(TVMBackendParallelBarrier);
DGL_INIT_CONTEXT_FUNC(DGLFuncCall);
DGL_INIT_CONTEXT_FUNC(DGLAPISetLastError);
DGL_INIT_CONTEXT_FUNC(DGLBackendGetFuncFromEnv);
DGL_INIT_CONTEXT_FUNC(DGLBackendAllocWorkspace);
DGL_INIT_CONTEXT_FUNC(DGLBackendFreeWorkspace);
DGL_INIT_CONTEXT_FUNC(DGLBackendParallelLaunch);
DGL_INIT_CONTEXT_FUNC(DGLBackendParallelBarrier);
#undef TVM_INIT_CONTEXT_FUNC
#undef DGL_INIT_CONTEXT_FUNC
}
} // namespace runtime
} // namespace tvm
} // namespace dgl
#endif // DGL_RUNTIME_MODULE_UTIL_H_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -13,21 +13,21 @@
#define API_BEGIN() try {
/*! \brief every function starts with API_BEGIN();
and finishes with API_END() or API_END_HANDLE_ERROR */
#define API_END() } catch(std::runtime_error &_except_) { return TVMAPIHandleException(_except_); } return 0; // NOLINT(*)
#define API_END() } catch(std::runtime_error &_except_) { return DGLAPIHandleException(_except_); } return 0; // NOLINT(*)
/*!
* \brief every function starts with API_BEGIN();
* and finishes with API_END() or API_END_HANDLE_ERROR
* The finally clause contains procedure to cleanup states when an error happens.
*/
#define API_END_HANDLE_ERROR(Finalize) } catch(std::runtime_error &_except_) { Finalize; return TVMAPIHandleException(_except_); } return 0; // NOLINT(*)
#define API_END_HANDLE_ERROR(Finalize) } catch(std::runtime_error &_except_) { Finalize; return DGLAPIHandleException(_except_); } return 0; // NOLINT(*)
/*!
* \brief handle exception throwed out
* \param e the exception
* \return the return value of API after exception is handled
*/
inline int TVMAPIHandleException(const std::runtime_error &e) {
TVMAPISetLastError(e.what());
inline int DGLAPIHandleException(const std::runtime_error &e) {
DGLAPISetLastError(e.what());
return -1;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment