Skip to content

Commit 3c1020d

Browse files
authored
[CODEGEN] Add CodeGenC (#22)
1 parent 5b408d1 commit 3c1020d

File tree

9 files changed

+661
-2
lines changed

9 files changed

+661
-2
lines changed

HalideIR

Submodule HalideIR updated from b6637f6 to adfa662

python/tvm/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from . import stmt
99
from . import make
1010
from . import ir_pass
11+
from . import codegen
1112
from . import collections
1213
from . import schedule
1314

python/tvm/_ctypes/_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def _init_function_module(root_namespace):
281281
namespace_match = {
282282
"_make_": sys.modules["%s.make" % root_namespace],
283283
"_pass_": sys.modules["%s.ir_pass" % root_namespace],
284+
"_codegen_": sys.modules["%s.codegen" % root_namespace],
284285
"_schedule_": sys.modules["%s.schedule" % root_namespace]
285286
}
286287

python/tvm/codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Code generation related functions"""

src/base/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ inline Type String2Type(std::string s) {
3030
} else if (s.substr(0, 5) == "float") {
3131
code = Type::Float; s = s.substr(5);
3232
} else if (s == "handle") {
33-
return Type(Type::Handle, 0, 0);
33+
return Type(Type::Handle, 32, 1);
3434
} else {
3535
LOG(FATAL) << "unknown type " << s;
3636
}

src/c_api/c_api_codegen.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*!
2+
* Copyright (c) 2016 by Contributors
3+
* Implementation of API functions related to IR build
4+
* \file c_api_ir.cc
5+
*/
6+
#include <tvm/expr.h>
7+
#include <tvm/ir.h>
8+
9+
#include "./c_api_registry.h"
10+
#include "../codegen/codegen_c.h"
11+
12+
namespace tvm {
13+
namespace codegen {
14+
15+
using ArgStack = const std::vector<APIVariantValue>;
16+
using RetValue = APIVariantValue;
17+
18+
TVM_REGISTER_API(_codegen_CompileToC)
19+
.set_body([](const ArgStack& args, RetValue *ret) {
20+
*ret = CodeGenC().Compile(
21+
args.at(0), args.at(1), args.at(2), args.at(3));
22+
});
23+
24+
} // namespace codegen
25+
} // namespace tvm

0 commit comments

Comments
 (0)