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