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

A few cleanups #10

Closed
wants to merge 20 commits into from
Closed
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
5 changes: 4 additions & 1 deletion include/tvm/ir/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <tvm/runtime/object.h>
#include <tvm/node/node.h>
#include <tvm/node/container.h>
#include <tvm/runtime/container.h>
#include <tvm/ir/span.h>
#include <tvm/ir/type.h>
#include <string>
Expand All @@ -36,6 +37,8 @@

namespace tvm {

using tvm::runtime::String;

/*!
* \brief Base type of all the expressions.
* \sa Expr
Expand Down Expand Up @@ -186,7 +189,7 @@ class GlobalVar;
class GlobalVarNode : public RelayExprNode {
public:
/*! \brief The name of the variable, this only acts as a hint. */
std::string name_hint;
String name_hint;

void VisitAttrs(AttrVisitor* v) {
v->Visit("name_hint", &name_hint);
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/node/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class Map : public ObjectRef {
/*!
* \brief Read element from map.
* \param key The key
* \return the corresonding element.
* \return the corresponding element.
*/
inline const V operator[](const K& key) const {
return DowncastNoCheck<V>(
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/node/reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AttrVisitor {
/*!
* \brief Virtual function table to support IR/AST node reflection.
*
* Functions are stored in columar manner.
* Functions are stored in a columnar manner.
* Each column is a vector indexed by Object's type_index.
*/
class ReflectionVTable {
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/relay/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class IdNode : public Object {
* this only acts as a hint to the user,
* and is not used for equality.
*/
std::string name_hint;
String name_hint;

void VisitAttrs(tvm::AttrVisitor* v) {
v->Visit("name_hint", &name_hint);
Expand Down
4 changes: 3 additions & 1 deletion include/tvm/relay/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <tvm/ir/expr.h>
#include <tvm/ir/op.h>
#include <tvm/ir/module.h>
#include <tvm/runtime/container.h>
#include <string>
#include <functional>
#include "./base.h"
Expand All @@ -36,6 +37,7 @@
namespace tvm {
namespace relay {

using tvm::runtime::String;
using Expr = tvm::RelayExpr;
using ExprNode = tvm::RelayExprNode;
using BaseFunc = tvm::BaseFunc;
Expand Down Expand Up @@ -172,7 +174,7 @@ class VarNode : public ExprNode {
Type type_annotation;

/*! \return The name hint of the variable */
const std::string& name_hint() const {
const String& name_hint() const {
return vid->name_hint;
}

Expand Down
11 changes: 11 additions & 0 deletions include/tvm/runtime/c_runtime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,15 @@ TVM_DLL int TVMObjectGetTypeIndex(TVMObjectHandle obj, unsigned* out_tindex);
*/
TVM_DLL int TVMObjectTypeKey2Index(const char* type_key, unsigned* out_tindex);

/*!
* \brief Increase the reference count of an object.
*
* \param obj The object handle.
* \note Internally we increase the reference counter of the object.
* \return 0 when success, -1 when failure happens
*/
TVM_DLL int TVMObjectRetain(TVMObjectHandle obj);

/*!
* \brief Free the object.
*
Expand All @@ -550,6 +559,8 @@ TVM_DLL int TVMObjectTypeKey2Index(const char* type_key, unsigned* out_tindex);
*/
TVM_DLL int TVMObjectFree(TVMObjectHandle obj);

TVM_DLL int TVMObjectDerivedFrom(uint32_t child_type_index, uint32_t parent_type_index, int* is_derived);

#ifdef __cplusplus
} // TVM_EXTERN_C
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/tvm/runtime/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ class StringObj : public Object {
friend class String;
};

TVM_REGISTER_OBJECT_TYPE(StringObj);

/*!
* \brief Reference to string objects.
*
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/runtime/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum TypeIndex {
* the type index will be assigned during runtime.
* Runtime type index can be accessed by ObjectType::TypeIndex();
* - _type_key:
* The unique string identifier of tyep type.
* The unique string identifier of the type.
* - _type_final:
* Whether the type is terminal type(there is no subclass of the type in the object system).
* This field is automatically set by marco TVM_DECLARE_FINAL_OBJECT_INFO
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/runtime/object_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def asobject(self):


def convert_to_object(value):
"""Convert a python value to corresponding object type.
"""Convert a Python value to corresponding object type.

Parameters
----------
Expand Down
18 changes: 9 additions & 9 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

[workspace]
members = [
"common",
"tvm-sys",
"macros",
"runtime",
"runtime/tests/test_tvm_basic",
"runtime/tests/test_tvm_dso",
"runtime/tests/test_nn",
"frontend",
"frontend/tests/basics",
"frontend/tests/callback",
"frontend/examples/resnet"
"graph-runtime",
"graph-runtime/tests/test_tvm_basic",
"graph-runtime/tests/test_tvm_dso",
"graph-runtime/tests/test_nn",
"tvm",
"tvm/tests/basics",
"tvm/tests/callback",
"tvm/examples/resnet"
]
58 changes: 0 additions & 58 deletions rust/common/build.rs

This file was deleted.

File renamed without changes.
8 changes: 4 additions & 4 deletions rust/runtime/Cargo.toml → rust/graph-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# under the License.

[package]
name = "tvm-runtime"
version = "0.1.0"
name = "tvm-graph-runtime"
version = "0.2.0"
license = "Apache-2.0"
description = "A static TVM runtime"
description = "A static linking friendly TVM graph runtime."
repository = "https://github.com/apache/incubator-tvm"
readme = "README.md"
keywords = ["tvm"]
Expand All @@ -38,7 +38,7 @@ num_cpus = "1.10"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tvm-common = { version = "0.1", path = "../common" }
tvm-sys = { version = "0.1", path = "../tvm-sys" }
tvm-macros = { version = "0.1", path = "../macros" }

[target.'cfg(not(any(target_arch = "wasm32", target_env = "sgx")))'.dependencies]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use std::{convert::TryFrom, mem, os::raw::c_void, ptr, slice};

use failure::Error;
use anyhow::Error;
use ndarray;
use tvm_common::{
array::{DataType, TVMContext},
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions rust/runtime/src/graph.rs → rust/graph-runtime/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use std::{cmp, collections::HashMap, convert::TryFrom, iter::FromIterator, mem, str};

use failure::Error;
use anyhow::Error;
use nom::{
character::complete::{alpha1, digit1},
number::complete::{le_i32, le_i64, le_u16, le_u32, le_u64, le_u8},
Expand Down Expand Up @@ -263,7 +263,7 @@ impl<'m, 't> GraphExecutor<'m, 't> {

let func = lib
.get_function(&attrs.func_name)
.ok_or_else(|| format_err!("Library is missing function {}", attrs.func_name))?;
.ok_or_else(|| anyhow!("Library is missing function {}", attrs.func_name))?;
let arg_indices = node
.inputs
.iter()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::{
ptr,
};

use failure::Error;
use anyhow::Error;

use crate::allocator::Allocation;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def main():
dshape = (32, 16)
net = _get_model(dshape)
mod, params = testing.create_workload(net)
import pdb; pdb.set_trace()
graph, lib, params = relay.build(
mod, 'llvm', params=params)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ fn test_load_graph() {
.unwrap()
.get("func_name")
.unwrap(),
"fused_nn_dense_nn_bias_add"
"fused_split"
);
assert_eq!(graph.nodes[3].inputs[0].index, 0);
assert_eq!(graph.nodes[4].inputs[0].index, 0);
assert_eq!(graph.nodes[5].inputs[0].index, 0);
assert_eq!(graph.nodes[6].inputs[0].index, 0);
assert_eq!(graph.heads.len(), 3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ authors = ["TVM Contributors"]
ndarray="0.12"
serde = "1.0"
serde_json = "1.0"
tvm-runtime = { path = "../../" }
tvm-graph-runtime = { path = "../../" }

[build-dependencies]
ar = "0.6"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ authors = ["TVM Contributors"]

[dependencies]
ndarray="0.12"
tvm-runtime = { path = "../../" }
tvm-graph-runtime = { path = "../../" }

[build-dependencies]
ar = "0.6"
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ authors = ["TVM Contributors"]

[dependencies]
ndarray="0.12"
tvm-runtime = { path = "../../" }
tvm-graph-runtime = { path = "../../" }
4 changes: 2 additions & 2 deletions rust/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ proc-macro = true
[dependencies]
goblin = "0.0.24"
proc-macro2 = "^1.0"
quote = "1.0"
syn = "1.0"
quote = "^1.0"
syn = { version = "1.0.17", features = ["full", "extra-traits"] }
Loading