forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PaddlePaddle#33 from Superjomn/fea/init-module
fea/init module
- Loading branch information
Showing
14 changed files
with
160 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cc_library( | ||
backends | ||
SRCS outputs.cc | ||
) |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "cinn/lang/outputs.h" | ||
|
||
namespace cinn { | ||
namespace lang {} // namespace lang | ||
} // namespace cinn |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
namespace cinn { | ||
namespace backends { | ||
|
||
/** | ||
* A struct specifying a collection of outputs. | ||
*/ | ||
struct Outputs { | ||
//! The name of the emitted object file. Empty if no object file is desired. | ||
std::string object_name; | ||
|
||
//! The name of the emitted llvm bitcode. Empty if no bitcode file is desired. | ||
std::string bitcode_name; | ||
|
||
//! The name of the emitted C header file. | ||
std::string c_header_name; | ||
|
||
Outputs object(const std::string& name) const { | ||
Outputs updated = *this; | ||
updated.object_name = name; | ||
return updated; | ||
} | ||
|
||
Outputs bitcode(const std::string& name) const { | ||
Outputs updated = *this; | ||
updated.bitcode_name = name; | ||
return updated; | ||
} | ||
|
||
Outputs c_header(const std::string& name) const { | ||
Outputs updated = *this; | ||
updated.c_header_name = name; | ||
return updated; | ||
} | ||
}; | ||
|
||
} // namespace backends | ||
} // namespace cinn |
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,5 +1,6 @@ | ||
cc_library(common | ||
SRCS shared.cc pod_value.cc type.cc | ||
target.cc | ||
object.cc | ||
graph_utils.cc | ||
context.cc | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "cinn/lang/module.h" | ||
|
||
namespace cinn { | ||
namespace lang { | ||
|
||
/** | ||
* Content of a module. | ||
*/ | ||
struct _Module_ : Object { | ||
std::string name; | ||
Target target; | ||
std::vector<ir::Buffer> buffers; | ||
std::vector<ir::PackedFunc> functions; | ||
std::vector<Module> submodules; | ||
|
||
const char *type_info() const override { return "_Module_"; } | ||
}; | ||
|
||
_Module_ *Module::self() { return module_->As<_Module_>(); } | ||
const _Module_ *Module::self() const { return module_->As<_Module_>(); } | ||
|
||
Module::Module(const std::string &name, const Target &target) : module_(make_shared<_Module_>()) { | ||
self()->name = name; | ||
self()->target = target; | ||
} | ||
|
||
const Target &Module::target() const { return self()->target; } | ||
|
||
const std::string &Module::name() const { return self()->name; } | ||
|
||
const std::vector<ir::Buffer> &Module::buffers() const { return self()->buffers; } | ||
|
||
const std::vector<ir::PackedFunc> &Module::functions() const { return self()->functions; } | ||
|
||
const std::vector<Module> &Module::submodules() const { return self()->submodules; } | ||
|
||
void Module::Append(const ir::Buffer &buffer) { self()->buffers.push_back(buffer); } | ||
|
||
void Module::Append(const ir::PackedFunc &function) { self()->functions.push_back(function); } | ||
|
||
void Module::Append(const Module &module) { self()->submodules.push_back(module); } | ||
|
||
void Module::Compile(const backends::Outputs &outputs) const {} | ||
|
||
} // namespace lang | ||
} // namespace cinn |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "cinn/backends/outputs.h" | ||
#include "cinn/common/common.h" | ||
#include "cinn/ir/buffer.h" | ||
#include "cinn/ir/function.h" | ||
|
||
namespace cinn { | ||
namespace lang { | ||
|
||
class _Module_; | ||
|
||
/** | ||
* Module represents IR containing lowered function definitions and buffers. | ||
*/ | ||
class Module { | ||
public: | ||
Module(const std::string& name, const Target& target); | ||
|
||
//! Get the target of this module. | ||
const Target& target() const; | ||
|
||
//! Get the name of the module. | ||
const std::string& name() const; | ||
|
||
//! The members in the module. | ||
// @{ | ||
const std::vector<ir::Buffer>& buffers() const; | ||
const std::vector<ir::PackedFunc>& functions() const; | ||
const std::vector<Module>& submodules() const; | ||
// @} | ||
|
||
//! Add something to this module. | ||
// @{ | ||
void Append(const ir::Buffer& buffer); | ||
void Append(const ir::PackedFunc& function); | ||
void Append(const Module& module); | ||
// @} | ||
|
||
//! Compile a module to some outputs. | ||
void Compile(const backends::Outputs& outputs) const; | ||
|
||
_Module_* self(); | ||
const _Module_* self() const; | ||
|
||
private: | ||
Shared<_Module_> module_; | ||
}; | ||
|
||
} // namespace lang | ||
} // namespace cinn |
Empty file.
Empty file.
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,4 +1,3 @@ | ||
cc_library(utils SRCS string.cc | ||
target.cc | ||
functional.cc | ||
) |