-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MODULE/REFACTOR] Introduce Module for AOT and runtime linking.
- Loading branch information
Showing
65 changed files
with
2,480 additions
and
1,149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,27 @@ | ||
/*! | ||
* Copyright (c) 2016 by Contributors | ||
* Copyright (c) 2017 by Contributors | ||
* \file api_registry.h | ||
* \brief This file defines the TVM API registry. | ||
* | ||
* The API registry stores type-erased functions. | ||
* Each registered function is automatically exposed | ||
* to front-end language(e.g. python). | ||
* Front-end can also pass callbacks as PackedFunc, or register | ||
* then into the same global registry in C++. | ||
* The goal is to mix the front-end language and the TVM back-end. | ||
* | ||
* \code | ||
* // register the function as MyAPIFuncName | ||
* TVM_REGISTER_API(MyAPIFuncName) | ||
* .set_body([](TVMArgs args, TVMRetValue* rv) { | ||
* // my code. | ||
* }); | ||
* \endcode | ||
* \brief This files include necessary headers to | ||
* be used to register an global API function. | ||
*/ | ||
#ifndef TVM_API_REGISTRY_H_ | ||
#define TVM_API_REGISTRY_H_ | ||
|
||
#include <dmlc/base.h> | ||
#include <string> | ||
#include "./base.h" | ||
#include "./runtime/packed_func.h" | ||
#include "./packed_func_ext.h" | ||
|
||
namespace tvm { | ||
|
||
/*! \brief Utility to register API. */ | ||
class APIRegistry { | ||
public: | ||
/*! | ||
* \brief set the body of the function to be f | ||
* \param f The body of the function. | ||
*/ | ||
APIRegistry& set_body(PackedFunc f); // NOLINT(*) | ||
/*! | ||
* \brief set the body of the function to be f | ||
* \param f The body of the function. | ||
*/ | ||
APIRegistry& set_body(PackedFunc::FType f) { // NOLINT(*) | ||
return set_body(PackedFunc(f)); | ||
} | ||
/*! | ||
* \brief Register a function with given name | ||
* \param name The name of the function. | ||
*/ | ||
static APIRegistry& __REGISTER__(const std::string& name); // NOLINT(*) | ||
|
||
private: | ||
/*! \brief name of the function */ | ||
std::string name_; | ||
}; | ||
#include "./runtime/registry.h" | ||
|
||
/*! | ||
* \brief Get API function by name. | ||
* \brief Register an API function globally. | ||
* It simply redirects to TVM_REGISTER_GLOBAL | ||
* | ||
* \param name The name of the function. | ||
* \return the corresponding API function. | ||
* \note It is really PackedFunc::GetGlobal under the hood. | ||
*/ | ||
inline PackedFunc GetAPIFunc(const std::string& name) { | ||
return PackedFunc::GetGlobal(name); | ||
} | ||
|
||
#define _TVM_REGISTER_VAR_DEF_ \ | ||
static DMLC_ATTRIBUTE_UNUSED ::tvm::APIRegistry& __make_TVMRegistry_ | ||
|
||
/*! | ||
* \brief Register API function globally. | ||
* \code | ||
* TVM_REGISTER_API(MyPrint) | ||
* .set_body([](TVMArgs args, TVMRetValue* rv) { | ||
* // my code. | ||
* }); | ||
* \endcode | ||
*/ | ||
#define TVM_REGISTER_API(OpName) \ | ||
DMLC_STR_CONCAT(_TVM_REGISTER_VAR_DEF_, __COUNTER__) = \ | ||
::tvm::APIRegistry::__REGISTER__(#OpName) | ||
} // namespace tvm | ||
#define TVM_REGISTER_API(OpName) TVM_REGISTER_GLOBAL(OpName) | ||
|
||
#endif // TVM_API_REGISTRY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.