Skip to content

Commit d781a57

Browse files
committed
[RUNTIME] Minimum runtime module (apache#31)
1 parent 343c19a commit d781a57

File tree

7 files changed

+612
-29
lines changed

7 files changed

+612
-29
lines changed

nnvm/deploy/nnvm_runtime.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
* All in one runtime
44
* \file nnvm_runtime.cc
55
*/
6+
/*
67
#include "../src/core/graph.cc"
78
#include "../src/core/node.cc"
89
#include "../src/core/pass.cc"
910
#include "../src/core/op.cc"
1011
#include "../src/pass/saveload_json.cc"
11-
#include "../src/runtime/graph_executor.cc"
12+
#include "../src/runtime/graph_executor.cc"*/
13+
#include "../src/runtime/graph_runtime.cc"

nnvm/src/compiler/graph_fuse.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,9 @@ nnvm::Graph GraphFuseCompile(nnvm::Graph g) {
335335
for (uint32_t nid = 0; nid < idx.num_nodes(); ++nid) {
336336
const auto& inode = idx[nid];
337337
if (inode.source->is_variable()) {
338+
// only copy over name since that is sufficient.
338339
nnvm::NodePtr np = nnvm::Node::Create();
339-
np->attrs = inode.source->attrs;
340+
np->attrs.name = inode.source->attrs.name;
340341
old_new[nid] = np;
341342
continue;
342343
}

nnvm/src/compiler/graph_hash.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ size_t GraphHash(const Graph& graph) {
9797
for (uint32_t nid = 0; nid < idx.num_nodes(); ++nid) {
9898
const IndexedGraph::Node& inode = idx[nid];
9999
// Use name instad op address so it is deterministic across runs
100-
key = dmlc::HashCombine(key, inode.source->op()p);
101100
if (inode.source->is_variable()) continue;
101+
key = dmlc::HashCombine(key, inode.source->op()->name);
102102
hash_temp.clear();
103103
for (const auto& kv : GetAttrDict(inode.source->attrs)) {
104104
hash_temp.push_back(dmlc::HashCombine(str_hash(kv.first), kv.second));

nnvm/src/runtime/graph_executor.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ inline void TVMOpParamParser(nnvm::NodeAttrs* attrs) {
299299
attrs->parsed = std::move(param);
300300
}
301301

302-
DMLC_REGISTER_PARAMETER(TVMOpParam);
303302

304303
NNVM_REGISTER_OP(tvm_op)
305304
.set_attr_parser(TVMOpParamParser)
@@ -328,12 +327,12 @@ tvm::runtime::Module RuntimeCreate(std::string sym_json,
328327
return tvm::runtime::Module(exec);
329328
}
330329

331-
TVM_REGISTER_GLOBAL("nnvm.runtime.create")
330+
TVM_REGISTER_GLOBAL("nnvm.runtime.createx")
332331
.set_body([](TVMArgs args, TVMRetValue *rv) {
333332
*rv = RuntimeCreate(args[0], args[1], args[2], args[3]);
334333
});
335334

336-
TVM_REGISTER_GLOBAL("nnvm.runtime.remote_create")
335+
TVM_REGISTER_GLOBAL("nnvm.runtime.remote_createx")
337336
.set_body([](TVMArgs args, TVMRetValue *rv) {
338337
void* mhandle = args[1];
339338
*rv = RuntimeCreate(args[0],

nnvm/src/runtime/graph_executor.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,11 @@
1717
#include <nnvm/pass.h>
1818
#include <vector>
1919
#include <string>
20+
#include "./graph_runtime.h"
2021

2122
namespace nnvm {
2223
namespace runtime {
2324

24-
/*! \brief Magic number for NDArray file */
25-
constexpr uint64_t kTVMNDArrayMagic = 0xDD5E40F096B4A13F;
26-
/*! \brief Magic number for NDArray list file */
27-
constexpr uint64_t kTVMNDArrayListMagic = 0xF7E58D4F05049CB7;
28-
29-
/*! \brief DLPack compatible data types */
30-
using DLTypeVector = std::vector<DLDataType>;
31-
32-
/*! \brief operator attributes about tvm op */
33-
struct TVMOpParam : public dmlc::Parameter<TVMOpParam> {
34-
std::string func_name;
35-
uint32_t num_inputs;
36-
uint32_t num_outputs;
37-
bool flatten_data;
38-
39-
DMLC_DECLARE_PARAMETER(TVMOpParam) {
40-
DMLC_DECLARE_FIELD(func_name);
41-
DMLC_DECLARE_FIELD(num_inputs).set_default(1);
42-
DMLC_DECLARE_FIELD(num_outputs).set_default(1);
43-
DMLC_DECLARE_FIELD(flatten_data).set_default(false);
44-
}
45-
};
46-
4725
/*!
4826
* \brief TVM Graph Executor.
4927
* This is a minimum graph executor, embedded in TVM runtime

0 commit comments

Comments
 (0)