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

Update TVM registry API calls and node->object #32

Merged
merged 1 commit into from
Jan 9, 2020
Merged
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
19 changes: 12 additions & 7 deletions aot/to_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def mk_register_api(self, name: str, func) -> str:
args += ", "

source += f"""
TVM_REGISTER_API("{name}")
TVM_REGISTER_GLOBAL("{name}")
.set_body([](TVMArgs args, TVMRetValue* ret) {{
{init}
std::initializer_list<Value> ilist = {{{args}}};
Expand All @@ -385,7 +385,9 @@ def inter(strs, sep=", "):

def mk_file(body, ctx):
return f"""
#include <tvm/api_registry.h>
#include <tvm/runtime/registry.h>
#include <tvm/packed_func_ext.h>
#include <tvm/node/env_func.h>
#include <tvm/relay/interpreter.h>
#include <iostream>

Expand Down Expand Up @@ -416,8 +418,8 @@ def mk_file(body, ctx):
}}

static ConstructorValue TagToCV(size_t tag, const tvm::Array<Value>& fields) {{
NodePtr<ConstructorValueNode> n = make_node<ConstructorValueNode>();
NodePtr<ConstructorNode> con = make_node<ConstructorNode>();
ObjectPtr<ConstructorValueNode> n = make_object<ConstructorValueNode>();
ObjectPtr<ConstructorNode> con = make_object<ConstructorNode>();
con->tag = tag;
n->tag = tag;
n->constructor = Constructor(con);
Expand All @@ -439,13 +441,16 @@ class FunctionValue;
TVM_DLL static FunctionValue make(const function_value_t& f);

static constexpr const char* _type_key = "relay.FunctionValue";
TVM_DECLARE_NODE_TYPE_INFO(FunctionValueNode, ValueNode);
TVM_DECLARE_FINAL_OBJECT_INFO(FunctionValueNode, ValueNode);
}};

RELAY_DEFINE_NODE_REF(FunctionValue, FunctionValueNode, Value);
class FunctionValue : public Value {{
public:
TVM_DEFINE_OBJECT_REF_METHODS(FunctionValue, Value, FunctionValueNode);
}};

FunctionValue FunctionValueNode::make(const function_value_t& f) {{
NodePtr<FunctionValueNode> n = make_node<FunctionValueNode>();
ObjectPtr<FunctionValueNode> n = make_object<FunctionValueNode>();
n->f = f;
return FunctionValue(n);
}}
Expand Down