Skip to content

Commit

Permalink
Merge branch 'master' into tf-rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
srkreddy1238 authored Mar 11, 2019
2 parents b59c2ef + f7eff09 commit 405500b
Show file tree
Hide file tree
Showing 48 changed files with 1,863 additions and 66 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ We do encourage everyone to work anything they are interested in.
- [Haichen Shen](https://github.com/icemelon9) (PMC): @icemelon9 - relay, topi
- [Zhixun Tan](https://github.com/phisiart): @phisiart - opengl, web
- [Leyuan Wang](https://github.com/Laurawly): @Laurawly: - topi
- [Yao Wang](https://github.com/kevinthesun): @kevinthesun: - topi, vision
- [Eddie Yan](https://github.com/eqy): @eqy - runtime, autotvm, rpc, topi
- [Lianmin Zheng](https://github.com/merrymercy) (PMC): @merrymercy - autotvm, topi, relay

Expand Down
5 changes: 3 additions & 2 deletions cmake/util/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ macro(find_llvm use_llvm)
execute_process(COMMAND ${LLVM_CONFIG} --cxxflags
OUTPUT_VARIABLE __llvm_cxxflags)
execute_process(COMMAND ${LLVM_CONFIG} --version
COMMAND cut -b 1,3
OUTPUT_VARIABLE TVM_LLVM_VERSION)
OUTPUT_VARIABLE __llvm_version)
# llvm version
string(REGEX REPLACE "^([^.]+)\.([^.])+\.[^.]+.*$" "\\1\\2" TVM_LLVM_VERSION ${__llvm_version})
# definitions
string(REGEX MATCHALL "(^| )-D[A-Za-z0-9_]*" LLVM_DEFINITIONS ${__llvm_cxxflags})
# include dir
Expand Down
20 changes: 20 additions & 0 deletions conda/cross-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# this one is important
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_PLATFORM Linux)
#this one not so much
set(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
set(CMAKE_C_COMPILER $ENV{CC})

# where is the target environment
set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot)

# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# god-awful hack because it seems to not run correct tests to determine this:
set(__CHAR_UNSIGNED___EXITCODE 1)
2 changes: 1 addition & 1 deletion conda/nnvm/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source:
path: ../..

build:
number: 1
number: 0
skip: True # [win]

requirements:
Expand Down
2 changes: 1 addition & 1 deletion conda/topi/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source:
path: ../..

build:
number: 1
number: 0

requirements:
host:
Expand Down
26 changes: 23 additions & 3 deletions conda/tvm-libs/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# Fix for OSX build to hide the clang LLVM
rm -f ${BUILD_PREFIX}/bin/llvm-config
rm -rf ${BUILD_PREFIX}/lib/cmake

set -e

if [ -z "$PREFIX" ]; then
Expand All @@ -9,13 +13,29 @@ fi
if [ -z "$cuda" ] || [ "$cuda" == "False" ]; then
CUDA_OPT=""
else
CUDA_OPT="-DUSE_CUDA=ON"
CUDA_OPT="-DUSE_CUDA=ON -DUSE_CUBLAS=ON"
fi

if [ "$target_platform" == "osx-64" ]; then
# macOS 64 bits
METAL_OPT="" # Conda can only target 10.9 for now
TOOLCHAIN_OPT=""
else
METAL_OPT=""
if [ "$target_platform" == "linux-64" ]; then
# Linux 64 bits
TOOLCHAIN_OPT="-DCMAKE_TOOLCHAIN_FILE=${RECIPE_DIR}/../cross-linux.cmake"
else
# Windows (or 32 bits, which we don't support)
METAL_OPT=""
TOOLCHAIN_OPT=""
fi
fi

rm -rf build || true
mkdir -p build
cd build
cmake $CUDA_OPT -DUSE_LLVM=ON -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
make -j4 VERBOSE=1
cmake $METAL_OPT $CUDA_OPT -DUSE_LLVM=ON -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" $TOOLCHAIN_OPT ..
make -j${CPU_COUNT} VERBOSE=1
make install
cd ..
14 changes: 5 additions & 9 deletions conda/tvm-libs/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ source:
path: ../..

build:
number: 1
number: 0
string: cuda{{ cuda_version }}_{{ PKG_BUILDNUM }} # [cuda]

requirements:
build:
- {{ compiler('cxx') }} # [linux]
- llvmdev ==6.0.0 # [osx]
host:
# The OS X build will require some manual setup or it will break
# See https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html#macos-sdk
# It is also ass-backward because of llvm brokeness when mixed with the
# conda OS X compiler
- {{ compiler('cxx') }} # [osx]
# See https://docs.conda.io/projects/conda-build/en/latest/source/resources/compiler-tools.html#macos-sdk
- {{ compiler('cxx') }}
host:
- cmake
- llvmdev ==6.0.0 # [linux]
- llvmdev ==6.0.0
- zlib # [linux]
run:
- {{ pin_compatible('cudatoolkit', lower_bound=cuda_version, max_pin='x.x') }} # [cuda]
Expand Down
2 changes: 1 addition & 1 deletion conda/tvm/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source:
path: ../..

build:
number: 1
number: 0

requirements:
build:
Expand Down
3 changes: 0 additions & 3 deletions docs/api/python/relay/backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ tvm.relay.backend

.. automodule:: tvm.relay.backend

Interpreter
-----------

.. automodule:: tvm.relay.backend.interpreter
:members:

Expand Down
3 changes: 3 additions & 0 deletions docs/api/python/relay/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ tvm.relay.base
.. autoclass:: tvm.relay.base.Span
:members:

.. autoclass:: tvm.relay.base.SourceName
:members:

.. autoclass:: tvm.relay.base.Id
:members:
2 changes: 2 additions & 0 deletions docs/api/python/relay/build_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ tvm.relay.build_module

.. autofunction:: tvm.relay.build_module.build

.. autofunction:: tvm.relay.build_module.build_config

.. autofunction:: tvm.relay.build_module.optimize

.. autofunction:: tvm.relay.build_module.create_executor
Expand Down
14 changes: 10 additions & 4 deletions docs/api/python/relay/expr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ tvm.relay.expr
.. autoclass:: tvm.relay.expr.TupleGetItem
:members:

.. autoclass:: tvm.relay.expr.TempExpr
.. autoclass:: tvm.relay.expr.RefCreate
:members:

.. autoclass:: tvm.relay.expr.RefRead
:members:

.. autoclass:: tvm.relay.expr.RefWrite
:members:

.. autoclass:: tvm.relay.expr.ExprFunctor
.. autoclass:: tvm.relay.expr.TupleGetItem
:members:

.. autoclass:: tvm.relay.expr.ExprMutator
.. autoclass:: tvm.relay.expr.TempExpr
:members:

.. autoclass:: tvm.relay.expr.TupleWrapper
:members
:members:

8 changes: 8 additions & 0 deletions docs/api/python/relay/frontend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ tvm.relay.frontend
.. autofunction:: tvm.relay.frontend.from_keras

.. autofunction:: tvm.relay.frontend.from_onnx

.. autofunction:: tvm.relay.frontend.from_tflite

.. autofunction:: tvm.relay.frontend.from_coreml

.. autofunction:: tvm.relay.frontend.from_caffe2

.. autofunction:: tvm.relay.frontend.from_tensorflow
2 changes: 1 addition & 1 deletion docs/api/python/relay/image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ tvm.relay.image
.. automodule:: tvm.relay.image
:members:

.. automodule:: tvm.relay.op.image.image
.. automodule:: tvm.relay.op.image
:members:
28 changes: 23 additions & 5 deletions docs/api/python/relay/op.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,27 @@ tvm.relay.op
.. automodule:: tvm.relay.op
:members:

.. automodule:: tvm.relay.op.op
:members:
.. autofunction:: tvm.relay.op.Op

.. autofunction:: tvm.relay.op.OpPattern

.. autofunction:: tvm.relay.op.get

.. autofunction:: tvm.relay.op.register

.. autofunction:: tvm.relay.op.register_schedule

.. autofunction:: tvm.relay.op.register_pattern

.. autofunction:: tvm.relay.op.register_compute

.. autofunction:: tvm.relay.op.register_gradient

.. autofunction:: tvm.relay.op.register_alter_op_layout

.. autofunction:: tvm.relay.op.schedule_injective

.. autofunction:: tvm.relay.op.debug

.. automodule:: tvm.relay.op.reduce
:members:
Expand All @@ -15,11 +34,10 @@ tvm.relay.op
.. automodule:: tvm.relay.op.transform
:members:

.. automodule:: tvm.relay.op.nn.nn
.. automodule:: tvm.relay.op.nn
:members:

.. automodule:: tvm.relay.op.vision.multibox
:members:

.. automodule:: tvm.relay.op.vision.nms
:members:
.. autofunction:: tvm.relay.vision.nms
4 changes: 4 additions & 0 deletions docs/api/python/topi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ List of operators
topi.logical_not
topi.arange
topi.stack
topi.repeat
topi.tile
topi.layout_transform
topi.image.resize

Expand Down Expand Up @@ -132,6 +134,8 @@ topi
.. autofunction:: topi.less
.. autofunction:: topi.arange
.. autofunction:: topi.stack
.. autofunction:: topi.repeat
.. autofunction:: topi.tile
.. autofunction:: topi.layout_transform

topi.nn
Expand Down
10 changes: 10 additions & 0 deletions docs/langref/relay_op.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ This level enables additional math and transform operators.
tvm.relay.split
tvm.relay.arange
tvm.relay.stack
tvm.relay.repeat
tvm.relay.tile


**Level 4: Broadcast and Reductions**
Expand All @@ -112,6 +114,9 @@ This level enables additional math and transform operators.
tvm.relay.greater_equal
tvm.relay.less
tvm.relay.less_equal
tvm.relay.logical_and
tvm.relay.logical_or
tvm.relay.logical_not
tvm.relay.maximum
tvm.relay.minimum
tvm.relay.power
Expand Down Expand Up @@ -222,6 +227,8 @@ Level 3 Definitions
.. autofunction:: tvm.relay.split
.. autofunction:: tvm.relay.arange
.. autofunction:: tvm.relay.stack
.. autofunction:: tvm.relay.repeat
.. autofunction:: tvm.relay.tile


Level 4 Definitions
Expand All @@ -234,6 +241,9 @@ Level 4 Definitions
.. autofunction:: tvm.relay.greater_equal
.. autofunction:: tvm.relay.less
.. autofunction:: tvm.relay.less_equal
.. autofunction:: tvm.relay.logical_and
.. autofunction:: tvm.relay.logical_or
.. autofunction:: tvm.relay.logical_not
.. autofunction:: tvm.relay.maximum
.. autofunction:: tvm.relay.minimum
.. autofunction:: tvm.relay.power
Expand Down
35 changes: 35 additions & 0 deletions include/tvm/arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,39 @@ class ModularSetAnalyzer {
Impl* impl_;
};

/*!
* \brief Rewrite-rule based simplifier.
*/
class RewriteSimplifier {
public:
/*!
* \brief analyze the expr
* \param expr The expression of interest.
* \return the result of the analysis.
*/
Expr operator()(const Expr& expr);

/*!
* \brief Update binding of var to a new expression.
*
* \param var The variable of interest.
* \param new_expr
* \param override Whether do we allow override of existing information.
*/
void Update(const Var& var,
const Expr& new_expr,
bool override = false);

private:
friend class Analyzer;
friend class ConstraintContext;
explicit RewriteSimplifier(Analyzer* parent);
~RewriteSimplifier();
class Impl;
/*! \brief Internal impl */
Impl* impl_;
};

/*!
* \brief A RAII constraint context.
*
Expand Down Expand Up @@ -242,6 +275,8 @@ class Analyzer {
ConstIntBoundAnalyzer const_int_bound;
/*! \brief sub-analyzer: modular set */
ModularSetAnalyzer modular_set;
/*! \brief sub-analyzer rewrite simplfy */
RewriteSimplifier rewrite_simplify;
/*! \brief constructor */
Analyzer();
/*!
Expand Down
22 changes: 22 additions & 0 deletions include/tvm/relay/attrs/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,28 @@ struct StackAttrs : public tvm::AttrsNode<StackAttrs> {
}
}; // struct StackAttrs

/*! \brief Attributes used in repeat operators */
struct RepeatAttrs : public tvm::AttrsNode<RepeatAttrs> {
Integer repeats;
Integer axis;
TVM_DECLARE_ATTRS(RepeatAttrs, "relay.attrs.RepeatAttrs") {
TVM_ATTR_FIELD(repeats)
.describe("The number of repetitions for each element.");
TVM_ATTR_FIELD(axis).set_default(NullValue<Integer>())
.describe(" The axis along which to repeat values.");
}
}; // struct RepeatAttrs

/*! \brief Attributes used in tile operators */
struct TileAttrs : public tvm::AttrsNode<TileAttrs> {
Array<Integer> reps;
TVM_DECLARE_ATTRS(TileAttrs, "relay.attrs.TileAttrs") {
TVM_ATTR_FIELD(reps)
.describe("The number of times for repeating the tensor a."
"Each dim sizeof reps must be a positive integer.");
}
}; // struct TileAttrs

/*! \brief Attributes used in squeeze operators */
struct SqueezeAttrs : public tvm::AttrsNode<SqueezeAttrs> {
// use axis to make the name numpy compatible.
Expand Down
Loading

0 comments on commit 405500b

Please sign in to comment.