Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CODEGEN] A First commit of codegen C #22

Merged
merged 1 commit into from
Jan 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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