Skip to content

Commit

Permalink
[CODEGEN] Add CodeGenC
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Jan 20, 2017
1 parent 5b408d1 commit c72fcd8
Show file tree
Hide file tree
Showing 9 changed files with 661 additions and 2 deletions.
2 changes: 1 addition & 1 deletion HalideIR
Submodule HalideIR updated from b6637f to adfa66
1 change: 1 addition & 0 deletions python/tvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from . import stmt
from . import make
from . import ir_pass
from . import codegen
from . import collections
from . import schedule

Expand Down
1 change: 1 addition & 0 deletions python/tvm/_ctypes/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def _init_function_module(root_namespace):
namespace_match = {
"_make_": sys.modules["%s.make" % root_namespace],
"_pass_": sys.modules["%s.ir_pass" % root_namespace],
"_codegen_": sys.modules["%s.codegen" % root_namespace],
"_schedule_": sys.modules["%s.schedule" % root_namespace]
}

Expand Down
1 change: 1 addition & 0 deletions python/tvm/codegen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Code generation related functions"""
2 changes: 1 addition & 1 deletion src/base/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline Type String2Type(std::string s) {
} else if (s.substr(0, 5) == "float") {
code = Type::Float; s = s.substr(5);
} else if (s == "handle") {
return Type(Type::Handle, 0, 0);
return Type(Type::Handle, 32, 1);
} else {
LOG(FATAL) << "unknown type " << s;
}
Expand Down
25 changes: 25 additions & 0 deletions src/c_api/c_api_codegen.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*!
* Copyright (c) 2016 by Contributors
* Implementation of API functions related to IR build
* \file c_api_ir.cc
*/
#include <tvm/expr.h>
#include <tvm/ir.h>

#include "./c_api_registry.h"
#include "../codegen/codegen_c.h"

namespace tvm {
namespace codegen {

using ArgStack = const std::vector<APIVariantValue>;
using RetValue = APIVariantValue;

TVM_REGISTER_API(_codegen_CompileToC)
.set_body([](const ArgStack& args, RetValue *ret) {
*ret = CodeGenC().Compile(
args.at(0), args.at(1), args.at(2), args.at(3));
});

} // namespace codegen
} // namespace tvm
Loading

0 comments on commit c72fcd8

Please sign in to comment.