Skip to content

Commit

Permalink
move TECompiler into VMCompilerContext
Browse files Browse the repository at this point in the history
  • Loading branch information
YuchenJin committed Jul 20, 2021
1 parent c4d08d2 commit 8e3d7ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/relay/backend/vm/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class VMFunctionCompiler : ExprFunctor<void(const Expr& expr)> {
void EmitShapeFunc(Function func, Array<Expr> inputs, Array<Expr> outputs) {
// Lower shape function
CCacheKey key(func, target_host_);
auto cfunc = compiler_->LowerShapeFunc(key);
auto cfunc = context_->compiler->LowerShapeFunc(key);
int op_index = -1;
// pick the only function inside the context
ICHECK_EQ(cfunc->funcs->functions.size(), 1);
Expand Down Expand Up @@ -552,7 +552,7 @@ class VMFunctionCompiler : ExprFunctor<void(const Expr& expr)> {

CCacheKey key(func, target);
auto mangle_fn = [](String name) { return name; };
auto cfunc = compiler_->Lower(key, mangle_fn);
auto cfunc = context_->compiler->Lower(key, mangle_fn);

auto op_index = -1;
if (func->GetAttr<String>(attr::kCompiler).defined()) {
Expand Down Expand Up @@ -858,8 +858,6 @@ class VMFunctionCompiler : ExprFunctor<void(const Expr& expr)> {
size_t last_register_;
/*! \brief Total number of virtual registers allocated. */
size_t registers_num_;
/*! \brief Compiler engine to lower primitive functions. */
TECompiler compiler_;
/*! \brief Global shared meta data */
VMCompilerContext* context_;
/*! \brief Target devices. */
Expand Down Expand Up @@ -1185,8 +1183,7 @@ void VMCompiler::Codegen() {
}
}

TECompiler compiler;
auto ext_mods = compiler->LowerExternalFunctions();
auto ext_mods = context_.compiler->LowerExternalFunctions();

runtime::Module lib;
if (funcs.size() > 0) {
Expand Down
2 changes: 2 additions & 0 deletions src/relay/backend/vm/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ struct VMCompilerContext {
TagMap tag_map;
// Map from global var to a unique integer
GlobalMap global_map;
// TECompiler to do lowering
tec::TECompiler compiler;
// List of constants
std::vector<NDArray> constants;
// Device type for constants
Expand Down

0 comments on commit 8e3d7ff

Please sign in to comment.