Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
425430d
[QNN] Refactor fixed point multiplication in requantize (#4073)
vinx13 Oct 8, 2019
b5bcdbb
[Fix][VM] Fix VM invoke with set_params (#4079)
icemelon Oct 8, 2019
153fd7f
[AlterOpLayout][x86] NHWC to NCHWc conv support. (#4080)
anijain2305 Oct 8, 2019
2ee0f65
[CodeGen] Disable -mfloat-abi hard option for LLVM < 6.0 (#4071)
mbaret Oct 8, 2019
be86954
[VTA] hotfix for de10-nano driver (#4081)
huajsj Oct 8, 2019
90b10b8
Fix wrong n_trial number in autotvm tutorials' progress bar (#4070)
dati91 Oct 8, 2019
ec375a8
[ARITH] Add floordiv for the deduce bound (#4025)
Oct 8, 2019
1c56c72
[topi] enable fp16 sort for arm (#4084)
yzhliu Oct 8, 2019
3a32729
[TOPI][X86] Pool operator parallel support. (#4090)
anijain2305 Oct 9, 2019
c12275e
[relay] Small refactor for context (#4091)
zhiics Oct 9, 2019
f2abd9f
[TVM] Rewrite simplification rule to eliminate unnecessary conditiona…
ajtulloch Oct 9, 2019
4d875d1
[TOPI] Add valid auto tvm for Intel Graphics (#4078)
Laurawly Oct 9, 2019
fc2713e
[Relay][VM] Fix constant folding issue in VM compiler (#4077)
wweic Oct 10, 2019
4b8cb3a
[DOCKER] torch install depends on future package (#4098)
mshawcroft Oct 10, 2019
283afac
Fixing tensor not found issue in bitserial operator (#4095)
arangrej Oct 10, 2019
9572d98
[Fix] Fix the logic of the number of nodes checking in op fusion (#4074)
yidawang Oct 10, 2019
9bbc98c
- Adding support for Mxnet flavored dequantization for both default a…
shoubhik Oct 10, 2019
f312288
correct error (#4093)
Laurawly Oct 10, 2019
aad48ff
Add a python tutorial of deploying tvm module with tvm runtime only (…
fwd4 Oct 10, 2019
47e50e1
[VTA][TSIM] Serial GEMM Application Added (#4082)
BenjaminTu Oct 10, 2019
aa42413
[TOPI] FIFO buffer op, to accelerate sequence modeling with dilated c…
hcho3 Oct 10, 2019
d69c6fd
[Relay][AlterOp] NHWC to NCHWc support for Pool, pad, concatenate, su…
anijain2305 Oct 11, 2019
ef66653
Tutorial: update Building a Graph Convolutional Network tutorial (#4060)
cylinbao Oct 11, 2019
15ae978
force code object v2 for amd gpu backend (#4099)
petrex Oct 11, 2019
9d5cba2
[tvm][any] broadcast with values other than one (#3967)
zhiics Oct 11, 2019
d08ec10
[Fix] Fix a few bugs when dtype is fp16 (#4088)
icemelon Oct 11, 2019
ce72e9b
[codegen] Add multiple operands and function support when using fp16 …
Oct 11, 2019
985d219
adding soiferj to the list of reviewers (#4108)
tmoreau89 Oct 12, 2019
068c148
Add parser support for CAST tflite operator (#4096)
inadob Oct 13, 2019
d7e30ed
add dependency of compilation with LLVM (#4117)
zhiqiu Oct 13, 2019
dcf084e
save
MarisaKirisame Oct 4, 2019
b8df23a
save
MarisaKirisame Oct 13, 2019
50ed608
refactor
MarisaKirisame Oct 14, 2019
9c679b7
save
MarisaKirisame Oct 14, 2019
5d1e05d
save
MarisaKirisame Oct 14, 2019
9ab4864
save
MarisaKirisame Oct 15, 2019
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
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ We do encourage everyone to work anything they are interested in.
- [Junru Shao](https://github.com/junrushao1994): @junrushao1994
- [Haichen Shen](https://github.com/icemelon9): @icemelon9
- [Xingjian Shi](https://github.com/sxjscience): @sxjscience
- [Jon Soifer](https://github.com/soiferj): @soiferj
- [Andrew Tulloch](https://github.com/ajtulloch): @ajtulloch
- [Luis Vega](https://github.com/vegaluisjose): @vegaluisjose
- [Alex Weaver](https://github.com/alex-weaver): @alex-weaver
Expand Down
48 changes: 48 additions & 0 deletions apps/howto_deploy/python_deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Copyright (c) 2017 by Contributors
# brief Example code on load and run TVM module.s
# file python_deploy.py

import tvm
import numpy as np

def verify(mod, fname):
# Get the function from the module
f = mod.get_function(fname)
# Use tvm.nd.array to convert numpy ndarray to tvm
# NDArray type, so that function can be invoked normally
N = 10
x = tvm.nd.array(np.arange(N, dtype=np.float32))
y = tvm.nd.array(np.zeros(N, dtype=np.float32))
# Invoke the function
f(x, y)
np_x = x.asnumpy()
np_y = y.asnumpy()
# Verify correctness of function
assert(np.all([xi+1 == yi for xi, yi in zip(np_x, np_y)]))
print("Finish verification...")


if __name__ == "__main__":
# The normal dynamic loading method for deployment
mod_dylib = tvm.module.load("lib/test_addone_dll.so")
print("Verify dynamic loading from test_addone_dll.so")
verify(mod_dylib, "addone")
# There might be methods to use the system lib way in
# python, but dynamic loading is good enough for now.
5 changes: 4 additions & 1 deletion apps/howto_deploy/run_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ export DYLD_LIBRARY_PATH=../../build:${DYLD_LIBRARY_PATH}
echo "Run the deployment with all in one packed library..."
lib/cpp_deploy_pack

echo "Run the deployment with all in normal library..."
echo "Run the cpp deployment with all in normal library..."
lib/cpp_deploy_normal

echo "Run the python deployment with all in normal library..."
python python_deploy.py
2 changes: 1 addition & 1 deletion cmake/modules/VTA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ elseif(PYTHON)
# Rules for Zynq-class FPGAs with pynq OS support (see pynq.io)
if(${VTA_TARGET} STREQUAL "pynq" OR
${VTA_TARGET} STREQUAL "ultra96")
file(GLOB FPGA_RUNTIME_SRCS vta/src/pynq/pynq_driver.cc)
list(APPEND FPGA_RUNTIME_SRCS vta/src/pynq/pynq_driver.cc)
# Rules for Pynq v2.4
find_library(__cma_lib NAMES cma PATH /usr/lib)
elseif(${VTA_TARGET} STREQUAL "de10nano") # DE10-Nano rules
Expand Down
4 changes: 4 additions & 0 deletions docker/install/ubuntu_install_onnx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ set -o pipefail
# fix to certain version for now
pip3 install onnx==1.5.0

# torch depends on a number of other packages, but unhelpfully, does
# not expose that in the wheel!!!
pip3 install future

pip3 install https://download.pytorch.org/whl/cu80/torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
2 changes: 1 addition & 1 deletion docs/install/from_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Our goal is to build the shared libraries:
.. code:: bash

sudo apt-get update
sudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential cmake
sudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential cmake libedit-dev libxml2-dev

The minimal building requirements are

Expand Down
2 changes: 2 additions & 0 deletions include/tvm/arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class RewriteSimplifier {
const Expr& new_expr,
bool override = false);

std::function<void()> EnterConstraint(const Expr& constraint);

private:
friend class Analyzer;
friend class ConstraintContext;
Expand Down
8 changes: 8 additions & 0 deletions include/tvm/ir_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ Stmt StorageFlatten(Stmt stmt,
Map<Tensor, Buffer> extern_buffer,
int cache_line_size,
bool create_bound_attribute = false);
/*!
* \brief Verify if there is any argument bound to compact buffer.
*
* \param stmt The stmt to be verified.
* \return true if there is any buffer_bind_scope attribute found,
* otherwise, false.
*/
bool VerifyCompactBuffer(Stmt stmt);

/*!
* \brief Remove No Op from the Stmt.
Expand Down
9 changes: 9 additions & 0 deletions include/tvm/relay/attrs/nn.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,15 @@ struct SparseTransposeAttrs : public tvm::AttrsNode<SparseTransposeAttrs> {
TVM_DECLARE_ATTRS(SparseTransposeAttrs, "relay.attrs.SparseTransposeAttrs") {}
};

/*! \brief Attributes for FIFO buffer operator */
struct FIFOBufferAttrs : public tvm::AttrsNode<FIFOBufferAttrs> {
int axis;

TVM_DECLARE_ATTRS(FIFOBufferAttrs, "relay.attrs.FIFOBufferAttrs") {
TVM_ATTR_FIELD(axis).set_default(0);
}
};

/*! \brief Attributes for upsampling operator */
struct UpSamplingAttrs : public tvm::AttrsNode<UpSamplingAttrs> {
int scale;
Expand Down
12 changes: 10 additions & 2 deletions include/tvm/relay/op.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,18 @@ inline const TVMRetValue& GenericOpMap::operator[](const Op& op) const {
CHECK(op.defined());
const uint32_t idx = op->index_;
CHECK(idx < data_.size() && data_[idx].second != 0)
<< "Attribute " << attr_name_ << " has not been registered for Operator "
<< op->name;
<< "Attribute " << attr_name_ << " has not been registered for Operator "
<< op->name;
return data_[idx].first;
}

template <typename ValueType>
inline ValueType GenericOpMap::get(const Op& op, ValueType value) const {
CHECK(op.defined());
if (count(op) == 0) {
std::cout << "Attribute " << attr_name_ << " has not been registered for Operator "
<< op->name << std::endl;
}
const uint32_t idx = op->index_;
if (idx < data_.size() && data_[idx].second != 0) {
return data_[idx].first;
Expand All @@ -551,6 +555,10 @@ inline ValueType GenericOpMap::get(const Op& op, ValueType value) const {
template <typename ValueType>
inline ValueType GenericOpMap::get(const Expr& expr, ValueType value) const {
CHECK(expr.defined());
if (expr.as<OpNode>() && count(Downcast<Op>(expr)) == 0) {
std::cout << "Attribute " << attr_name_ << " has not been registered for Operator "
<< Downcast<Op>(expr)->name << std::endl;
}
if (const OpNode* op = expr.as<OpNode>()) {
const uint32_t idx = op->index_;
if (idx < data_.size() && data_[idx].second != 0) {
Expand Down
5 changes: 5 additions & 0 deletions include/tvm/relay/op_attr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ using TNonComputational = bool;
*/
using TShapeDataDependant = bool;

/*!
* \brief Can we lower this even with dynamic shape?
*/
using TOpDynamicCompute = bool;

/*!
* \brief Computation description interface.
*
Expand Down
16 changes: 15 additions & 1 deletion include/tvm/runtime/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct Instruction {
static Instruction Ret(RegName return_reg);
/*! \brief Construct a fatal instruction.
* \return The fatal instruction.
* */
* */
static Instruction Fatal();
/*! \brief Construct a invoke packed instruction.
* \param packed_index The index of the packed function.
Expand Down Expand Up @@ -419,6 +419,20 @@ class VirtualMachine : public runtime::ModuleNode {
runtime::Module lib;
/*! \brief The virtual machine's packed function table. */
std::vector<PackedFunc> packed_funcs;
size_t next_packed_func_index = 0;
size_t NewPackedFuncIndex() {
++next_packed_func_index;
return next_packed_func_index - 1;
}
/*! \brief Construct a invoke packed instruction.
* \param pf The PackedFunc.
* \param arity The arity of the function.
* \param output_size The number of outputs of the packed function.
* \param args The argument registers.
* \return The invoke packed instruction.
*/
Instruction InvokeNewPacked(const PackedFunc& pf, Index arity, Index output_size,
const std::vector<RegName>& args);
/*! \brief The virtual machine's function table. */
std::vector<VMFunction> functions;
/*! \brief The current stack of call frames. */
Expand Down
3 changes: 2 additions & 1 deletion nnvm/tutorials/tune_nnvm_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ def tune_tasks(tasks,
tuner_obj.load_history(autotvm.record.load_from_file(tmp_log_file))

# do tuning
tuner_obj.tune(n_trial=min(n_trial, len(tsk.config_space)),
n_trial = min(n_trial, len(tsk.config_space))
tuner_obj.tune(n_trial=n_trial,
early_stopping=early_stopping,
measure_option=measure_option,
callbacks=[
Expand Down
3 changes: 2 additions & 1 deletion nnvm/tutorials/tune_nnvm_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def tune_tasks(tasks,
tuner_obj.load_history(autotvm.record.load_from_file(tmp_log_file))

# do tuning
tuner_obj.tune(n_trial=min(n_trial, len(tsk.config_space)),
n_trial = min(n_trial, len(tsk.config_space))
tuner_obj.tune(n_trial=n_trial,
early_stopping=early_stopping,
measure_option=measure_option,
callbacks=[
Expand Down
3 changes: 2 additions & 1 deletion nnvm/tutorials/tune_nnvm_mobile_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def tune_tasks(tasks,
tuner_obj.load_history(autotvm.record.load_from_file(tmp_log_file))

# do tuning
tuner_obj.tune(n_trial=min(n_trial, len(tsk.config_space)),
n_trial = min(n_trial, len(tsk.config_space))
tuner_obj.tune(n_trial=n_trial,
early_stopping=early_stopping,
measure_option=measure_option,
callbacks=[
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/autotvm/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_const_int(exp):
if not isinstance(exp, (expr.IntImm, expr.UIntImm)):
exp = ir_pass.Simplify(exp)
if not isinstance(exp, (expr.IntImm, expr.UIntImm)):
raise ValueError("Expect value to be constant int")
raise ValueError("Expect value to be constant int, but is: " + str(exp))
return exp.value


Expand Down
18 changes: 15 additions & 3 deletions python/tvm/build_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,17 @@ def build_config(**kwargs):

return config

def get_binds(args, binds=None):
def get_binds(args, compact=False, binds=None):
"""Internal function to get binds and arg_list given arguments.

Parameters
----------
args : list of Buffer or Tensor or Var
The argument lists to the function.

compact : bool
If the statement has already bound to a compact buffer.

binds : dict of :any:`Tensor` to :any:`Buffer`, optional
Dictionary that maps the Tensor to Buffer which specified the data layout
requirement of the function. By default, a new compact buffer is created
Expand All @@ -290,12 +293,15 @@ def get_binds(args, binds=None):
arg_list = []
for x in args:
if isinstance(x, tensor.Tensor):
any_dim = any(isinstance(i, expr.Var) for i in x.shape)
buffer_type = "auto_broadcast" if any_dim and not compact else ""
if x not in binds:
buf = api.decl_buffer(x.shape,
dtype=x.dtype,
name=x.name,
data_alignment=cfg.data_alignment,
offset_factor=cfg.offset_factor)
offset_factor=cfg.offset_factor,
buffer_type=buffer_type)
binds[x] = buf
arg_list.append(buf)
else:
Expand Down Expand Up @@ -361,7 +367,6 @@ def lower(sch,
The result function, if with_api_wrapper=False
Then the Stmt before make api is returned.
"""
binds, arg_list = get_binds(args, binds)
cfg = current_build_config()
add_lower_pass = cfg.add_lower_pass if cfg.add_lower_pass else []
if cfg.dump_pass_ir:
Expand All @@ -377,11 +382,16 @@ def lower(sch,

for f in lower_phase0:
stmt = f(stmt)

compact = ir_pass.VerifyCompactBuffer(stmt)
binds, arg_list = get_binds(args, compact, binds)

# Phase 1
stmt = ir_pass.StorageFlatten(stmt, binds, 64, cfg.instrument_bound_checkers)
stmt = ir_pass.CanonicalSimplify(stmt)
for f in lower_phase1:
stmt = f(stmt)

# Phase 2
if not simple_mode:
stmt = ir_pass.LoopPartition(stmt, cfg.partition_const_loop)
Expand All @@ -400,6 +410,7 @@ def lower(sch,
cfg.unroll_explicit)
for f in lower_phase2:
stmt = f(stmt)

# Phase 3
stmt = ir_pass.Simplify(stmt)
stmt = ir_pass.LowerStorageAccessInfo(stmt)
Expand All @@ -413,6 +424,7 @@ def lower(sch,
stmt = ir_pass.InstrumentBoundCheckers(stmt)
if simple_mode:
return stmt

return ir_pass.MakeAPI(stmt, name, arg_list, 0, cfg.restricted_func)


Expand Down
Loading