[incubator-tvm] branch master updated (da23619 -> 3f6b3db)

2019-11-15 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from da23619  Add check to ensure input file was successfully opened in 
NNVM deploy code demo (#4315)
 add 3f6b3db  [COMMUNITY] Add DISCLAIMER, KEYS for ASF release (#4345)

No new revisions were added by this update.

Summary of changes:
 DISCLAIMER| 12 +++
 KEYS  | 74 +++
 NOTICE|  7 +++-
 tests/lint/check_file_type.py |  2 ++
 4 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 DISCLAIMER
 create mode 100644 KEYS



[incubator-tvm] branch master updated (545f6ea -> b422f6a)

2020-02-25 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 545f6ea  [Fix] remove unnecessary spliting in the cached chunk (#4935)
 add b422f6a  [WIP] Fixing an Infinite Loop case in UnmatchedChecker. 
(#4881)

No new revisions were added by this update.

Summary of changes:
 src/relay/pass/match_exhaustion.cc  | 34 +++--
 tests/python/relay/test_pass_unmatched_cases.py | 25 ++
 2 files changed, 34 insertions(+), 25 deletions(-)



[incubator-tvm] branch pass_callback_via_cx created (now 00ec7f9)

2020-01-27 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch pass_callback_via_cx
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at 00ec7f9  [Build] Explicitly link to cublasLt if it exists (#4776)

No new revisions were added by this update.



[incubator-tvm] branch pass_callback_via_cx updated: Implement pass tracing API

2020-01-27 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch pass_callback_via_cx
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/pass_callback_via_cx by this 
push:
 new 1f38493  Implement pass tracing API
1f38493 is described below

commit 1f3849378884be54c16efcd23c78f168c5c99ecd
Author: Jared Roesch 
AuthorDate: Mon Jan 27 16:35:45 2020 -0800

Implement pass tracing API
---
 include/tvm/ir/transform.h  | 19 +++
 python/tvm/relay/transform.py   | 13 +
 src/ir/transform.cc |  8 
 src/relay/ir/transform.cc   |  3 ++-
 tests/python/relay/test_pass_manager.py | 30 ++
 5 files changed, 68 insertions(+), 5 deletions(-)

diff --git a/include/tvm/ir/transform.h b/include/tvm/ir/transform.h
index c606b34..03aba40 100644
--- a/include/tvm/ir/transform.h
+++ b/include/tvm/ir/transform.h
@@ -65,6 +65,14 @@
 namespace tvm {
 namespace transform {
 
+// Forward declare for TraceFunc.
+class PassInfo;
+
+/*! \brief A callback for tracing passes, useful for debugging and logging.
+ *
+ */
+using TraceFunc = runtime::TypedPackedFunc;
+
 /*!
  * \brief PassContextNode contains the information that a pass can rely on,
  * such as analysis results.
@@ -88,6 +96,8 @@ class PassContextNode : public Object {
   /*! \brief The list of disabled passes. */
   Array disabled_pass;
 
+  TraceFunc trace_func;
+
   PassContextNode() = default;
 
   void VisitAttrs(AttrVisitor* v) {
@@ -101,6 +111,7 @@ class PassContextNode : public Object {
   TVM_DECLARE_FINAL_OBJECT_INFO(PassContextNode, Object);
 };
 
+
 /*!
  * \brief PassContext that is used to configure the pass behavior.
  *
@@ -146,6 +157,14 @@ class PassContext : public ObjectRef {
*/
   TVM_DLL static PassContext Current();
 
+  /*!
+   * \brief Apply the tracing functions of the context to the module, with the 
info.
+   * \param module The IRModule to trace.
+   * \param info The pass information.
+   * \param is_before Indicated whether the tracing is before or after a pass.
+   */
+  TVM_DLL void Trace(const IRModule& module, const PassInfo& info, bool 
is_before) const;
+
   // accessor.
   using ContainerType = PassContextNode;
   class Internal;
diff --git a/python/tvm/relay/transform.py b/python/tvm/relay/transform.py
index c4fbde6..26b20e0 100644
--- a/python/tvm/relay/transform.py
+++ b/python/tvm/relay/transform.py
@@ -78,7 +78,8 @@ class PassContext(RelayNode):
  opt_level=2,
  fallback_device=_nd.cpu(),
  required_pass=None,
- disabled_pass=None):
+ disabled_pass=None,
+ trace=None):
 if isinstance(fallback_device, str):
 fallback_device = _nd.context(fallback_device).device_type
 elif isinstance(fallback_device, TVMContext):
@@ -99,7 +100,7 @@ class PassContext(RelayNode):
 
 self.__init_handle_by_constructor__(_transform.PassContext, opt_level,
 fallback_device, required,
-disabled)
+disabled, trace)
 
 def __enter__(self):
 _transform.EnterPassContext(self)
@@ -117,7 +118,8 @@ class PassContext(RelayNode):
 def build_config(opt_level=2,
  fallback_device=_nd.cpu(),
  required_pass=None,
- disabled_pass=None):
+ disabled_pass=None,
+ trace=None):
 """Configure the build behavior by setting config variables.
 
 Parameters
@@ -151,13 +153,16 @@ def build_config(opt_level=2,
 disabled_pass: set of str, optional
 Optimization passes to be disabled during optimization.
 
+trace: Callable[[IRModule, PassInfo, bool], None]
+A tracing function for debugging or introspection.
+
 Returns
 ---
 pass_context: PassContext
 The pass context for optimizations.
 """
 return PassContext(opt_level, fallback_device, required_pass,
-   disabled_pass)
+   disabled_pass, trace)
 
 
 @register_relay_node
diff --git a/src/ir/transform.cc b/src/ir/transform.cc
index 1da010c..d14a5b4 100644
--- a/src/ir/transform.cc
+++ b/src/ir/transform.cc
@@ -84,6 +84,10 @@ PassContext PassContext::Create() {
   return PassContext(make_object());
 }
 
+void PassContext::Trace(const IRModule& module, const PassInfo& info, bool 
is_before) const {
+this->operator->()->trace_func(module, info, is_before);
+}
+
 class ModulePass;
 
 /*!
@@ -231,8 +235,10 @@ IRModule ModulePassNode::operator()(const IRModule& mod,
  << " with opt level: "
  << pass_info->opt_level;
   CHECK(mod.defined());
+  pas

[incubator-tvm] branch master updated (f71a10c -> de919cb)

2020-01-27 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from f71a10c  properly extract error type from windows error message (#4780)
 add de919cb  [Relay][Frontend][ONNX] Broadcast condition, x, and y for 
Where op (#4774)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/onnx.py  | 29 -
 tests/python/frontend/onnx/test_forward.py | 16 
 2 files changed, 40 insertions(+), 5 deletions(-)



[incubator-tvm] branch master updated (1b8522e -> 6798ba8)

2020-01-29 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 1b8522e  [AUTOTVM] Fix a bug in generating the search space (#4779)
 add 6798ba8  Make sure to visit the arguments of inlined functions (#4783)

No new revisions were added by this update.

Summary of changes:
 src/relay/backend/vm/inline_primitives.cc | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)



[incubator-tvm] branch master updated (f9b46c4 -> 3e7bd70)

2020-02-04 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from f9b46c4  [REFACTOR][PY] tvm._ffi (#4813)
 add 3e7bd70  allow customize mkldnn library location (#4814)

No new revisions were added by this update.

Summary of changes:
 cmake/config.cmake   |  2 +-
 cmake/modules/contrib/BLAS.cmake | 28 +++-
 2 files changed, 24 insertions(+), 6 deletions(-)



[incubator-tvm] branch master updated (dcf7fbf -> 86092de)

2020-01-10 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from dcf7fbf  [Relay][TOPI]Fix meaning of conv2d_transpose output_padding 
parameter (#4318)
 add 86092de  [REFACTOR] Replace TensorObj and TensorValue with NDArray 
(#4643)

No new revisions were added by this update.

Summary of changes:
 docs/api/python/dev.rst|  13 +-
 docs/dev/codebase_walkthrough.rst  |   8 +-
 include/tvm/relay/interpreter.h| 105 ---
 include/tvm/runtime/vm.h   |  19 --
 python/tvm/__init__.py |   4 +-
 python/tvm/_ffi/_ctypes/function.py|  13 +-
 python/tvm/_ffi/_ctypes/object.py  |  10 +-
 python/tvm/_ffi/_cython/function.pxi   |  11 +-
 python/tvm/_ffi/_cython/object.pxi |   8 +-
 python/tvm/_ffi/function.py|   2 +-
 python/tvm/_ffi/node.py|  89 --
 python/tvm/_ffi/object.py  |  66 ++-
 .../_ffi/{node_generic.py => object_generic.py}|  30 ++--
 python/tvm/api.py  |  19 +-
 python/tvm/arith.py|  16 +-
 python/tvm/attrs.py|   6 +-
 python/tvm/build_module.py |  18 +-
 python/tvm/container.py|  28 +--
 python/tvm/expr.py |  86 +-
 python/tvm/ir_builder.py   |   6 +-
 python/tvm/{node.py => object.py}  |   4 +-
 python/tvm/relay/_module.pyi   |   4 +-
 python/tvm/relay/adt.py|   4 +-
 python/tvm/relay/backend/compile_engine.py |  10 +-
 python/tvm/relay/backend/interpreter.py|  62 ++-
 python/tvm/relay/backend/vm.py |  12 +-
 python/tvm/relay/backend/vmobj.py  |  45 +
 python/tvm/relay/base.py   |   9 +-
 python/tvm/relay/expr.pyi  |   4 +-
 python/tvm/relay/quantize/quantize.py  |   4 +-
 python/tvm/relay/testing/py_converter.py   |  19 +-
 python/tvm/relay/transform.pyi |   8 +-
 python/tvm/relay/ty.pyi|   4 +-
 python/tvm/schedule.py |  40 ++---
 python/tvm/stmt.py |  32 ++--
 python/tvm/target.py   |  12 +-
 python/tvm/tensor.py   |  43 ++---
 python/tvm/tensor_intrin.py|   6 +-
 src/relay/backend/interpreter.cc   | 191 ++---
 src/relay/backend/vm/compiler.cc   |   2 +-
 src/relay/pass/fold_constant.cc|  26 +--
 src/relay/pass/partial_eval.cc |  13 +-
 src/runtime/vm/executable.cc   |  15 +-
 src/runtime/vm/object.cc   |  20 ---
 src/runtime/vm/vm.cc   |  50 ++
 .../frontend/tensorflow/test_control_flow.py   |   3 +-
 tests/python/frontend/tensorflow/test_forward.py   |   4 +-
 tests/python/relay/test_adt.py |   4 +-
 tests/python/relay/test_backend_interpreter.py |  37 ++--
 tests/python/relay/test_py_converter.py|   9 +-
 tests/python/relay/test_vm.py  |   2 +-
 tests/python/relay/test_vm_object.py   |  18 +-
 .../unittest/test_pass_inject_double_buffer.py |   4 +-
 tests/python/unittest/test_pass_inject_vthread.py  |   8 +-
 tests/python/unittest/test_pass_storage_flatten.py |   4 +-
 55 files changed, 508 insertions(+), 781 deletions(-)
 delete mode 100644 python/tvm/_ffi/node.py
 rename python/tvm/_ffi/{node_generic.py => object_generic.py} (82%)
 rename python/tvm/{node.py => object.py} (93%)



[incubator-tvm] branch master updated (9687307 -> 3cc4971)

2020-04-24 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 9687307  Corrected TVM autotuning on GPU (#5432)
 add 3cc4971  [RUNTIME][OBJECT] Introduce static slots for common objects. 
(#5423)

No new revisions were added by this update.

Summary of changes:
 include/tvm/ir/expr.h   |  7 ++--
 include/tvm/ir/function.h   |  1 +
 include/tvm/ir/tensor_type.h|  1 +
 include/tvm/ir/type.h   |  2 ++
 include/tvm/relay/expr.h|  1 +
 include/tvm/runtime/container.h |  6 ++--
 include/tvm/runtime/ndarray.h   |  4 +--
 include/tvm/runtime/object.h| 43 ++---
 include/tvm/runtime/packed_func.h   |  2 ++
 include/tvm/runtime/vm.h|  4 +--
 include/tvm/tir/stmt.h  |  1 +
 include/tvm/tir/var.h   |  1 +
 python/tvm/relay/quantize/quantize.py   |  2 +-
 python/tvm/runtime/container.py |  2 +-
 python/tvm/runtime/ndarray.py   |  2 +-
 src/arith/canonical_simplify.cc |  1 +
 src/runtime/module.cc   |  2 ++
 src/runtime/object.cc   | 34 ---
 src/target/codegen.cc   |  1 +
 src/target/opt/build_cuda_on.cc |  2 +-
 src/target/source/codegen_opencl.cc |  2 +-
 src/target/source/codegen_opengl.cc |  2 +-
 src/target/spirv/build_vulkan.cc|  2 +-
 src/target/stackvm/codegen_stackvm.cc   |  2 +-
 tests/cpp/build_module_test.cc  |  8 ++---
 tests/cpp/object_protocol_test.cc   |  1 +
 tests/cpp/relay_build_module_test.cc| 14 
 tests/cpp/utvm_runtime_standalone_test.cc   |  8 ++---
 tests/python/unittest/test_te_schedule_graph.py |  6 ++--
 29 files changed, 113 insertions(+), 51 deletions(-)



[incubator-tvm] branch master updated (3be9576 -> 09792ec)

2020-05-18 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 3be9576  [BYOC] Remove kCompiler attr from external functions (#5615)
 add 09792ec  [Relay]Improve Shape Func handling for Tuple inputs (#5467)

No new revisions were added by this update.

Summary of changes:
 src/relay/backend/compile_engine.cc |  7 ++
 src/relay/op/memory/memory.cc   | 13 ++-
 tests/python/relay/test_any.py  | 44 +
 3 files changed, 63 insertions(+), 1 deletion(-)



[incubator-tvm] branch rust-tvm-sys created (now 84e7d53)

2020-05-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm-sys
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at 84e7d53  Tests are passing

No new revisions were added by this update.



[incubator-tvm] branch rust-tvm-sys updated (79131d5 -> 5662f8e)

2020-05-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm-sys
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard 79131d5  Add the tvm-sys crate as the lowest level bindings.
 add 5662f8e  Add tvm-sys

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (79131d5)
\
 N -- N -- N   refs/heads/rust-tvm-sys (5662f8e)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 include/tvm/ir/expr.h  |   5 +-
 include/tvm/node/container.h   |   2 +-
 include/tvm/node/reflection.h  |   2 +-
 include/tvm/relay/base.h   |   2 +-
 include/tvm/relay/expr.h   |   4 +-
 include/tvm/runtime/c_runtime_api.h|  11 -
 include/tvm/runtime/container.h|  16 -
 include/tvm/runtime/object.h   |   2 +-
 python/tvm/runtime/object_generic.py   |   2 +-
 rust/Cargo.toml|  19 +-
 rust/{tvm-sys => common}/Cargo.toml|   5 +-
 rust/common/build.rs   |  58 +++
 rust/{tvm-sys => common}/src/array.rs  |  85 
 rust/{tvm-sys => common}/src/errors.rs |  13 +-
 rust/{tvm-sys => common}/src/lib.rs|  26 +-
 rust/{tvm-sys => common}/src/packed_func.rs| 111 +++--
 rust/common/src/value.rs   | 231 +++
 rust/{tvm => frontend}/.gitignore  |   0
 rust/{tvm => frontend}/.travis.yml |   0
 rust/{tvm => frontend}/Cargo.toml  |  12 +-
 rust/{tvm => frontend}/README.md   |   0
 .../examples/resnet/Cargo.toml |   0
 rust/{tvm => frontend}/examples/resnet/README.md   |   0
 rust/{tvm => frontend}/examples/resnet/build.rs|   0
 .../examples/resnet/src/build_resnet.py|   0
 rust/{tvm => frontend}/examples/resnet/src/main.rs |   0
 rust/frontend/src/context.rs   | 330 +++
 rust/{tvm-rt => frontend}/src/errors.rs|  22 +-
 rust/frontend/src/function.rs  | 462 +
 rust/{tvm-rt => frontend}/src/lib.rs   |  32 +-
 rust/{tvm-rt => frontend}/src/module.rs|  45 +-
 rust/{tvm-rt => frontend}/src/ndarray.rs   |  90 ++--
 rust/frontend/src/value.rs | 166 
 rust/{tvm => frontend}/tests/basics/.gitignore |   0
 rust/{tvm => frontend}/tests/basics/Cargo.toml |   2 +-
 rust/{tvm => frontend}/tests/basics/build.rs   |   0
 rust/{tvm => frontend}/tests/basics/src/main.rs|   0
 rust/{tvm => frontend}/tests/basics/src/tvm_add.py |   0
 rust/{tvm => frontend}/tests/callback/Cargo.toml   |   2 +-
 .../tests/callback/src/bin/array.rs|   0
 .../tests/callback/src/bin/error.rs|   0
 .../tests/callback/src/bin/float.rs|   0
 .../tests/callback/src/bin/int.rs  |   0
 .../tests/callback/src/bin/string.rs   |   0
 rust/graph-runtime/.travis.yml |  22 -
 rust/macros/Cargo.toml |   4 +-
 rust/macros/src/import_module.rs   | 133 --
 rust/macros/src/lib.rs | 124 +-
 rust/macros/src/object.rs  | 171 
 rust/out-of-tree/Cargo.toml|  16 -
 rust/out-of-tree/import_pass.py|  41 --
 rust/out-of-tree/src/lib.rs|  60 ---
 rust/{tvm-rt => runtime}/.travis.yml   |   0
 rust/{graph-runtime => runtime}/Cargo.toml |   8 +-
 rust/{graph-runtime => runtime}/src/allocator.rs   |   0
 rust/{graph-runtime => runtime}/src/array.rs   |   4 +-
 rust/{graph-runtime => runtime}/src/errors.rs  |   0
 rust/{graph-runtime => runtime}/src/graph.rs   |   6 +-
 rust/{graph-runtime => runtime}/src/lib.rs |   5 +-
 rust/{graph-runtime => runtime}/src/module/dso.rs  |   4 +-
 rust/{graph-runtime => runtime}/src/module/mod.rs  |   4 +-
 .../src/module/syslib.rs   |   2 +-
 rust/{graph-runtime => runtime}/src/

[incubator-tvm] 01/01: Add tvm-rt

2020-05-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm-rt
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit d8d3147e304bdf5336acf22fb7616a9e59c2ad71
Author: Jared Roesch 
AuthorDate: Wed May 6 02:22:08 2020 -0700

Add tvm-rt
---
 include/tvm/ir/expr.h  |   5 +-
 python/tvm/runtime/object_generic.py   |   2 +-
 rust/macros/Cargo.toml |   4 +-
 rust/macros/src/{lib.rs => import_module.rs}   |  12 +-
 rust/macros/src/lib.rs | 124 +-
 rust/macros/src/object.rs  | 171 
 rust/tvm-rt/.gitignore |   7 +
 rust/{macros/Cargo.toml => tvm-rt/.travis.yml} |  24 +-
 rust/{macros => tvm-rt}/Cargo.toml |  30 +-
 rust/tvm-rt/README.md  | 235 +++
 rust/{macros => tvm-rt/examples/resnet}/Cargo.toml |  23 +-
 rust/tvm-rt/examples/resnet/README.md  |  45 +++
 rust/tvm-rt/examples/resnet/build.rs   |  42 ++
 rust/tvm-rt/examples/resnet/src/build_resnet.py| 134 +++
 rust/tvm-rt/examples/resnet/src/main.rs| 160 
 rust/tvm-rt/src/context.rs |  76 
 rust/tvm-rt/src/errors.rs  |  45 +++
 rust/tvm-rt/src/function.rs| 340 
 rust/tvm-rt/src/lib.rs | 124 ++
 rust/tvm-rt/src/module.rs  | 130 +++
 rust/tvm-rt/src/ndarray.rs | 431 +
 rust/tvm-rt/src/object/mod.rs  |  99 +
 rust/tvm-rt/src/object/object_ptr.rs   | 283 ++
 rust/tvm-rt/src/string.rs  |  72 
 rust/tvm-rt/src/to_boxed_fn.rs | 222 +++
 rust/tvm-rt/src/to_function.rs | 377 ++
 rust/tvm-rt/src/value.rs   | 166 
 rust/tvm-rt/tests/test_ir.rs   |  36 ++
 src/ir/expr.cc |  11 +-
 src/printer/relay_text_printer.cc  |  15 +-
 src/relay/transforms/to_cps.cc |   2 +-
 src/runtime/object.cc  |  14 +
 src/runtime/object_internal.h  |   9 +
 33 files changed, 3294 insertions(+), 176 deletions(-)

diff --git a/include/tvm/ir/expr.h b/include/tvm/ir/expr.h
index fba35a9..82689bd 100644
--- a/include/tvm/ir/expr.h
+++ b/include/tvm/ir/expr.h
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,6 +37,8 @@
 
 namespace tvm {
 
+using tvm::runtime::String;
+
 /*!
  * \brief Base type of all the expressions.
  * \sa Expr
@@ -189,7 +192,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", _hint);
diff --git a/python/tvm/runtime/object_generic.py 
b/python/tvm/runtime/object_generic.py
index cc21450..8f559ae 100644
--- a/python/tvm/runtime/object_generic.py
+++ b/python/tvm/runtime/object_generic.py
@@ -38,7 +38,7 @@ ObjectTypes = (ObjectBase, NDArrayBase, Module, 
ObjectRValueRef, PyNativeObject)
 
 
 def convert_to_object(value):
-"""Convert a python value to corresponding object type.
+"""Convert a Python value to corresponding object type.
 
 Parameters
 --
diff --git a/rust/macros/Cargo.toml b/rust/macros/Cargo.toml
index 784b35e..7abc9ae 100644
--- a/rust/macros/Cargo.toml
+++ b/rust/macros/Cargo.toml
@@ -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"] }
diff --git a/rust/macros/src/lib.rs b/rust/macros/src/import_module.rs
similarity index 92%
copy from rust/macros/src/lib.rs
copy to rust/macros/src/import_module.rs
index 9f28c74..6b059ae 100644
--- a/rust/macros/src/lib.rs
+++ b/rust/macros/src/import_module.rs
@@ -16,9 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-extern crate proc_macro;
-
 use quote::quote;
 use std::{fs::File, io::Read};
 use syn::parse::{Parse, ParseStream, Result};
@@ -37,8 +34,7 @@ impl Parse for ImportModule {
 }
 }
 
-#[proc_macro]
-pub fn import_module(input: proc_macro::TokenStream) -> 
proc_macro::TokenStream {
+pub fn macro_impl(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
 let import_module_args = syn::parse_macro_input!(input as ImportModule);
 
 let man

[incubator-tvm] branch rust-tvm-sys updated (84e7d53 -> 79131d5)

2020-05-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm-sys
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


omit 84e7d53  Tests are passing
omit 6e7ef97  New function interface
omit 8ca7efd  Repair tests for tvm-sys
omit 719b805  Format for Max
omit 40a3adb  Hack hack
omit f4a940e  Almost there ...
omit 7fedb66  ToFunction not working
omit a4c6de2  Unify different context types and add ToFunction instances
omit e605234  Work on converting tvm-rt, split to_function into its own file
omit 77a6473  Clean up organization of tvm-sys
omit d74fb91  WIP
omit 37ce767  Add function and get out of tree pass working
omit 35be34b  WIP
omit 6a15349  WIP
omit 2177ffa  Almost got out of tree pass working
omit e38d2f7  Useful v1 of Macro
omit cb093c8  Object derive Macro v1
omit eea1f0f  Finish array support and add call node
omit 82377ba  Almost got arrays working
omit baf91bf  Remove diff tool generated files
omit f8b5f3c  Now with failing array test
omit b866880  Reorganize
omit 8c8bb4b  Runtime crate builds
omit 7701399  Reorganize to new structure
omit ebeb899  Add runtime copy
omit 06b1590  Move frontend
omit f4f4f50  Move runtime to graph-runtime
omit 1283829  Move tvm-common to tvm-sys
omit 2d8a2be  Convert to thiserror and anyhow
omit 62efbe2  WIP
omit 2ab6141  Add a couple more Relay IR nodes
omit c991575  Refactor the Rust libraries.
 add 79131d5  Add the tvm-sys crate as the lowest level bindings.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (84e7d53)
\
 N -- N -- N   refs/heads/rust-tvm-sys (79131d5)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:



[incubator-tvm] branch rust-tvm-sys updated (79131d5 -> 5662f8e)

2020-05-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm-sys
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard 79131d5  Add the tvm-sys crate as the lowest level bindings.
 add 5662f8e  Add tvm-sys

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (79131d5)
\
 N -- N -- N   refs/heads/rust-tvm-sys (5662f8e)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 include/tvm/ir/expr.h  |   5 +-
 include/tvm/node/container.h   |   2 +-
 include/tvm/node/reflection.h  |   2 +-
 include/tvm/relay/base.h   |   2 +-
 include/tvm/relay/expr.h   |   4 +-
 include/tvm/runtime/c_runtime_api.h|  11 -
 include/tvm/runtime/container.h|  16 -
 include/tvm/runtime/object.h   |   2 +-
 python/tvm/runtime/object_generic.py   |   2 +-
 rust/Cargo.toml|  19 +-
 rust/{tvm-sys => common}/Cargo.toml|   5 +-
 rust/common/build.rs   |  58 +++
 rust/{tvm-sys => common}/src/array.rs  |  85 
 rust/{tvm-sys => common}/src/errors.rs |  13 +-
 rust/{tvm-sys => common}/src/lib.rs|  26 +-
 rust/{tvm-sys => common}/src/packed_func.rs| 111 +++--
 rust/common/src/value.rs   | 231 +++
 rust/{tvm => frontend}/.gitignore  |   0
 rust/{tvm => frontend}/.travis.yml |   0
 rust/{tvm => frontend}/Cargo.toml  |  12 +-
 rust/{tvm => frontend}/README.md   |   0
 .../examples/resnet/Cargo.toml |   0
 rust/{tvm => frontend}/examples/resnet/README.md   |   0
 rust/{tvm => frontend}/examples/resnet/build.rs|   0
 .../examples/resnet/src/build_resnet.py|   0
 rust/{tvm => frontend}/examples/resnet/src/main.rs |   0
 rust/frontend/src/context.rs   | 330 +++
 rust/{tvm-rt => frontend}/src/errors.rs|  22 +-
 rust/frontend/src/function.rs  | 462 +
 rust/{tvm-rt => frontend}/src/lib.rs   |  32 +-
 rust/{tvm-rt => frontend}/src/module.rs|  45 +-
 rust/{tvm-rt => frontend}/src/ndarray.rs   |  90 ++--
 rust/frontend/src/value.rs | 166 
 rust/{tvm => frontend}/tests/basics/.gitignore |   0
 rust/{tvm => frontend}/tests/basics/Cargo.toml |   2 +-
 rust/{tvm => frontend}/tests/basics/build.rs   |   0
 rust/{tvm => frontend}/tests/basics/src/main.rs|   0
 rust/{tvm => frontend}/tests/basics/src/tvm_add.py |   0
 rust/{tvm => frontend}/tests/callback/Cargo.toml   |   2 +-
 .../tests/callback/src/bin/array.rs|   0
 .../tests/callback/src/bin/error.rs|   0
 .../tests/callback/src/bin/float.rs|   0
 .../tests/callback/src/bin/int.rs  |   0
 .../tests/callback/src/bin/string.rs   |   0
 rust/graph-runtime/.travis.yml |  22 -
 rust/macros/Cargo.toml |   4 +-
 rust/macros/src/import_module.rs   | 133 --
 rust/macros/src/lib.rs | 124 +-
 rust/macros/src/object.rs  | 171 
 rust/out-of-tree/Cargo.toml|  16 -
 rust/out-of-tree/import_pass.py|  41 --
 rust/out-of-tree/src/lib.rs|  60 ---
 rust/{tvm-rt => runtime}/.travis.yml   |   0
 rust/{graph-runtime => runtime}/Cargo.toml |   8 +-
 rust/{graph-runtime => runtime}/src/allocator.rs   |   0
 rust/{graph-runtime => runtime}/src/array.rs   |   4 +-
 rust/{graph-runtime => runtime}/src/errors.rs  |   0
 rust/{graph-runtime => runtime}/src/graph.rs   |   6 +-
 rust/{graph-runtime => runtime}/src/lib.rs |   5 +-
 rust/{graph-runtime => runtime}/src/module/dso.rs  |   4 +-
 rust/{graph-runtime => runtime}/src/module/mod.rs  |   4 +-
 .../src/module/syslib.rs   |   2 +-
 rust/{graph-runtime => runtime}/src/

[incubator-tvm] branch rust-tvm-sys updated (5662f8e -> dd2bcd0)

2020-05-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm-sys
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard 5662f8e  Add tvm-sys
 add 12e737f  Make "none" DataType explicit (#5491)
 add 3f33b25  [Hexagon] Change "scalar" and "stack" in IDL from "inrout" to 
"in" (#5487)
 add 967d731  [MXNET]broadcast and logical op support (#5461)
 add 9c1e74c  [REFACTOR][BOYC] Non recursive partitioning (#5493)
 add 360027d  Link necessary libraries when building runtime for Android 
(#5496)
 add 8599f7c  [TFLite] Model importer to be compatible with tflite 2.1.0 
(#5497)
 add c7a16d8  [Rust] Fixes for wasm32 target (#5489)
 add 6347406  [uTVM] Reset target and wait for runtime initialization on 
connect. (#5499)
 add 0abf581  bump tophub rocm version (#5504)
 add 6bbab4c  Fix Canonical Simplifier (#5505)
 add 7e88030  [RUST][RUNTIME] Fix workspace (#5503)
 add 95e06b3  [REFACTOR][RPC][PROCOTOL-CHANGE] Modularize the RPC infra 
(#5484)
 add 70a5902  [RPC] Call sync in remote cpu to gpu copies (#5512)
 add 32a094c  [QNN] Support CallNode inputs in qnn.concatenate (#5360)
 add 4c9724d  [RPC][BUGFIX][BACKPORT-0.6] Fix bug in rpc ring buffer shrink 
(#5516)
 add 7cbc0ca  [PATCH] [ring_buffer.h] Improve commentary for RingBuffer 
(#5518)
 add 16cb571  [TFLITE]Nit: Function names made consitent (#5515)
 add 7eb2451  fix prelu importer and add tests: (#5521)
 add dd2bcd0  Add tvm-sys

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5662f8e)
\
 N -- N -- N   refs/heads/rust-tvm-sys (dd2bcd0)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 .gitignore |3 +-
 3rdparty/dmlc-core |2 +-
 CMakeLists.txt |   26 +-
 apps/cpp_rpc/rpc_server.cc |   20 +-
 apps/cpp_rpc/rpc_tracker_client.h  |2 +-
 cmake/modules/Hexagon.cmake|6 +-
 golang/sample/gen_mobilenet_lib.py |8 +-
 include/tvm/runtime/c_runtime_api.h|   48 +
 include/tvm/runtime/data_type.h|   20 +-
 include/tvm/runtime/device_api.h   |   10 +-
 .../java/org/apache/tvm/contrib/GraphRuntime.java  |   53 +-
 .../src/main/java/org/apache/tvm/rpc/Client.java   |2 +-
 .../java/org/apache/tvm/rpc/NativeServerLoop.java  |2 +-
 .../main/java/org/apache/tvm/rpc/RPCSession.java   |4 +-
 python/tvm/_ffi/_ctypes/packed_func.py |8 +-
 python/tvm/_ffi/_cython/packed_func.pxi|8 +-
 python/tvm/_ffi/base.py|1 -
 python/tvm/autotvm/tophub.py   |2 +-
 python/tvm/contrib/cc.py   |   10 +-
 python/tvm/contrib/graph_runtime.py|9 +-
 python/tvm/error.py|5 +
 python/tvm/relay/frontend/mxnet.py |   37 +-
 python/tvm/relay/frontend/onnx.py  |7 +-
 python/tvm/relay/frontend/tflite.py|   38 +-
 python/tvm/relay/qnn/op/qnn.py |   13 +-
 python/tvm/rpc/__init__.py |4 +-
 python/tvm/{ir => rpc}/_ffi_api.py |4 +-
 python/tvm/rpc/base.py |7 -
 python/tvm/rpc/client.py   |  108 +-
 python/tvm/rpc/minrpc.py   |   86 ++
 python/tvm/rpc/proxy.py|3 +-
 python/tvm/rpc/server.py   |7 +-
 python/tvm/runtime/module.py   |6 +-
 rust/Cargo.toml|1 +
 rust/common/build.rs   |1 +
 rust/common/src/array.rs   |1 +
 rust/common/src/lib.rs |9 +-
 rust/runtime/src/array.rs  |1 +
 rust/runtime/src/graph.rs  |   13 +-
 rust/runtime/src/module/mod.rs |   12 +-
 rust/runtime/src/threading.rs  |9 +-
 rust/runtime/src/workspace.rs  |   10 +-
 rust/runtim

[incubator-tvm] branch rust-tvm-rt created (now d8d3147)

2020-05-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm-rt
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at d8d3147  Add tvm-rt

This branch includes the following new commits:

 new d8d3147  Add tvm-rt

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[incubator-tvm] 01/01: Fix up the final pieces

2020-03-21 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-stablize
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 5939ce700ca24f10dab71fa0d0c5fab19fd2be4f
Author: Jared Roesch 
AuthorDate: Sat Mar 21 22:30:29 2020 -0700

Fix up the final pieces
---
 rust/Cargo.toml   |   1 -
 rust/frontend/tests/callback/Cargo.toml   |   1 +
 rust/frontend/tests/callback/src/bin/error.rs |   5 +-
 rust/macros/Cargo.toml|   9 +-
 rust/macros/src/lib.rs| 123 --
 rust/macros_raw/Cargo.toml|  36 ---
 rust/macros_raw/src/lib.rs| 141 --
 rust/runtime/tests/test_nn/build.rs   |   3 +-
 rust/runtime/tests/test_tvm_basic/build.rs|  16 ++-
 rust/runtime/tests/test_tvm_basic/src/main.rs |   2 +-
 10 files changed, 141 insertions(+), 196 deletions(-)

diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 190a6eb..8467f6a 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -19,7 +19,6 @@
 members = [
"common",
"macros",
-   "macros_raw",
"runtime",
"runtime/tests/test_tvm_basic",
"runtime/tests/test_tvm_dso",
diff --git a/rust/frontend/tests/callback/Cargo.toml 
b/rust/frontend/tests/callback/Cargo.toml
index a452572..dfe80cc 100644
--- a/rust/frontend/tests/callback/Cargo.toml
+++ b/rust/frontend/tests/callback/Cargo.toml
@@ -19,6 +19,7 @@
 name = "callback"
 version = "0.0.0"
 authors = ["TVM Contributors"]
+edition = "2018"
 
 [dependencies]
 ndarray = "0.12"
diff --git a/rust/frontend/tests/callback/src/bin/error.rs 
b/rust/frontend/tests/callback/src/bin/error.rs
index 29bfd9a..c9f9a6f 100644
--- a/rust/frontend/tests/callback/src/bin/error.rs
+++ b/rust/frontend/tests/callback/src/bin/error.rs
@@ -19,10 +19,7 @@
 
 use std::panic;
 
-#[macro_use]
-extern crate tvm_frontend as tvm;
-
-use tvm::{errors::Error, *};
+use tvm_frontend::{errors::Error, *};
 
 fn main() {
 register_global_func! {
diff --git a/rust/macros/Cargo.toml b/rust/macros/Cargo.toml
index ff4f7d8..784b35e 100644
--- a/rust/macros/Cargo.toml
+++ b/rust/macros/Cargo.toml
@@ -19,13 +19,18 @@
 name = "tvm-macros"
 version = "0.1.1"
 license = "Apache-2.0"
-description = "Proc macros used by the TVM crates."
+description = "Procedural macros of the TVM crate."
 repository = "https://github.com/apache/incubator-tvm;
 readme = "README.md"
 keywords = ["tvm"]
 authors = ["TVM Contributors"]
 edition = "2018"
 
+[lib]
+proc-macro = true
 
 [dependencies]
-tvm-macros-raw = { path = "../macros_raw" }
+goblin = "0.0.24"
+proc-macro2 = "^1.0"
+quote = "1.0"
+syn = "1.0"
diff --git a/rust/macros/src/lib.rs b/rust/macros/src/lib.rs
index efd85d0..d1d86b6 100644
--- a/rust/macros/src/lib.rs
+++ b/rust/macros/src/lib.rs
@@ -17,12 +17,123 @@
  * under the License.
  */
 
-#[macro_use]
-extern crate tvm_macros_raw;
+extern crate proc_macro;
 
-#[macro_export]
-macro_rules! import_module {
-($module_path:literal) => {
-$crate::import_module_raw!(file!(), $module_path);
+use std::{fs::File, io::Read};
+use syn::parse::{Parse, ParseStream, Result};
+use syn::{LitStr};
+use quote::quote;
+
+use std::path::PathBuf;
+
+struct ImportModule {
+importing_file: LitStr,
+}
+
+impl Parse for ImportModule {
+fn parse(input: ParseStream) -> Result {
+let importing_file: LitStr = input.parse()?;
+Ok(ImportModule {
+importing_file,
+})
+}
+}
+
+#[proc_macro]
+pub fn import_module(input: proc_macro::TokenStream) -> 
proc_macro::TokenStream {
+let import_module_args = syn::parse_macro_input!(input as ImportModule);
+
+let manifest = std::env::var("CARGO_MANIFEST_DIR")
+.expect("variable should always be set by Cargo.");
+
+let mut path = PathBuf::new();
+path.push(manifest);
+path = path.join(import_module_args.importing_file.value());
+
+let mut fd = File::open()
+.unwrap_or_else(|_| panic!("Unable to find TVM object file at `{}`", 
path.display()));
+let mut buffer = Vec::new();
+fd.read_to_end( buffer).unwrap();
+
+let fn_names = match goblin::Object::parse().unwrap() {
+goblin::Object::Elf(elf) => elf
+.syms
+.iter()
+.filter_map(|s| {
+if s.st_type() == 0 || 
goblin::elf::sym::type_to_str(s.st_type()) == "FILE" {
+return None;
+}
+match elf.strtab.get(s.st_name) {
+Some(Ok(name)) if name != "" => {
+  

[incubator-tvm] branch rust-stablize created (now 5939ce7)

2020-03-21 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-stablize
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at 5939ce7  Fix up the final pieces

This branch includes the following new commits:

 new 5939ce7  Fix up the final pieces

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[incubator-tvm] branch master updated (a6de507 -> e6dd8e1)

2020-03-24 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from a6de507  Change Rust version to stable in Docker (#5138)
 add e6dd8e1  [Relay] GradientCell Relay Pass (#5039)

No new revisions were added by this update.

Summary of changes:
 include/tvm/ir/module.h|   8 +
 include/tvm/relay/transform.h  |  14 +
 .../tvm/relay/std/gradient.rly |  48 ++-
 python/tvm/relay/transform/transform.py|  13 +
 src/ir/module.cc   |  12 +
 src/relay/transforms/lazy_gradient_init.cc | 317 +
 tests/python/relay/test_ir_parser.py   |   5 +-
 tests/python/relay/test_pass_lazy_gradient_init.py | 395 +
 8 files changed, 794 insertions(+), 18 deletions(-)
 copy tests/cpp/simple_passes_test.cc => python/tvm/relay/std/gradient.rly (50%)
 create mode 100644 src/relay/transforms/lazy_gradient_init.cc
 create mode 100644 tests/python/relay/test_pass_lazy_gradient_init.py



[incubator-tvm] branch master updated (e6dd8e1 -> 667e24f)

2020-03-24 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from e6dd8e1  [Relay] GradientCell Relay Pass (#5039)
 add 667e24f  [CI] Update rust docker (#5141)

No new revisions were added by this update.

Summary of changes:
 Jenkinsfile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)



[incubator-tvm] branch master updated (b4ee81d -> 19f322d)

2020-05-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from b4ee81d  [RPC][BUGFIX] Fix remote device sync (#5538)
 add 19f322d  [Refactor][std::string --> String] IRModule is updated with 
String (#5523)

No new revisions were added by this update.

Summary of changes:
 include/tvm/ir/module.h   | 34 +-
 src/ir/module.cc  | 34 +-
 src/printer/relay_text_printer.cc | 16 +++-
 3 files changed, 45 insertions(+), 39 deletions(-)



[incubator-tvm] branch master updated: [Rust] Add first stage of updating and rewriting Rust bindings. (#5526)

2020-05-08 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new aded92d  [Rust] Add first stage of updating and rewriting Rust 
bindings. (#5526)
aded92d is described below

commit aded92d3ba2d3a097425774d0890d07a9350e1bc
Author: Jared Roesch 
AuthorDate: Fri May 8 16:53:47 2020 -0700

[Rust] Add first stage of updating and rewriting Rust bindings. (#5526)

* Add tvm-sys

* Use as_mut_ptr

* Address CR feedback

* Update rust/tvm-sys/src/datatype.rs

Co-authored-by: Nick Hynes 

* Final CR comments

* Fix find and replace error in frontend

Co-authored-by: Nick Hynes 
---
 rust/.rustfmt.toml  |   1 +
 rust/Cargo.toml |   3 +-
 rust/{ => tvm-sys}/Cargo.toml   |  32 ++--
 rust/tvm-sys/build.rs   |  61 +++
 rust/tvm-sys/src/array.rs   |  62 +++
 rust/tvm-sys/src/byte_array.rs  |  87 +
 rust/tvm-sys/src/context.rs | 284 ++
 rust/tvm-sys/src/datatype.rs| 187 
 rust/tvm-sys/src/errors.rs  |  46 +
 rust/tvm-sys/src/lib.rs |  54 ++
 rust/tvm-sys/src/packed_func.rs | 380 
 rust/tvm-sys/src/value.rs   |  95 ++
 12 files changed, 1277 insertions(+), 15 deletions(-)

diff --git a/rust/.rustfmt.toml b/rust/.rustfmt.toml
index 3c51bb3..5a1f1d2 100644
--- a/rust/.rustfmt.toml
+++ b/rust/.rustfmt.toml
@@ -29,3 +29,4 @@ merge_derives = true
 use_try_shorthand = false
 use_field_init_shorthand = false
 force_explicit_abi = true
+
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index f08f861..b4a159c 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -27,5 +27,6 @@ members = [
"frontend",
"frontend/tests/basics",
"frontend/tests/callback",
-   "frontend/examples/resnet"
+   "frontend/examples/resnet",
+"tvm-sys"
 ]
diff --git a/rust/Cargo.toml b/rust/tvm-sys/Cargo.toml
similarity index 74%
copy from rust/Cargo.toml
copy to rust/tvm-sys/Cargo.toml
index f08f861..fe4d0bf 100644
--- a/rust/Cargo.toml
+++ b/rust/tvm-sys/Cargo.toml
@@ -15,17 +15,21 @@
 # specific language governing permissions and limitations
 # under the License.
 
-[workspace]
-members = [
-   "common",
-   "macros",
-   "runtime",
-   "runtime/tests/test_tvm_basic",
-   "runtime/tests/test_tvm_dso",
-   "runtime/tests/test_wasm32",
-   "runtime/tests/test_nn",
-   "frontend",
-   "frontend/tests/basics",
-   "frontend/tests/callback",
-   "frontend/examples/resnet"
-]
+[package]
+name = "tvm-sys"
+version = "0.1.0"
+authors = ["TVM Contributors"]
+license = "Apache-2.0"
+edition = "2018"
+
+[features]
+bindings = []
+
+[dependencies]
+thiserror = "^1.0"
+anyhow = "^1.0"
+ndarray = "0.12"
+enumn = "^0.1"
+
+[build-dependencies]
+bindgen = "0.51"
diff --git a/rust/tvm-sys/build.rs b/rust/tvm-sys/build.rs
new file mode 100644
index 000..85e16be
--- /dev/null
+++ b/rust/tvm-sys/build.rs
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+extern crate bindgen;
+
+use std::path::PathBuf;
+
+use std::env;
+
+fn main() {
+let tvm_home = option_env!("TVM_HOME").map(str::to_string).unwrap_or({
+let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
+.canonicalize()
+.unwrap();
+crate_dir
+.parent()
+.unwrap()
+.parent()
+.unwrap()
+.to_str()
+.unwrap()
+.to_string()
+});
+
+if cfg!(feature = "bindings") {
+println!("cargo:rerun-if-env-changed=TVM_HOME");
+println!("cargo:r

[incubator-tvm] branch ci-docker-staging updated (b8f37ee -> 39c1f56)

2020-09-11 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from b8f37ee  [BYOC][JSON] Support input nodes with multiple entries (#6368)
 add 4fc320a  [Relay] support i64 indices (#6143)
 add 9a42cb6  add missing dependency (#6375)
 add 6ed242e  [Relay] Enhance relay.split(), allow splitted dim to be 
dynamic (#6289)
 add bbcecc9  acquire gil while finalizing PackedFunc (#6378)
 add c0cbc11  [Torch] Support logsumexp, clean up unnecessary infer_shape 
usage (#6374)
 add dd9282f  [RUNTIME][CRT] use macro to replace hardcode number (#6365)
 add 693c0de  [RELAY] Fix the FoldConstant Regression for VTA (#6377)
 add b235e59  [TESTS] Refactor tests to run on either the GPU or CPU. 
(#6331)
 add 19de625  Make docs build again when not everything is enabled (#6386)
 add 6770d28  [Frontend][TensorFlow] Improve TensorFlow control flow nodes 
ordering (#6387)
 add 237b4c1  [TFLite] Support for 'SAME' Padding option for TRANSPOSE_CONV 
operator of TFLite. (#6381)
 add 12d66d4  [DOCS] Fix the docker binary cache location (#6390)
 add 1224d56  [RELAY][VM] Enable heterogeneous execution for Relay VM 
(#6337)
 add 5262765  [Bugfix][Printer] Avoid adding annotation twice for 
ConstantNode (#6364)
 add 17d39fb  [Relay] Fix Type Arguments not Attached (#6385)
 add af69e1c  [CI][Contrib] Add Vitis-AI docker installation (#6342)
 add a2db689  [METAL] Use CFBridgeRetain for retaining the allocated 
resource (#6393)
 add 86fa81c  [RELAY][DYN] Dynamic UpSampling3D Op (#6353)
 add 8508ec3  [Relay/topi] Support scalar inputs in where op (#6383)
 add e382b16  Remove unintentional pytest dependency. Fix #6398 (#6399)
 add 73d9e01  Add safe up/downcasting to the Rust object system (#6384)
 add 3451ccb  [VTA][Xilinx] Update to Vivado 2020.1 and Pynq 2.5 (#6402)
 add 9aa69e2  [TARGET] Add layout_transform, clip and expand_dims in onnx 
converter (#6366)
 add 3004285  [Fix] fix compilation error when setting USE_RELAY_DEBUG 
(#6380)
 add 4b48d89  iadd conv2d_transpose alter layout (#6358)
 add 656b4c5  reshape with non constant shape argument (#6411)
 add 7f7df05  [ONNX] Add Clip importer to handle when min/max are provided 
as inputs. (#6251)
 add d08eb9a  [TESTING] Fix the error when running tests with default 
targets (#6394)
 add 9f2a90b  bugfix: "verify" call parameter name changed (#6382)
 add 6f8e875  [Torch] Miscellaneous fix, enable some VM GPU tests (#6418)
 add 14f0042  [TFLite] Implemented MATRIX_DIAG Operator for TFLite. (#6397)
 add 718a9a7  Remove comparison of unsigned expression < 0 warning (#6319)
 add eee413f  Dynamic Strided Slice (#6316)
 add 84fa626  [AutoTVM][Ansor] Enable random fill and CPU cache flush for 
AutoTVM and Ansor (#6391)
 add 82c1c73  [PASS][ConvertLayout] Fixes AttributeError during 
ConvertLayout to NHWC (#6419)
 add 8499d58  [Ansor][AutoTVM v2.0] Phase 2: Layout Rewrite in 
AutoScheduler (#6297)
 add 50adbfa  [RELAY][REFACTOR] Mix mode context analysis (#6403)
 add 502f79d  Switch Windows CI to build Release instead of Debug (#6427)
 add 97ab77e  [RELAY] Allow StructuralEqual/Hash via Var.vid (#6424)
 add 29cf2e0  Address issue #6415 using compiler-rt half-float function. 
(#6431)
 add fdef79d  hot fix (#6434)
 add 8705cea  [Relay, Torch] Fix stack op axis check, support torch::stack 
conversion for a static list  (#6433)
 add 3a4e61a  [METAL] set MTLBuffer purgeable state (#6376) (#6438)
 add b05aa96  [Rust] Improve the error reporting in build.rs files by using 
anyhow. (#6401)
 add 6b6661e  [Target] Tags, Composite Target, Unified Interface (#6369)
 add e6374dc  Fix broadcast shape (#6422)
 add b81bdee  [Relay] Add Defunctionalization Pass  (#6400)
 add aeef16d  [QNN][Relay] Fixed bug in quantized conv2d. (#6420)
 add ecba2f3  [Relay][Op] Fix Reshape Compute (#6396)
 add 355720e  CUDA: broaden path detection (#6444)
 add 1228111  [Relay][Topi][Op]Advanced indexing (#6388)
 add 01460e0  ROCm: use GcnArch for mcpu and ApiVersion to select code 
object version (#6447)
 add 2d6f471  Add black to lint docker image
 new 39c1f56  Update tag

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/main.yml |  10 +-
 .gitignore |   3 +
 3rdparty/vta-hw|   2 +-
 CMakeLists.txt |   5 +
 Jenkinsfile|   3 +-
 apps/benchmark/gpu_imagenet_benc

[incubator-tvm] 01/01: Update tag

2020-09-11 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 39c1f5629419318dfb8fa9672fd779ea95d68045
Author: Jared Roesch 
AuthorDate: Fri Sep 11 11:43:50 2020 -0700

Update tag
---
 Jenkinsfile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 3ce5b60..aeac271 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -44,7 +44,8 @@
 //
 
 // NOTE: these lines are scanned by docker/dev_common.sh. Please update the 
regex as needed. -->
-ci_lint = "tlcpack/ci-lint:v0.61"
+// ci_lint = "tlcpack/ci-lint:v0.61"
+ci_lint = "tlcpack/ci-lint:v0.62.d31cc37f8568-t0"
 ci_gpu = "tlcpack/ci-gpu:v0.64"
 ci_cpu = "tlcpack/ci-cpu:v0.65"
 ci_wasm = "tlcpack/ci-wasm:v0.60"



[incubator-tvm] branch master updated (e382b16 -> 73d9e01)

2020-09-04 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from e382b16  Remove unintentional pytest dependency. Fix #6398 (#6399)
 add 73d9e01  Add safe up/downcasting to the Rust object system (#6384)

No new revisions were added by this update.

Summary of changes:
 rust/tvm-macros/src/object.rs| 119 +--
 rust/tvm-macros/src/util.rs  |  18 ++
 rust/tvm-rt/src/array.rs |   7 +--
 rust/tvm-rt/src/map.rs   |   9 +--
 rust/tvm-rt/src/object/mod.rs| 110 +---
 rust/tvm-rt/src/object/object_ptr.rs |  62 --
 rust/tvm-rt/src/string.rs|  25 +++-
 rust/tvm/src/ir/mod.rs   |   2 +-
 rust/tvm/src/ir/relay/mod.rs |   2 +-
 rust/tvm/src/ir/tir.rs   |  14 +
 10 files changed, 178 insertions(+), 190 deletions(-)



[incubator-tvm] branch master updated: upstream (#6436)

2020-09-11 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new 9b0e37a  upstream (#6436)
9b0e37a is described below

commit 9b0e37a42de0f4cb0efcaa907bfa54d61f1c3faf
Author: 雾雨魔理沙 
AuthorDate: Fri Sep 11 17:00:50 2020 -0700

upstream (#6436)
---
 src/relay/transforms/fold_constant.cc | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/relay/transforms/fold_constant.cc 
b/src/relay/transforms/fold_constant.cc
index 0a1f173..a3f2f69 100644
--- a/src/relay/transforms/fold_constant.cc
+++ b/src/relay/transforms/fold_constant.cc
@@ -105,7 +105,23 @@ class ConstantFolder : public ExprMutator {
 }
   }
 
+  bool inside_primitive = false;
+  Expr VisitExpr_(const FunctionNode* op) final {
+if (op->HasNonzeroAttr(attr::kPrimitive)) {
+  CHECK_EQ(inside_primitive, false);
+  inside_primitive = true;
+  auto ret = ExprMutator::VisitExpr_(op);
+  inside_primitive = false;
+  return ret;
+} else {
+  return ExprMutator::VisitExpr_(op);
+}
+  }
+
   Expr VisitExpr_(const CallNode* call) final {
+if (inside_primitive) {
+  return GetRef(call);
+}
 static auto op_stateful = Op::GetAttrMap("TOpIsStateful");
 
 std::unordered_set skip_list{"zeros_like", "ones_like", 
"full_like", "full"};



[incubator-tvm] 01/05: Fix documentation comment

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 2952d3cd752f3fefc6d983e565cffa09cde5d845
Author: Jared Roesch 
AuthorDate: Mon Oct 5 14:09:46 2020 -0700

Fix documentation comment
---
 include/tvm/ir/type.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/tvm/ir/type.h b/include/tvm/ir/type.h
index b7a60b3..8fce9fa 100644
--- a/include/tvm/ir/type.h
+++ b/include/tvm/ir/type.h
@@ -300,6 +300,7 @@ class GlobalTypeVar : public Type {
* \brief Constructor
* \param name_hint The name of the type var.
* \param kind The kind of the type var.
+   * \param span The span of the type.
*/
   TVM_DLL GlobalTypeVar(String name_hint, TypeKind kind, Span span = Span());
 
@@ -341,6 +342,7 @@ class TupleType : public Type {
   /*!
* \brief Constructor
* \param fields Fields in the tuple.
+   * \param span The span of the type.
*/
   TVM_DLL explicit TupleType(Array fields, Span span = Span());
 
@@ -448,6 +450,7 @@ class FuncType : public Type {
* \param ret_type The type of the return value.
* \param type_params The type parameters.
* \param type_constraints The type constraints.
+   * \param span The span information.
* \sa FuncTypeNode for more docs about these fields.
*/
   TVM_DLL FuncType(Array arg_types, Type ret_type, Array 
type_params,



[incubator-tvm] 02/05: Kill dead doc comment

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 7ae6990c5bba3f95f148f93f4a2db84f39baf204
Author: Jared Roesch 
AuthorDate: Mon Oct 5 13:58:28 2020 -0700

Kill dead doc comment
---
 include/tvm/ir/diagnostic.h | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/include/tvm/ir/diagnostic.h b/include/tvm/ir/diagnostic.h
index e6a7232..6b98074 100644
--- a/include/tvm/ir/diagnostic.h
+++ b/include/tvm/ir/diagnostic.h
@@ -129,17 +129,6 @@ class Diagnostic : public ObjectRef {
 
 /*!
  * \brief A wrapper around std::stringstream to build a diagnostic.
- *
- * \code
- *
- * void ReportError(const Error& err);
- *
- * void Test(int number) {
- *   // Use error reporter to construct an error.
- *   ReportError(ErrorBuilder() << "This is an error number=" << number);
- * }
- *
- * \endcode
  */
 class DiagnosticBuilder {
  public:



[incubator-tvm] 04/05: Merge branch 'master' of https://github.com/apache/incubator-tvm

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 9ea627bd387ed9a6eb8ff64116a68ce3ffb8af18
Merge: 44a785c 0cfda17
Author: Jared Roesch 
AuthorDate: Tue Oct 6 22:57:23 2020 -0700

Merge branch 'master' of https://github.com/apache/incubator-tvm

 CONTRIBUTORS.md|   1 +
 Jenkinsfile|   2 +-
 include/tvm/relay/adt.h|   1 +
 include/tvm/relay/attrs/nn.h   |  12 +-
 include/tvm/runtime/ndarray.h  |   3 +-
 include/tvm/runtime/object.h   |   6 +-
 include/tvm/tir/data_layout.h  |   3 +
 include/tvm/topi/nn/batch_matmul.h |  67 ---
 python/tvm/autotvm/tuner/tuner.py  |  17 +
 python/tvm/driver/tvmc/main.py |   5 +-
 python/tvm/relay/frontend/onnx.py  |   9 -
 python/tvm/relay/op/strategy/arm_cpu.py|  44 +-
 python/tvm/topi/arm_cpu/arm_utils.py   | 100 +
 python/tvm/topi/arm_cpu/conv2d_alter_op.py | 105 +++--
 python/tvm/topi/arm_cpu/conv2d_gemm.py | 283 
 python/tvm/topi/arm_cpu/conv2d_int8.py | 120 -
 python/tvm/topi/arm_cpu/tensor_intrin.py   | 298 +++-
 python/tvm/topi/nn/batch_matmul.py |  28 +-
 python/tvm/topi/testing/batch_matmul.py|   7 +-
 python/tvm/topi/x86/batch_matmul.py|  10 +-
 rust/tvm-graph-rt/src/graph.rs |   8 +-
 rust/tvm-graph-rt/src/threading.rs |   4 +-
 rust/tvm-macros/Cargo.toml |   1 +
 rust/tvm-rt/Cargo.toml |   1 +
 rust/tvm-rt/src/array.rs   |  17 +
 rust/tvm-rt/src/errors.rs  |   2 -
 rust/tvm-rt/src/ndarray.rs | 322 +++--
 rust/tvm-rt/src/object/object_ptr.rs   |  72 +--
 rust/tvm-rt/src/string.rs  |   4 +-
 rust/tvm-rt/src/value.rs   |  56 +--
 rust/tvm-sys/src/packed_func.rs|  15 +
 rust/tvm/Cargo.toml|   4 +
 rust/tvm/examples/resnet/Cargo.toml|   3 +-
 rust/tvm/examples/resnet/build.rs  |  10 +-
 rust/tvm/examples/resnet/src/build_resnet.py   |  95 ++--
 rust/tvm/examples/resnet/src/main.rs   | 130 +++---
 rust/tvm/src/ir/arith.rs   |   2 +-
 rust/tvm/src/{runtime/mod.rs => ir/attrs.rs}   |  11 +-
 rust/tvm/src/ir/{mod.rs => expr.rs}|  66 ++-
 rust/tvm/src/{runtime/mod.rs => ir/function.rs}|  28 +-
 rust/tvm/src/ir/mod.rs |  62 +--
 rust/tvm/src/ir/module.rs  | 159 +++
 rust/tvm/src/{runtime/mod.rs => ir/op.rs}  |  25 +-
 rust/tvm/src/{runtime => ir/relay/attrs}/mod.rs|   3 +-
 rust/tvm/src/ir/relay/attrs/nn.rs  |  96 
 .../mod.rs => ir/relay/attrs/transform.rs} |  13 +-
 rust/tvm/src/ir/relay/mod.rs   | 499 +
 rust/tvm/src/{runtime/mod.rs => ir/span.rs}|   4 +-
 rust/tvm/src/ir/tir.rs |   4 +-
 rust/tvm/src/ir/ty.rs  | 242 ++
 rust/tvm/src/lib.rs|   2 +
 rust/tvm/src/python.rs |  60 +++
 rust/tvm/src/runtime/graph_rt.rs   |  97 
 rust/tvm/src/runtime/mod.rs|   2 +
 rust/tvm/tests/basics/src/main.rs  |   4 +-
 rust/tvm/tests/callback/src/bin/array.rs   |  19 +-
 src/relay/op/nn/convolution.cc |   4 +-
 src/relay/op/nn/nn.cc  |   6 +-
 src/relay/qnn/op/convolution.cc|   6 +-
 src/relay/transforms/combine_parallel_conv2d.cc|   3 +-
 src/relay/transforms/pattern_util.h|   2 +-
 src/relay/transforms/transform_layout.h|   2 +-
 src/runtime/ndarray.cc |   5 +-
 src/topi/nn.cc |   6 -
 tests/python/frontend/onnx/test_forward.py |   1 -
 tests/python/relay/test_pass_alter_op_layout.py|  91 +++-
 tests/python/topi/python/test_topi_batch_matmul.py |  21 +-
 tests/python/topi/python/test_topi_conv2d_int8.py  | 105 +++--
 tests/scripts/task_cpp_unittest.sh |   3 +
 tests/scripts/task_python_docs.sh  |   9 +
 tests/scripts/task_rust.sh |  13 +-
 71 files changed, 2670 insertions(+), 870 deletions(-)




[incubator-tvm] 03/05: Fix rebase issues

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 44a785c83b4550fee7c0261b1f6fa57988d43f2f
Author: Jared Roesch 
AuthorDate: Mon Oct 5 14:20:08 2020 -0700

Fix rebase issues
---
 src/relay/op/nn/convolution.h  | 4 
 src/runtime/contrib/random/mt_random_engine.cc | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/relay/op/nn/convolution.h b/src/relay/op/nn/convolution.h
index 8a6c308..e7a5b13 100644
--- a/src/relay/op/nn/convolution.h
+++ b/src/relay/op/nn/convolution.h
@@ -362,13 +362,17 @@ bool Conv3DRel(const Array& types, int num_inputs, 
const Attrs& attrs,
   << "Conv3D: shape of weight is inconsistent with kernel_size, "
   << " kernel_size=" << param->kernel_size << " wshape=" << wshape;
 }
+
 if (param->channels.defined()) {
   CHECK(reporter->AssertEQ(param->channels, wshape[0]))
   << "Conv3D: shape of weight is inconsistent with channels, "
   << " channels=" << param->channels << " wshape=" << wshape;
 }
+
 if (!dshape_ncdhw[1].as() && !wshape[1].as()) {
   CHECK(reporter->AssertEQ(indexdiv(dshape_ncdhw[1], param->groups), 
wshape[1]));
+}
+
 channels = wshape[0];
 dilated_ksize_z = 1 + (wshape[2] - 1) * param->dilation[0];
 dilated_ksize_y = 1 + (wshape[3] - 1) * param->dilation[1];
diff --git a/src/runtime/contrib/random/mt_random_engine.cc 
b/src/runtime/contrib/random/mt_random_engine.cc
index 8a4ee9a..8c20f07 100644
--- a/src/runtime/contrib/random/mt_random_engine.cc
+++ b/src/runtime/contrib/random/mt_random_engine.cc
@@ -42,7 +42,7 @@ class RandomEngine {
   /*!
* \brief Creates a RandomEngine using a default seed.
*/
-  RandomEngine() { this->Seed(time(0)); }
+  RandomEngine() { this->Seed(time(nullptr)); }
 
   /*!
* \brief Creates a RandomEngine, suggesting the use of a provided seed.



[incubator-tvm] 05/05: Turn on Rust docs and MxNet based ResNet

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit d4001e5c8c88bc17b7e05867dc966cf267bdaf5c
Author: Jared Roesch 
AuthorDate: Tue Oct 6 23:00:46 2020 -0700

Turn on Rust docs and MxNet based ResNet
---
 Jenkinsfile  |  4 ++--
 docker/install/ubuntu_install_darknet.sh |  7 ++-
 tests/scripts/task_python_docs.sh| 11 ---
 tests/scripts/task_rust.sh   |  6 ++
 4 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index b44aa2a..f8dabf2 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -45,8 +45,8 @@
 
 // NOTE: these lines are scanned by docker/dev_common.sh. Please update the 
regex as needed. -->
 ci_lint = "tlcpack/ci-lint:v0.62"
-ci_gpu = "tlcpack/ci-gpu:v0.64"
-ci_cpu = "tlcpack/ci-cpu:v0.66"
+ci_gpu = "tlcpack/ci-gpu:v0.65-t0"
+ci_cpu = "tlcpack/ci-cpu:v0.67-t0"
 ci_wasm = "tlcpack/ci-wasm:v0.60"
 ci_i386 = "tlcpack/ci-i386:v0.52"
 // <--- End of regex-scanned config.
diff --git a/docker/install/ubuntu_install_darknet.sh 
b/docker/install/ubuntu_install_darknet.sh
index c48724c..37adf4a 100755
--- a/docker/install/ubuntu_install_darknet.sh
+++ b/docker/install/ubuntu_install_darknet.sh
@@ -6,9 +6,9 @@
 # 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
@@ -23,7 +23,4 @@ set -o pipefail
 #install the necessary dependancies, cffi, opencv
 wget -q 
'https://github.com/siju-samuel/darknet/blob/master/lib/libdarknet.so?raw=true' 
-O libdarknet.so
 debian_version=`cat /etc/debian_version`
-if [ "$debian_version" == "stretch/sid" ]; then
-pip2 install opencv-python cffi
-fi
 pip3 install opencv-python cffi
diff --git a/tests/scripts/task_python_docs.sh 
b/tests/scripts/task_python_docs.sh
index 98dac93..71bb922 100755
--- a/tests/scripts/task_python_docs.sh
+++ b/tests/scripts/task_python_docs.sh
@@ -68,12 +68,10 @@ npm install
 npm run typedoc
 cd ..
 
-# TODO(@jroesch): add Rust to CI container
-# see: https://github.com/apache/incubator-tvm/issues/6628
 # Rust doc
-# cd rust
-# cargo doc --workspace --no-deps
-# cd ..
+cd rust
+cargo doc --workspace --no-deps
+cd ..
 
 # Prepare the doc dir
 rm -rf _docs
@@ -82,8 +80,7 @@ rm -f _docs/.buildinfo
 mkdir -p _docs/api
 mv docs/doxygen/html _docs/api/doxygen
 mv jvm/core/target/site/apidocs _docs/api/javadoc
-# See above TODO
-# mv rust/target/doc _docs/api/rust
+mv rust/target/doc _docs/api/rust
 mv web/dist/docs _docs/api/typedoc
 
 echo "Start creating the docs tarball.."
diff --git a/tests/scripts/task_rust.sh b/tests/scripts/task_rust.sh
index 18361fe..d60999c 100755
--- a/tests/scripts/task_rust.sh
+++ b/tests/scripts/task_rust.sh
@@ -110,8 +110,6 @@ cargo run --bin array
 cargo run --bin string
 cd -
 
-# TODO(@jroesch): we need to renable MxNet in ci-cpu image
-# https://github.com/apache/incubator-tvm/pull/6563
-# cd examples/resnet
-# cargo build
+cd examples/resnet
+cargo run
 cd -



[incubator-tvm] branch ci-docker-staging updated (f90cc57 -> d4001e5)

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard f90cc57  Build with USE_LLVM on to fix cpp unittests.
 discard 073bc6e  add QEMU build to regression
 add ed70dca  Refactor the type checker to use diagnostics
 add 9565d30  Apply suggestions from code review
 add dd0c616  Apply suggestions from code review
 add 2419435  Clean up parser
 add 1a5e328  CR feedback
 add 997692e  Apply Bobs suggestions
 add eaceca9  Fix up Python interface for diagnostics
 add d6bbc29  Fix test_ir_parser and formatting
 add d1a6bfe  Fix cpplint
 add e61d7e8  Fix lint
 add 328afd6  Fix format
 add f0f  More lint
 new 2952d3c  Fix documentation comment
 new 7ae6990  Kill dead doc comment
 new 44a785c  Fix rebase issues
 add 86122d1  [FIX,AUTOTVM] Print warning when all autotvm tasks fail with 
errors (#6612)
 add 311eca4  Fix a bug with Alter Op Layout (#6626)
 add feb041d  bump dockerfile (#6632)
 add 277bfc8  [Rust] Improve NDArray, GraphRt, and Relay bindings (#6563)
 add dec5030  Fix example code (#6627)
 add 82289ea  [TVMC] fail gracefully in case no subcommand is provided 
(#6625)
 add 8369adc  Add dot product support for quantized convolution. (#6445)
 add 889fac1  [Topi] Allow batch_matmul to broadcast along batch dimension. 
(#6616)
 add 35793ae  [COMMUNITY] areusch -> Reviewer (#6637)
 add 0cfda17  [CI] fix Python dependency required by cpp tests to work 
standalone (#6639)
 new 9ea627b  Merge branch 'master' of 
https://github.com/apache/incubator-tvm
 new d4001e5  Turn on Rust docs and MxNet based ResNet

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (f90cc57)
\
 N -- N -- N   refs/heads/ci-docker-staging (d4001e5)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CMakeLists.txt |   1 +
 CONTRIBUTORS.md|   1 +
 Jenkinsfile|  17 +-
 Makefile   |   5 +
 docker/install/ubuntu_install_darknet.sh   |   7 +-
 include/tvm/ir/diagnostic.h| 262 ++
 include/tvm/ir/module.h|  12 +-
 include/tvm/ir/span.h  |   2 +-
 include/tvm/ir/transform.h |  14 +-
 include/tvm/ir/type.h  |  15 +-
 include/tvm/ir/type_relation.h |  13 +-
 include/tvm/parser/parser.h|   3 +-
 include/tvm/parser/source_map.h|  69 +-
 include/tvm/relay/adt.h|   1 +
 include/tvm/relay/analysis.h   |   9 +-
 include/tvm/relay/attrs/nn.h   |  12 +-
 include/tvm/relay/transform.h  |  12 -
 include/tvm/runtime/container.h|  14 +
 include/tvm/runtime/ndarray.h  |   3 +-
 include/tvm/runtime/object.h   |   8 +-
 include/tvm/tir/data_layout.h  |   3 +
 include/tvm/tir/op.h   |   1 +
 include/tvm/topi/nn/batch_matmul.h |  67 --
 pyproject.toml |   2 +-
 python/tvm/__init__.py |   9 +-
 python/tvm/autotvm/tuner/tuner.py  |  17 +
 python/tvm/driver/tvmc/main.py |   5 +-
 python/tvm/ir/__init__.py  |   1 +
 python/tvm/ir/diagnostics/__init__.py  | 109 +++
 python/tvm/{arith => ir/diagnostics}/_ffi_api.py   |   4 +-
 python/tvm/ir/module.py|  16 +-
 python/tvm/parser/__init__.py  |  14 +-
 python/tvm/relay/backend/graph_runtime_factory.py  |   4 +-
 python/tvm/relay/backend/interpreter.py|   4 +-
 python/tvm/relay/build_module.py   |   2 +
 python/tvm/relay/dataflow_pattern/__init__.py  |   2 +-
 python/tvm/relay/fro

[incubator-tvm] branch ci-docker-staging updated (d4001e5 -> 2e52c67)

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard d4001e5  Turn on Rust docs and MxNet based ResNet
 discard 9ea627b  Merge branch 'master' of 
https://github.com/apache/incubator-tvm
 discard 44a785c  Fix rebase issues
 discard 7ae6990  Kill dead doc comment
 discard 2952d3c  Fix documentation comment
omit f0f  More lint
omit 328afd6  Fix format
omit e61d7e8  Fix lint
omit d1a6bfe  Fix cpplint
omit d6bbc29  Fix test_ir_parser and formatting
omit eaceca9  Fix up Python interface for diagnostics
omit 997692e  Apply Bobs suggestions
omit 1a5e328  CR feedback
omit 2419435  Clean up parser
omit dd0c616  Apply suggestions from code review
omit 9565d30  Apply suggestions from code review
omit ed70dca  Refactor the type checker to use diagnostics
 new 2e52c67  Turn on Rust docs and MxNet based ResNet

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d4001e5)
\
 N -- N -- N   refs/heads/ci-docker-staging (2e52c67)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CMakeLists.txt |   1 -
 Makefile   |   5 -
 include/tvm/ir/diagnostic.h| 262 --
 include/tvm/ir/module.h|  12 +-
 include/tvm/ir/span.h  |   2 +-
 include/tvm/ir/transform.h |  14 +-
 include/tvm/ir/type.h  |  15 +-
 include/tvm/ir/type_relation.h |  13 +-
 include/tvm/parser/parser.h|   3 +-
 include/tvm/parser/source_map.h|  69 +-
 include/tvm/relay/analysis.h   |   9 +-
 include/tvm/relay/transform.h  |  12 +
 include/tvm/runtime/container.h|  14 -
 include/tvm/runtime/object.h   |   2 +-
 include/tvm/tir/op.h   |   1 -
 pyproject.toml |   2 +-
 python/tvm/__init__.py |   9 +-
 python/tvm/ir/__init__.py  |   1 -
 python/tvm/ir/diagnostics/__init__.py  | 109 ---
 python/tvm/ir/diagnostics/_ffi_api.py  |  21 -
 python/tvm/ir/module.py|  16 +-
 python/tvm/parser/__init__.py  |  14 +-
 python/tvm/relay/backend/graph_runtime_factory.py  |   4 +-
 python/tvm/relay/backend/interpreter.py|   4 +-
 python/tvm/relay/build_module.py   |   2 -
 python/tvm/relay/dataflow_pattern/__init__.py  |   2 +-
 python/tvm/relay/prelude.py| 578 ++---
 .../tvm/relay/quantize/_partition_conversions.py   |   8 +-
 python/tvm/relay/quantize/quantize.py  |   2 +-
 python/tvm/relay/std/nat.rly   |  78 --
 python/tvm/relay/std/prelude.rly   |   5 +-
 python/tvm/relay/testing/__init__.py   |   3 +-
 python/tvm/relay/testing/nat.py| 149 +++-
 python/tvm/relay/testing/py_converter.py   |  27 +-
 python/tvm/relay/transform/memory_alloc.py |   2 -
 python/tvm/relay/transform/transform.py|  14 -
 src/driver/driver_api.cc   |  22 +-
 src/ir/diagnostic.cc   | 282 ---
 src/ir/module.cc   | 114 +--
 src/ir/span.cc |   6 +-
 src/ir/transform.cc|  26 +-
 src/ir/type.cc |  18 +-
 src/parser/diagnostic.h| 179 
 src/parser/parser.cc   | 807 +++---
 src/parser/source_map.cc   |  90 +-
 src/parser/span_check.cc   | 109 ---
 src/parser/span_check.h|  80 --
 src/parser/token.h |  15 -
 src/parser/tokenizer.h  

[incubator-tvm] 01/01: Turn on Rust docs and MxNet based ResNet

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 2e52c6796283b02e5f872f0ed3eb16f1706057c1
Author: Jared Roesch 
AuthorDate: Tue Oct 6 23:00:46 2020 -0700

Turn on Rust docs and MxNet based ResNet
---
 Jenkinsfile  |  4 ++--
 docker/install/ubuntu_install_darknet.sh |  7 ++-
 tests/scripts/task_python_docs.sh| 11 ---
 tests/scripts/task_rust.sh   |  6 ++
 4 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index b44aa2a..f8dabf2 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -45,8 +45,8 @@
 
 // NOTE: these lines are scanned by docker/dev_common.sh. Please update the 
regex as needed. -->
 ci_lint = "tlcpack/ci-lint:v0.62"
-ci_gpu = "tlcpack/ci-gpu:v0.64"
-ci_cpu = "tlcpack/ci-cpu:v0.66"
+ci_gpu = "tlcpack/ci-gpu:v0.65-t0"
+ci_cpu = "tlcpack/ci-cpu:v0.67-t0"
 ci_wasm = "tlcpack/ci-wasm:v0.60"
 ci_i386 = "tlcpack/ci-i386:v0.52"
 // <--- End of regex-scanned config.
diff --git a/docker/install/ubuntu_install_darknet.sh 
b/docker/install/ubuntu_install_darknet.sh
index c48724c..37adf4a 100755
--- a/docker/install/ubuntu_install_darknet.sh
+++ b/docker/install/ubuntu_install_darknet.sh
@@ -6,9 +6,9 @@
 # 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
@@ -23,7 +23,4 @@ set -o pipefail
 #install the necessary dependancies, cffi, opencv
 wget -q 
'https://github.com/siju-samuel/darknet/blob/master/lib/libdarknet.so?raw=true' 
-O libdarknet.so
 debian_version=`cat /etc/debian_version`
-if [ "$debian_version" == "stretch/sid" ]; then
-pip2 install opencv-python cffi
-fi
 pip3 install opencv-python cffi
diff --git a/tests/scripts/task_python_docs.sh 
b/tests/scripts/task_python_docs.sh
index 98dac93..71bb922 100755
--- a/tests/scripts/task_python_docs.sh
+++ b/tests/scripts/task_python_docs.sh
@@ -68,12 +68,10 @@ npm install
 npm run typedoc
 cd ..
 
-# TODO(@jroesch): add Rust to CI container
-# see: https://github.com/apache/incubator-tvm/issues/6628
 # Rust doc
-# cd rust
-# cargo doc --workspace --no-deps
-# cd ..
+cd rust
+cargo doc --workspace --no-deps
+cd ..
 
 # Prepare the doc dir
 rm -rf _docs
@@ -82,8 +80,7 @@ rm -f _docs/.buildinfo
 mkdir -p _docs/api
 mv docs/doxygen/html _docs/api/doxygen
 mv jvm/core/target/site/apidocs _docs/api/javadoc
-# See above TODO
-# mv rust/target/doc _docs/api/rust
+mv rust/target/doc _docs/api/rust
 mv web/dist/docs _docs/api/typedoc
 
 echo "Start creating the docs tarball.."
diff --git a/tests/scripts/task_rust.sh b/tests/scripts/task_rust.sh
index 18361fe..d60999c 100755
--- a/tests/scripts/task_rust.sh
+++ b/tests/scripts/task_rust.sh
@@ -110,8 +110,6 @@ cargo run --bin array
 cargo run --bin string
 cd -
 
-# TODO(@jroesch): we need to renable MxNet in ci-cpu image
-# https://github.com/apache/incubator-tvm/pull/6563
-# cd examples/resnet
-# cargo build
+cd examples/resnet
+cargo run
 cd -



[incubator-tvm] branch ci-docker-staging updated (2e52c67 -> 4b7aa5d)

2020-10-07 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 2e52c67  Turn on Rust docs and MxNet based ResNet
 add 7836654  Add deps needed for Rust examples and docs
 add 4b7aa5d  Setup Rust path

No new revisions were added by this update.

Summary of changes:
 Jenkinsfile  | 4 ++--
 docker/Dockerfile.ci_cpu | 4 
 docker/Dockerfile.ci_gpu | 7 +++
 3 files changed, 13 insertions(+), 2 deletions(-)



[incubator-tvm] branch ci-docker-staging updated: Format

2020-10-14 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/ci-docker-staging by this push:
 new ecf8b65  Format
ecf8b65 is described below

commit ecf8b656abcfb0d73903aee9a0ee3dea039c0ff8
Author: Jared Roesch 
AuthorDate: Wed Oct 14 13:31:27 2020 -0700

Format
---
 tutorials/frontend/build_gcn.py | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tutorials/frontend/build_gcn.py b/tutorials/frontend/build_gcn.py
index a99ed80..b832d18 100644
--- a/tutorials/frontend/build_gcn.py
+++ b/tutorials/frontend/build_gcn.py
@@ -242,7 +242,9 @@ import networkx as nx
 
 def prepare_params(g, data):
 params = {}
-params["infeats"] = data.features.numpy().astype("float32")  # Only 
support float32 as feature for now
+params["infeats"] = data.features.numpy().astype(
+"float32"
+)  # Only support float32 as feature for now
 
 # Generate adjacency matrix
 adjacency = nx.to_scipy_sparse_matrix(g)
@@ -351,5 +353,6 @@ acc = evaluate(data, logits_tvm)
 print("Test accuracy of TVM results: {:.2%}".format(acc))
 
 import tvm.testing
+
 # Verify the results with the DGL model
 tvm.testing.assert_allclose(logits_torch, logits_tvm, atol=1e-3)



[incubator-tvm] branch master created (now 98c2096)

2020-10-13 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at 98c2096  [Diagnostics][Relay][InferType] Refactor InferType to work on 
whole module, and use new diagnostics. (#6274)

No new revisions were added by this update.



[incubator-tvm] branch ci-docker-staging updated: Disable Rust change for now

2020-10-14 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/ci-docker-staging by this push:
 new d4e3f4d  Disable Rust change for now
d4e3f4d is described below

commit d4e3f4d043aa35dcca355ce171a29c1c33e76d08
Author: Jared Roesch 
AuthorDate: Wed Oct 14 22:22:34 2020 -0700

Disable Rust change for now
---
 tests/scripts/task_rust.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/scripts/task_rust.sh b/tests/scripts/task_rust.sh
index d60999c..25e70ee 100755
--- a/tests/scripts/task_rust.sh
+++ b/tests/scripts/task_rust.sh
@@ -111,5 +111,5 @@ cargo run --bin string
 cd -
 
 cd examples/resnet
-cargo run
+# cargo run
 cd -



[incubator-tvm] branch master updated (feb041d -> 277bfc8)

2020-10-06 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from feb041d  bump dockerfile (#6632)
 add 277bfc8  [Rust] Improve NDArray, GraphRt, and Relay bindings (#6563)

No new revisions were added by this update.

Summary of changes:
 include/tvm/relay/adt.h|   1 +
 include/tvm/relay/attrs/nn.h   |  12 +-
 include/tvm/runtime/ndarray.h  |   3 +-
 include/tvm/tir/data_layout.h  |   3 +
 rust/tvm-graph-rt/src/graph.rs |   8 +-
 rust/tvm-graph-rt/src/threading.rs |   4 +-
 rust/tvm-macros/Cargo.toml |   1 +
 rust/tvm-rt/Cargo.toml |   1 +
 rust/tvm-rt/src/array.rs   |  17 +
 rust/tvm-rt/src/errors.rs  |   2 -
 rust/tvm-rt/src/ndarray.rs | 322 +++--
 rust/tvm-rt/src/object/object_ptr.rs   |  72 +--
 rust/tvm-rt/src/string.rs  |   4 +-
 rust/tvm-rt/src/value.rs   |  56 +--
 rust/tvm-sys/src/packed_func.rs|  15 +
 rust/tvm/Cargo.toml|   4 +
 rust/tvm/examples/resnet/Cargo.toml|   3 +-
 rust/tvm/examples/resnet/build.rs  |  10 +-
 rust/tvm/examples/resnet/src/build_resnet.py   |  95 ++--
 rust/tvm/examples/resnet/src/main.rs   | 130 +++---
 rust/tvm/src/ir/arith.rs   |   2 +-
 .../backtrace.h => rust/tvm/src/ir/attrs.rs|  17 +-
 rust/tvm/src/ir/{mod.rs => expr.rs}|  66 ++-
 .../gotvm_test.go => rust/tvm/src/ir/function.rs   |  40 +-
 rust/tvm/src/ir/mod.rs |  62 +--
 rust/tvm/src/ir/module.rs  | 159 +++
 .../css/tvm_theme.css => rust/tvm/src/ir/op.rs |  42 +-
 rust/tvm/src/{runtime => ir/relay/attrs}/mod.rs|   3 +-
 rust/tvm/src/ir/relay/attrs/nn.rs  |  96 
 .../tvm/src/ir/relay/attrs/transform.rs|  19 +-
 rust/tvm/src/ir/relay/mod.rs   | 499 +
 .../relay/std/core.rly => rust/tvm/src/ir/span.rs  |   4 +-
 rust/tvm/src/ir/tir.rs |   4 +-
 rust/tvm/src/ir/ty.rs  | 242 ++
 rust/tvm/src/lib.rs|   2 +
 rust/tvm/src/python.rs |  60 +++
 rust/tvm/src/runtime/graph_rt.rs   |  97 
 rust/tvm/src/runtime/mod.rs|   2 +
 rust/tvm/tests/basics/src/main.rs  |   4 +-
 rust/tvm/tests/callback/src/bin/array.rs   |  19 +-
 src/relay/op/nn/convolution.cc |   4 +-
 src/relay/qnn/op/convolution.cc|   6 +-
 src/relay/transforms/combine_parallel_conv2d.cc|   3 +-
 src/relay/transforms/pattern_util.h|   2 +-
 src/runtime/ndarray.cc |   5 +-
 tests/scripts/task_python_docs.sh  |   9 +
 tests/scripts/task_rust.sh |  13 +-
 47 files changed, 1618 insertions(+), 626 deletions(-)
 copy apps/bundle_deploy/backtrace.h => rust/tvm/src/ir/attrs.rs (82%)
 copy rust/tvm/src/ir/{mod.rs => expr.rs} (74%)
 copy golang/src/gotvm_test.go => rust/tvm/src/ir/function.rs (59%)
 create mode 100644 rust/tvm/src/ir/module.rs
 copy docs/_static/css/tvm_theme.css => rust/tvm/src/ir/op.rs (58%)
 copy rust/tvm/src/{runtime => ir/relay/attrs}/mod.rs (96%)
 create mode 100644 rust/tvm/src/ir/relay/attrs/nn.rs
 copy apps/bundle_deploy/backtrace.h => 
rust/tvm/src/ir/relay/attrs/transform.rs (74%)
 copy python/tvm/relay/std/core.rly => rust/tvm/src/ir/span.rs (93%)
 create mode 100644 rust/tvm/src/ir/ty.rs
 create mode 100644 rust/tvm/src/python.rs
 create mode 100644 rust/tvm/src/runtime/graph_rt.rs



[incubator-tvm] branch master updated: bump dockerfile (#6632)

2020-10-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new feb041d  bump dockerfile (#6632)
feb041d is described below

commit feb041d08c7658ee262430e6660435630e636f90
Author: Thierry Moreau 
AuthorDate: Mon Oct 5 21:55:46 2020 -0700

bump dockerfile (#6632)
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 9e3b0f5..b44aa2a 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -46,7 +46,7 @@
 // NOTE: these lines are scanned by docker/dev_common.sh. Please update the 
regex as needed. -->
 ci_lint = "tlcpack/ci-lint:v0.62"
 ci_gpu = "tlcpack/ci-gpu:v0.64"
-ci_cpu = "tlcpack/ci-cpu:v0.65"
+ci_cpu = "tlcpack/ci-cpu:v0.66"
 ci_wasm = "tlcpack/ci-wasm:v0.60"
 ci_i386 = "tlcpack/ci-i386:v0.52"
 // <--- End of regex-scanned config.



[incubator-tvm] branch main updated (e997185 -> 461e75b)

2020-10-16 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from e997185  [Relay] Change some passes to mix mode (#6695)
 add 461e75b  [LLVM][WINDOWS] Recover windows support for the latest LLVM 
(#6698)

No new revisions were added by this update.

Summary of changes:
 CMakeLists.txt |  2 ++
 apps/cpp_rpc/rpc_env.cc| 11 +--
 apps/cpp_rpc/win32_process.h   |  6 +-
 src/target/llvm/codegen_cpu.cc | 15 +++
 4 files changed, 31 insertions(+), 3 deletions(-)



[incubator-tvm] branch main updated (b121278 -> 3e8ba2a)

2020-10-15 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from b121278  int32 pooling with int64 shapes (#6687)
 add 3e8ba2a  [Docker] Update CI CPU and GPU images based on new Docker 
build files. (#6690)

No new revisions were added by this update.

Summary of changes:
 Jenkinsfile  | 4 ++--
 docker/Dockerfile.ci_cpu | 4 
 docker/Dockerfile.ci_gpu | 7 +++
 docker/install/ubuntu_install_darknet.sh | 7 ++-
 docker/install/ubuntu_install_dgl.sh | 0
 docker/install/ubuntu_install_sphinx.sh  | 2 +-
 rust/Cargo.toml  | 1 -
 7 files changed, 16 insertions(+), 9 deletions(-)
 mode change 100644 => 100755 docker/install/ubuntu_install_dgl.sh



[incubator-tvm] branch master updated: Faster sparse_dense on GPUs (#6580)

2020-10-09 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new 6d0351a  Faster sparse_dense on GPUs (#6580)
6d0351a is described below

commit 6d0351a7f0e23eb5428c59a976edd2bfb8207c0d
Author: Tristan Konolige 
AuthorDate: Fri Oct 9 16:15:26 2020 -0700

Faster sparse_dense on GPUs (#6580)

* Faster sparse_dense on GPUs.

This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.

* formatting

* more formatting

* Check that alteroplayout is definedbefore using it

* check if FTVMAlterOpLayout exists before using it

* formatting

* restore message passing

* Fix sparse_dense and sparse_dense_padded docs

* Fix old sparse_dense, autotvm and sparse_dense dont play well together

* Remove unused imports

* clarify warp count in cuda_transpose

* Document multidimensional access

* Warn users not to use sparse_dense_padded

* rename nn.sparse_dense_padded to nn.internal.sparse_dense_padded
---
 python/tvm/relay/op/nn/_nn.py|  16 ++
 python/tvm/relay/op/nn/nn.py |   6 +-
 python/tvm/relay/op/strategy/cuda.py |  13 ++
 python/tvm/relay/op/strategy/generic.py  |   6 +
 python/tvm/tir/ir_builder.py |  39 +++-
 python/tvm/topi/cuda/sparse.py   | 310 +--
 python/tvm/topi/nn/sparse.py |  25 +++
 src/relay/op/nn/sparse.cc|  36 +++-
 src/relay/transforms/transform_layout.h  |  12 ++
 src/target/source/codegen_cuda.cc|   3 +-
 src/te/operation/compute_op.cc   |   4 +-
 src/te/operation/op_util.cc  |   3 +-
 src/te/schedule/schedule_lang.cc |   2 +-
 src/tir/transforms/lower_warp_memory.cc  |   6 +-
 src/tir/transforms/storage_access.cc |   2 +-
 tests/python/topi/python/test_topi_sparse.py | 114 +++---
 16 files changed, 537 insertions(+), 60 deletions(-)

diff --git a/python/tvm/relay/op/nn/_nn.py b/python/tvm/relay/op/nn/_nn.py
index c83f6a9..9e47dc0 100644
--- a/python/tvm/relay/op/nn/_nn.py
+++ b/python/tvm/relay/op/nn/_nn.py
@@ -75,6 +75,22 @@ reg.register_strategy("nn.sparse_dense", 
strategy.sparse_dense_strategy)
 reg.register_pattern("nn.sparse_dense", reg.OpPattern.OUT_ELEMWISE_FUSABLE)
 
 
+@reg.register_alter_op_layout("nn.sparse_dense")
+def alter_op_layout_sparse_dense(attrs, inputs, tinfos, out_type):
+"""Alternate the layout of sparse_dense"""
+return topi.nn.sparse_dense_alter_layout(attrs, inputs, tinfos, out_type)
+
+
+@reg.register_compute("nn.internal.sparse_dense_padded")
+def compute_sparse_dense_padded(attrs, inputs, out_type):
+"""Compute definition of sparse_dense_padded"""
+raise NotImplementedError("nn.internal.sparse_dense_padded is only 
available on cuda")
+
+
+reg.register_strategy("nn.internal.sparse_dense_padded", 
strategy.sparse_dense_padded_strategy)
+reg.register_pattern("nn.internal.sparse_dense_padded", 
reg.OpPattern.OUT_ELEMWISE_FUSABLE)
+
+
 # sparse_transpose
 @reg.register_compute("nn.sparse_transpose")
 def compute_sparse_transpose(attrs, inputs, out_type):
diff --git a/python/tvm/relay/op/nn/nn.py b/python/tvm/relay/op/nn/nn.py
index 86a76ff..1aad4e7 100644
--- a/python/tvm/relay/op/nn/nn.py
+++ b/python/tvm/relay/op/nn/nn.py
@@ -2016,7 +2016,7 @@ def sparse_dense(data, weight):
 data : tvm.relay.Expr
 The input data for the matrix multiplication
 
-weight : namedtuple.
+weight : Union[namedtuple, Tuple[ndarray, ndarray, ndarray]].
 The sparse weight matrix for the matrix multiplication.
 
 Returns
@@ -2024,7 +2024,9 @@ def sparse_dense(data, weight):
 result: tvm.relay.Expr
 The computed result.
 """
-return _make.sparse_dense(data, weight.data, weight.indices, weight.indptr)
+if hasattr(weight, "indices"):
+return _make.sparse_dense(data, weight.data, weight.indices, 
weight.indptr)
+return _make.sparse_dense(data, weight[0], weight[1], weight[2])
 
 
 def sparse_transpose(x):
diff --git a/python/tvm/relay/op/strategy/cuda.py 
b/python/tvm/relay/op/strategy/cuda.py
index baa03f4..7031365 100644
--- a/python/tvm/relay/op/strategy/cuda.py
+++ b/python/tvm/relay/op/strategy/cuda.py
@@ -633,6 +633,19 @@ def sparse_dense_strategy_cuda(attrs, inputs, out_type, 
target):
 return strategy
 
 
+@sparse_dense_padded_strategy.register(["cuda", "gpu

[incubator-tvm] branch ci-docker-staging updated (4b7aa5d -> 074dbef)

2020-10-09 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard 4b7aa5d  Setup Rust path
 discard 7836654  Add deps needed for Rust examples and docs
 discard 2e52c67  Turn on Rust docs and MxNet based ResNet
 add 1c85047  [apps/bundle_deploy] Link demo_* targets with LDFLAGS and 
also with -lm. (#6636)
 add e4b47a6  Add qemu build step to CI (#6644)
 add 455d401  add a test for assymetric padding in ONNX conv and fix 
importer (#6646)
 add 35854c1  missing header for GraphRuntimeFactory in android_rpc (#6648)
 add dffdb23  Fix leakyReLU support for CoreML (#6651)
 add a8c1273  [CI] make sure graphviz is on both ci-cpu and ci-gpu images 
(#6645)
 add a919824  Add Range op to ONNX, make tvm arange op support negative 
steps (#6647)
 add 1fc47cc  [µTVM] Avoid use of builtin math functions (#6630)
 add 0922d17  [FIX,AUTOTVM] More descriptive error message when an autotvm 
task is not (#6652)
 add f73a1f6  [TEST][TEDD] improve TEDD tests to also run on CPU Docker 
image. (#6643)
 add 98c2096  [Diagnostics][Relay][InferType] Refactor InferType to work on 
whole module, and use new diagnostics. (#6274)
 add a04e8f6  Turn on Rust docs and MxNet based ResNet
 add 7858503  Add deps needed for Rust examples and docs
 add 0704756  Setup Rust path
 add 074dbef  Bump Jenkinsfile

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (4b7aa5d)
\
 N -- N -- N   refs/heads/ci-docker-staging (074dbef)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 CMakeLists.txt |   1 +
 Jenkinsfile|  17 +-
 Makefile   |   5 +
 apps/android_rpc/app/src/main/jni/tvm_runtime.h|   1 +
 apps/bundle_deploy/Makefile|   4 +-
 docker/Dockerfile.ci_gpu   |   2 +-
 docker/install/ubuntu_install_arm_compute_lib.sh   |   0
 docker/install/ubuntu_install_core.sh  |   2 +-
 .../install/ubuntu_install_ethosn_driver_stack.sh  |   1 -
 include/tvm/ir/diagnostic.h| 262 ++
 include/tvm/ir/module.h|  12 +-
 include/tvm/ir/span.h  |   2 +-
 include/tvm/ir/transform.h |  14 +-
 include/tvm/ir/type.h  |  17 +-
 include/tvm/ir/type_relation.h |  13 +-
 include/tvm/parser/parser.h|   3 +-
 include/tvm/parser/source_map.h|  69 +-
 include/tvm/relay/analysis.h   |   9 +-
 include/tvm/relay/transform.h  |  12 -
 include/tvm/runtime/container.h|  14 +
 include/tvm/runtime/object.h   |   2 +-
 include/tvm/tir/op.h   |   1 +
 pyproject.toml |   2 +-
 python/tvm/__init__.py |   9 +-
 python/tvm/_ffi/runtime_ctypes.py  |   2 +-
 python/tvm/autotvm/task/task.py|  19 +-
 python/tvm/ir/__init__.py  |   1 +
 python/tvm/ir/diagnostics/__init__.py  | 118 +++
 python/tvm/{arith => ir/diagnostics}/_ffi_api.py   |   4 +-
 python/tvm/ir/module.py|  23 +-
 python/tvm/micro/build.py  |  46 +-
 python/tvm/micro/compiler.py   |   2 +-
 python/tvm/micro/debugger.py   |  10 +-
 python/tvm/micro/transport.py  |   6 +-
 python/tvm/parser/__init__.py  |  13 +
 python/tvm/relay/backend/graph_runtime_factory.py  |   4 +-
 python/tvm/relay/backend/interpreter.py|   4 +-
 python/tvm/relay/build_module.py   |   2 +
 python/tvm/relay/dataflow_pattern/__init__.py  |   2 +-
 python/tvm/relay/frontend/common.py|   3 +-
 python/tvm/relay/frontend/coreml.py|   2 +-
 python/tvm/relay/frontend/onnx.py  |  25 +-
 python/tvm/relay/frontend/pytorch.py   |  23 +-
 python/tvm/relay/frontend/tensorflow.py|  73 +-
 python/tvm/relay/op/_transform.py   

[incubator-tvm] branch ci-docker-staging updated (4b7aa5d -> 074dbef)

2020-10-09 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard 4b7aa5d  Setup Rust path
 discard 7836654  Add deps needed for Rust examples and docs
 discard 2e52c67  Turn on Rust docs and MxNet based ResNet
 add 1c85047  [apps/bundle_deploy] Link demo_* targets with LDFLAGS and 
also with -lm. (#6636)
 add e4b47a6  Add qemu build step to CI (#6644)
 add 455d401  add a test for assymetric padding in ONNX conv and fix 
importer (#6646)
 add 35854c1  missing header for GraphRuntimeFactory in android_rpc (#6648)
 add dffdb23  Fix leakyReLU support for CoreML (#6651)
 add a8c1273  [CI] make sure graphviz is on both ci-cpu and ci-gpu images 
(#6645)
 add a919824  Add Range op to ONNX, make tvm arange op support negative 
steps (#6647)
 add 1fc47cc  [µTVM] Avoid use of builtin math functions (#6630)
 add 0922d17  [FIX,AUTOTVM] More descriptive error message when an autotvm 
task is not (#6652)
 add f73a1f6  [TEST][TEDD] improve TEDD tests to also run on CPU Docker 
image. (#6643)
 add 98c2096  [Diagnostics][Relay][InferType] Refactor InferType to work on 
whole module, and use new diagnostics. (#6274)
 add a04e8f6  Turn on Rust docs and MxNet based ResNet
 add 7858503  Add deps needed for Rust examples and docs
 add 0704756  Setup Rust path
 add 074dbef  Bump Jenkinsfile

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (4b7aa5d)
\
 N -- N -- N   refs/heads/ci-docker-staging (074dbef)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 CMakeLists.txt |   1 +
 Jenkinsfile|  17 +-
 Makefile   |   5 +
 apps/android_rpc/app/src/main/jni/tvm_runtime.h|   1 +
 apps/bundle_deploy/Makefile|   4 +-
 docker/Dockerfile.ci_gpu   |   2 +-
 docker/install/ubuntu_install_arm_compute_lib.sh   |   0
 docker/install/ubuntu_install_core.sh  |   2 +-
 .../install/ubuntu_install_ethosn_driver_stack.sh  |   1 -
 include/tvm/ir/diagnostic.h| 262 ++
 include/tvm/ir/module.h|  12 +-
 include/tvm/ir/span.h  |   2 +-
 include/tvm/ir/transform.h |  14 +-
 include/tvm/ir/type.h  |  17 +-
 include/tvm/ir/type_relation.h |  13 +-
 include/tvm/parser/parser.h|   3 +-
 include/tvm/parser/source_map.h|  69 +-
 include/tvm/relay/analysis.h   |   9 +-
 include/tvm/relay/transform.h  |  12 -
 include/tvm/runtime/container.h|  14 +
 include/tvm/runtime/object.h   |   2 +-
 include/tvm/tir/op.h   |   1 +
 pyproject.toml |   2 +-
 python/tvm/__init__.py |   9 +-
 python/tvm/_ffi/runtime_ctypes.py  |   2 +-
 python/tvm/autotvm/task/task.py|  19 +-
 python/tvm/ir/__init__.py  |   1 +
 python/tvm/ir/diagnostics/__init__.py  | 118 +++
 python/tvm/{arith => ir/diagnostics}/_ffi_api.py   |   4 +-
 python/tvm/ir/module.py|  23 +-
 python/tvm/micro/build.py  |  46 +-
 python/tvm/micro/compiler.py   |   2 +-
 python/tvm/micro/debugger.py   |  10 +-
 python/tvm/micro/transport.py  |   6 +-
 python/tvm/parser/__init__.py  |  13 +
 python/tvm/relay/backend/graph_runtime_factory.py  |   4 +-
 python/tvm/relay/backend/interpreter.py|   4 +-
 python/tvm/relay/build_module.py   |   2 +
 python/tvm/relay/dataflow_pattern/__init__.py  |   2 +-
 python/tvm/relay/frontend/common.py|   3 +-
 python/tvm/relay/frontend/coreml.py|   2 +-
 python/tvm/relay/frontend/onnx.py  |  25 +-
 python/tvm/relay/frontend/pytorch.py   |  23 +-
 python/tvm/relay/frontend/tensorflow.py|  73 +-
 python/tvm/relay/op/_transform.py   

[incubator-tvm] branch ci-docker-staging updated (074dbef -> 9ddcff9)

2020-10-14 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard 074dbef  Bump Jenkinsfile
 discard 0704756  Setup Rust path
 discard 7858503  Add deps needed for Rust examples and docs
 discard a04e8f6  Turn on Rust docs and MxNet based ResNet
 add 6d0351a  Faster sparse_dense on GPUs (#6580)
 add 5a33774  Revert "[Relay] Keep fixed dim when unifying dynamic shape 
(#5795)" (#6658)
 add f6657a6  [AutoScheduler] Improve the GPU tutorial by deleting 
measure_ctx earlier (#6660)
 add dd60d24  [AutoScheduler] Improve test cases (#6657)
 add bf21371  [Frontend][Tensorflow] Fix TF 1.15 conv2d_transpose parsing 
(#6589)
 add e561007  [BYOC][ACL] Support add operation (#6532)
 add d3ef137  Fix typographical error. (#6664)
 add 74b6922  [Relay][MXNet] Support broadcast_like (#6561)
 add 0cdd285  [CI] Move to use main as the default (#6665)
 add b277f18  [Torch] Object detection support update for PyTorch 1.6 
(#6659)
 add d955718  don't validate AttrInitEntry until a value has attempted to 
be set (#6672)
 add 4073adc  [CI] Set main as default in github actions (#6669)
 add d5728bd  [BYOC] Support control flow in annotate_target (#6641)
 add d24634a  TF argmax - handling int64 datatype (#6674)
 add f196a81  [CODEGEN][COREML] Call InferType explicitly in coreml test 
(#6676)
 add 8d9ca2a  Adjust Vulkan queue selection and creation logic (#6662)
 add d7fa9c1  Install xgboost>=1.1.0 in CI container (#6679)
 add 7d805b5  Fix format error in integrate.rst (#6677)
 add e66b2e8  Revert #5238 (#6680)
 add b06fa68  Turn on Rust docs and MxNet based ResNet
 add 84d9d99  Add deps needed for Rust examples and docs
 add 81e91f9  Setup Rust path
 add 5403ca2  Bump Jenkinsfile
 add 7e264b8  Fix broken version setting, which instead redirects stdout 
and stderr
 add 9ddcff9  Update Jenkinsfile

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (074dbef)
\
 N -- N -- N   refs/heads/ci-docker-staging (9ddcff9)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 .github/workflows/main.yml |   4 +-
 Jenkinsfile|  12 +-
 Makefile   |   2 +-
 NEWS.md|   4 +-
 README.md  |   4 +-
 apps/android_deploy/README.md  |   4 +-
 apps/android_rpc/README.md |   6 +-
 apps/benchmark/README.md   |   2 +-
 apps/ios_rpc/tests/ios_rpc_mobilenet.py|   2 +-
 apps/wasm-standalone/README.md |   4 +-
 docker/install/ubuntu_install_dgl.sh   |   0
 docker/install/ubuntu_install_redis.sh |   2 +-
 docker/install/ubuntu_install_sphinx.sh|   2 +-
 docker/lint.sh |   4 +-
 docs/conf.py   |   2 +-
 docs/contribute/code_guide.rst |   2 +-
 docs/contribute/community.rst  |   2 +-
 docs/contribute/document.rst   |   4 +-
 docs/contribute/git_howto.rst  |  26 +-
 docs/contribute/pull_request.rst   |   8 +-
 docs/contribute/release_process.rst|   8 +-
 docs/deploy/android.rst|   4 +-
 docs/deploy/arm_compute_lib.rst|   4 +
 docs/deploy/cpp_deploy.rst |  10 +-
 docs/deploy/integrate.rst  |   9 +-
 docs/dev/frontend/tensorflow.rst   |   4 +-
 docs/dev/index.rst |   4 +-
 docs/dev/inferbound.rst|  30 +-
 docs/dev/pass_infra.rst|  20 +-
 docs/dev/relay_add_pass.rst|   6 +-
 docs/dev/relay_bring_your_own_codegen.rst  |   2 +-
 docs/dev/relay_intro.rst   |   6 +-
 docs/dev/runtime.rst   |  22 +-
 docs/dev/virtual_machine.rst   |  18 +-
 docs/install/docker.rst|   2 +-
 docs/langref/relay_patt

[incubator-tvm] branch master updated (617949d -> 942c90b)

2020-08-26 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 617949d  Use auto-tuner to improve conv2d_gemm performance (#6117)
 add 942c90b  [DYN][RELAY] Resize support for NCHW-convertible layouts 
(#6293)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/op/dyn/image/_image.py | 34 ++---
 1 file changed, 14 insertions(+), 20 deletions(-)



[incubator-tvm] branch master updated (751982e -> 1a26a2e)

2020-08-25 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 751982e  [FIX][VM] Fix relay vm optimize (#6322)
 add 1a26a2e  [Relay] Make check stricter by using Feature. Fixed multiple 
bugs. (#6326)

No new revisions were added by this update.

Summary of changes:
 include/tvm/relay/feature.h|  34 +++
 include/tvm/relay/transform.h  |   9 ++
 python/tvm/relay/prelude.py|  16 +--
 python/tvm/relay/transform/transform.py|  17 +++-
 src/relay/analysis/feature.cc  |  51 +-
 src/relay/transforms/gradient.cc   |  55 ---
 src/relay/transforms/lazy_gradient_init.cc | 107 -
 src/relay/transforms/partial_eval.cc   |   5 +-
 src/relay/transforms/pass_util.h   |   3 +-
 src/relay/transforms/to_a_normal_form.cc   |  62 ++--
 src/relay/transforms/to_cps.cc |   3 +
 tests/python/relay/test_analysis_feature.py|   2 -
 tests/python/relay/test_op_grad_level10.py |  14 ++-
 tests/python/relay/test_pass_gradient.py   |  24 -
 tests/python/relay/test_pass_lazy_gradient_init.py |  18 
 tests/python/relay/test_pass_merge_composite.py|  16 +--
 tests/python/relay/test_pass_partial_eval.py   |  25 +
 17 files changed, 291 insertions(+), 170 deletions(-)



[incubator-tvm] branch master updated (942c90b -> 4910c8c)

2020-08-26 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 942c90b  [DYN][RELAY] Resize support for NCHW-convertible layouts 
(#6293)
 add 4910c8c  [MSVC] Make able to compile with MSVC (#6341)

No new revisions were added by this update.

Summary of changes:
 src/target/llvm/codegen_hexagon.cc | 2 +-
 src/te/autodiff/ad_simplify.cc | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)



[incubator-tvm] branch master updated (4c9a391 -> c899b3c)

2020-08-28 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 4c9a391  quanitze operation expanded to take const argument (#6127)
 add c899b3c  Improve Rust bindings: Map, Array, String, various IR nodes 
(#6339)

No new revisions were added by this update.

Summary of changes:
 rust/tvm-macros/src/object.rs  |   6 +-
 rust/tvm-rt/src/array.rs   |  45 +++-
 rust/tvm-rt/src/function.rs|   2 +-
 rust/tvm-rt/src/lib.rs |   1 +
 rust/tvm-rt/src/map.rs | 264 +
 rust/tvm-rt/src/object/mod.rs  |   4 +
 rust/tvm-rt/src/object/object_ptr.rs   |   4 +-
 rust/tvm-rt/src/string.rs  | 118 ++---
 rust/tvm-sys/src/datatype.rs   |   3 +-
 rust/tvm-sys/src/packed_func.rs|  31 +++
 .../bytearray_test.go => rust/tvm/src/ir/arith.rs  |  46 ++--
 rust/tvm/src/ir/mod.rs |  40 +++-
 rust/tvm/src/ir/relay/mod.rs   |  10 +-
 rust/tvm/src/ir/tir.rs |  93 
 rust/tvm/src/transform.rs  |  32 ++-
 15 files changed, 619 insertions(+), 80 deletions(-)
 create mode 100644 rust/tvm-rt/src/map.rs
 copy golang/src/bytearray_test.go => rust/tvm/src/ir/arith.rs (52%)
 create mode 100644 rust/tvm/src/ir/tir.rs



[incubator-tvm] branch master updated: [Relay][Training] Make AutoDiff thread through global function. (#6336)

2020-08-27 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new e35b7fc  [Relay][Training] Make AutoDiff thread through global 
function. (#6336)
e35b7fc is described below

commit e35b7fc4bcdcfe008c5dfea60c2297b93dbff99e
Author: 雾雨魔理沙 
AuthorDate: Thu Aug 27 11:32:40 2020 -0700

[Relay][Training] Make AutoDiff thread through global function. (#6336)

* save

* lint

* lint

* fix warning

* fix test

* save
---
 src/printer/doc.cc   |   2 +-
 src/relay/transforms/gradient.cc | 106 ---
 tests/python/relay/test_pass_gradient.py |  41 +++-
 3 files changed, 124 insertions(+), 25 deletions(-)

diff --git a/src/printer/doc.cc b/src/printer/doc.cc
index d487e3e..ab1eddb 100644
--- a/src/printer/doc.cc
+++ b/src/printer/doc.cc
@@ -129,7 +129,7 @@ Doc Doc::Indent(int indent, Doc doc) {
 }
 
 Doc Doc::StrLiteral(const std::string& value, std::string quote) {
-  // TODO(M.K.): add escape.
+  // TODO(@M.K.): add escape.
   Doc doc;
   return doc << quote << value << quote;
 }
diff --git a/src/relay/transforms/gradient.cc b/src/relay/transforms/gradient.cc
index 7894c34..9c47254 100644
--- a/src/relay/transforms/gradient.cc
+++ b/src/relay/transforms/gradient.cc
@@ -72,7 +72,7 @@ Type WithGradientType(const Type&);
 Expr FirstOrderGradient(const Expr& e, const Optional& mod);
 
 Type WithGradientType(const Type& t) {
-  // TODO(M.K.): stricter checking
+  // TODO(@M.K.): stricter checking
   auto ty = t.as();
   CHECK(ty) << "input should be a function";
   return FuncType(ty->arg_types, TupleType({ty->ret_type, 
TupleType(ty->arg_types)}), {}, {});
@@ -85,7 +85,7 @@ Expr DeGlobal(const Optional& mod, const Expr& e) {
   if (mod.defined() && x) {
 BaseFunc base_func = mod.value()->Lookup(GetRef(x));
 if (auto* n = base_func.as()) {
-  return n->body;
+  return GetRef(n);
 } else {
   return e;
 }
@@ -338,11 +338,22 @@ Expr FirstOrderGradient(const Expr& re, const 
Optional& mod) {
 
 
TVM_REGISTER_GLOBAL("relay._transform.first_order_gradient").set_body_typed(FirstOrderGradient);
 
+Type bpt = RelayRefType(FuncType({}, TupleType(Array()), {}, {}));
+
 struct ReverseADType : TypeMutator {
   Type VisitType_(const TensorTypeNode* ttn) final {
 Type t = GetRef(ttn);
 return TupleType({t, RelayRefType(t)});
   }
+
+  Type VisitType_(const FuncTypeNode* ftn) final {
+std::vector arg_types;
+for (const auto& t : ftn->arg_types) {
+  arg_types.push_back(VisitType(t));
+}
+arg_types.push_back(bpt);
+return FuncType(arg_types, ftn->ret_type, ftn->type_params, 
ftn->type_constraints);
+  }
 };
 
 Type ReverseType(const Type& t) { return ReverseADType()(t); }
@@ -438,12 +449,18 @@ Expr BPEmpty() {
 
 struct ReverseAD : ExprMutator {
   using ADVarMap = std::unordered_map;
-
+  using ADGlobalVarMap = std::unordered_map;
+  Optional mod;
+  // TODO(@M.K.) refactor AD to always use mod.
   Var bp;
   std::shared_ptr ad_vars;
+  std::shared_ptr ad_gvars;
   const OpAttrMap rev_map = 
Op::GetAttrMap("FPrimalGradient");
 
-  explicit ReverseAD(const Var& bp, std::shared_ptr ad_vars) : 
bp(bp), ad_vars(ad_vars) {}
+  explicit ReverseAD(const Optional& mod, const Var& bp,
+ const std::shared_ptr& ad_vars,
+ const std::shared_ptr& ad_gvars)
+  : mod(mod), bp(bp), ad_vars(ad_vars), ad_gvars(ad_gvars) {}
 
   Expr VisitExpr_(const OpNode* op) final {
 LOG(FATAL) << "op should only be inside call";
@@ -481,9 +498,8 @@ struct ReverseAD : ExprMutator {
   Expr nbp = Function({}, LetList::With([&](LetList* ll) {
 // we need a new ReverseAD visitor to avoid 
clobbering the bp local var
 auto dup_bp = ll->Push(BPEmpty());
-ReverseAD dup_diff(dup_bp, ad_vars);
-auto dup_ad = 
ll->Push(dup_diff.VisitExpr(DeDup(x)));
-
+auto dup_ad =
+ll->Push(ReverseAD(mod, dup_bp, ad_vars, 
ad_gvars)(DeDup(x)));
 TransferGrads(call->checked_type(), ret, dup_ad, 
ll);
 ll->Push(Call(RefRead(dup_bp), {}));
 return Call(bpv, {});
@@ -518,22 +534,29 @@ struct ReverseAD : ExprMutator {
 orig_var->checked_type_ = call->checked_type();
 auto ret = ll->Push(GetRev(call->checked_type(), orig_var, ll));
 auto bpv = ll->Push(RefRead(bp));
- 

[incubator-tvm] branch master updated: [TIR][REFACTOR] std::string -> String Migration in TIR nodes (#5596)

2020-05-28 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new a072da0  [TIR][REFACTOR] std::string -> String Migration in TIR nodes 
(#5596)
a072da0 is described below

commit a072da0588c542757d2815832b7f010f530b2428
Author: Neo Chien 
AuthorDate: Thu May 28 16:56:06 2020 +0800

[TIR][REFACTOR] std::string -> String Migration in TIR nodes (#5596)

* [TIR][REFACTOR] std::string -> String Migration for Var node and SizeVar 
Node

* update json_compact.py
---
 include/tvm/tir/stmt.h  |  2 +-
 include/tvm/tir/var.h   | 12 ++--
 python/tvm/ir/json_compact.py   |  4 ++--
 src/printer/tir_text_printer.cc |  2 +-
 src/tir/ir/data_layout.cc   |  6 +++---
 src/tir/ir/expr.cc  | 15 +++
 6 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/include/tvm/tir/stmt.h b/include/tvm/tir/stmt.h
index e1fef55..bbc37fe 100644
--- a/include/tvm/tir/stmt.h
+++ b/include/tvm/tir/stmt.h
@@ -20,7 +20,7 @@
  * \file tvm/tir/stmt.h
  * \brief TIR statements.
  */
-// Acknowledgement: Mnay low-level stmts originate from Halide.
+// Acknowledgement: Many low-level stmts originate from Halide.
 #ifndef TVM_TIR_STMT_H_
 #define TVM_TIR_STMT_H_
 
diff --git a/include/tvm/tir/var.h b/include/tvm/tir/var.h
index a89c665..4db462d 100644
--- a/include/tvm/tir/var.h
+++ b/include/tvm/tir/var.h
@@ -50,7 +50,7 @@ class VarNode : public PrimExprNode {
* \brief The hint to the variable name.
* \note Each variable is uniquely identified by its address.
*/
-  std::string name_hint;
+  String name_hint;
   /*!
* \brief type annotaion of the variable.
*
@@ -92,19 +92,19 @@ class Var : public PrimExpr {
* \param name_hint variable name
* \param dtype data type
*/
-  TVM_DLL explicit Var(std::string name_hint = "v", DataType dtype = 
DataType::Int(32));
+  TVM_DLL explicit Var(String name_hint = "v", DataType dtype = 
DataType::Int(32));
   /*!
* \brief Constructor which provides a more detailed type annotation.
* \param name_hint variable name.
* \param type_annotation The type annotation.
*/
-  TVM_DLL explicit Var(std::string name_hint, Type type_annotation);
+  TVM_DLL explicit Var(String name_hint, Type type_annotation);
   /*!
* \brief Make a new copy of var with same type, append suffix
* \param suffix The suffix to be appended.
* \return the new Var copy
*/
-  TVM_DLL Var copy_with_suffix(const std::string& suffix) const;
+  TVM_DLL Var copy_with_suffix(const String& suffix) const;
   /*!
* \brief Get pointer to the internal value.
* \return the corresponding Variable.
@@ -138,7 +138,7 @@ class SizeVar : public Var {
* \param name_hint variable name
* \param t data type
*/
-  TVM_DLL explicit SizeVar(std::string name_hint = "s", DataType t = 
DataType::Int(32));
+  TVM_DLL explicit SizeVar(String name_hint = "s", DataType t = 
DataType::Int(32));
   /*!
* \brief Get pointer to the internal value.
* \return the corresponding Variable.
@@ -178,7 +178,7 @@ enum IterVarType : int {
   /*!
* \brief The IterVar itself is a thread-index
*  of a fixed thread launching group.
-   *  Note that this is already assumed to be paralellized.
+   *  Note that this is already assumed to be parallelized.
*
*  Disallow: split/fuse/vectorize/parallel
*/
diff --git a/python/tvm/ir/json_compact.py b/python/tvm/ir/json_compact.py
index 2abfd81..9d90685 100644
--- a/python/tvm/ir/json_compact.py
+++ b/python/tvm/ir/json_compact.py
@@ -130,8 +130,8 @@ def create_updater_06_to_07():
 "relay.ModulePass": _rename("transform.ModulePass"),
 "relay.Sequential": _rename("transform.Sequential"),
 # TIR
-"Variable": _update_tir_var("tir.Var"),
-"SizeVar": _update_tir_var("tir.SizeVar"),
+"Variable": [_update_tir_var("tir.Var"), _update_from_std_str("name")],
+"SizeVar": [_update_tir_var("tir.SizeVar"), 
_update_from_std_str("name")],
 }
 return create_updater(node_map, "0.6", "0.7")
 
diff --git a/src/printer/tir_text_printer.cc b/src/printer/tir_text_printer.cc
index 0bcc148..4d22cbb 100644
--- a/src/printer/tir_text_printer.cc
+++ b/src/printer/tir_text_printer.cc
@@ -567,7 +567,7 @@ Doc TIRTextPrinter::AllocVar(const Var& var) {
   if (it != memo_var_.end()) {
 return it->second;
   }
-  std::string name = var->name_hint;
+  std::string name = var->name_hint.operator std::string();
   if (name.length() == 0 || !std::isalpha(name[0])) {
 name = "v" + name;
   }
diff --gi

[incubator-tvm] branch rust-tvm created (now a44a379)

2020-05-30 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at a44a379  Refactor anyhow out of the rt layer

This branch includes the following new commits:

 new 4cf2dbc  Add tvm crate
 new a44a379  Refactor anyhow out of the rt layer

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[incubator-tvm] 01/02: Add tvm crate

2020-05-30 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 4cf2dbcf9b058e4d10f332a3fe0385d9387929fc
Author: Jared Roesch 
AuthorDate: Thu May 28 02:08:14 2020 -0700

Add tvm crate
---
 rust/tvm/.gitignore  |   7 +
 rust/tvm/.travis.yml |  22 +++
 rust/tvm/Cargo.toml  |  45 +
 rust/tvm/README.md   | 235 +++
 rust/tvm/examples/resnet/Cargo.toml  |  29 
 rust/tvm/examples/resnet/README.md   |  45 +
 rust/tvm/examples/resnet/build.rs|  42 +
 rust/tvm/examples/resnet/src/build_resnet.py | 134 +++
 rust/tvm/examples/resnet/src/main.rs | 160 ++
 rust/tvm/src/ir/array.rs |  70 
 rust/tvm/src/ir/mod.rs   |  17 ++
 rust/tvm/src/ir/relay/mod.rs | 232 ++
 rust/tvm/src/lib.rs  |  60 +++
 rust/tvm/src/runtime/mod.rs  |   1 +
 rust/tvm/src/transform.rs|  41 +
 rust/tvm/tests/basics/.gitignore |   7 +
 rust/tvm/tests/basics/Cargo.toml |  32 
 rust/tvm/tests/basics/build.rs   |  46 ++
 rust/tvm/tests/basics/src/main.rs|  55 +++
 rust/tvm/tests/basics/src/tvm_add.py |  50 ++
 rust/tvm/tests/callback/Cargo.toml   |  26 +++
 rust/tvm/tests/callback/src/bin/array.rs |  72 
 rust/tvm/tests/callback/src/bin/error.rs |  56 +++
 rust/tvm/tests/callback/src/bin/float.rs |  50 ++
 rust/tvm/tests/callback/src/bin/int.rs   |  49 ++
 rust/tvm/tests/callback/src/bin/string.rs|  54 ++
 rust/tvm/tests/test_ir.rs|  37 +
 27 files changed, 1674 insertions(+)

diff --git a/rust/tvm/.gitignore b/rust/tvm/.gitignore
new file mode 100644
index 000..2430329
--- /dev/null
+++ b/rust/tvm/.gitignore
@@ -0,0 +1,7 @@
+target
+**/*.rs.bk
+Cargo.lock
+/tests/basics/add_*
+/examples/resnet/deploy_*
+/examples/resnet/*.png
+/examples/resnet/synset.*
diff --git a/rust/tvm/.travis.yml b/rust/tvm/.travis.yml
new file mode 100644
index 000..e963b7c
--- /dev/null
+++ b/rust/tvm/.travis.yml
@@ -0,0 +1,22 @@
+# 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.
+
+language: rust
+rust:
+  - nightly
+matrix:
+  fast_finish: true
diff --git a/rust/tvm/Cargo.toml b/rust/tvm/Cargo.toml
new file mode 100644
index 000..4cbb619
--- /dev/null
+++ b/rust/tvm/Cargo.toml
@@ -0,0 +1,45 @@
+# 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.
+
+[package]
+name = "tvm"
+version = "0.1.0"
+license = "Apache-2.0"
+description = "Rust frontend support for TVM"
+repository = "https://github.com/apache/incubator-tvm;
+homepage = "https://github.com/apache/incubator-tvm;
+readme = "README.md"
+keywords = ["rust", "tvm"]
+categories = ["api-bindings", "science"]
+authors = ["TVM Contributors"]
+edition = "2018"
+
+[dependencies]
+thiserror = "^1.0"
+anyhow = "^1.0"
+lazy_static = "1.1"
+ndarray = "0.12"
+num-traits = "0.2"
+tvm-rt = { version = "0.1", path = &qu

[incubator-tvm] 02/02: Refactor anyhow out of the rt layer

2020-05-30 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit a44a379bb3b3f4fab505dce3520eeb97f230ac23
Author: Jared Roesch 
AuthorDate: Sat May 30 01:07:46 2020 -0700

Refactor anyhow out of the rt layer
---
 rust/Cargo.toml  |  3 +-
 rust/macros/src/object.rs|  8 ++---
 rust/tvm-rt/src/errors.rs| 36 
 rust/tvm-rt/src/function.rs  | 66 +---
 rust/tvm-rt/src/lib.rs   |  5 +--
 rust/tvm-rt/src/ndarray.rs   | 66 +++-
 rust/tvm-rt/src/object/mod.rs| 17 --
 rust/tvm-rt/src/object/object_ptr.rs | 30 +---
 rust/tvm-rt/src/to_function.rs   | 37 ++--
 rust/tvm-rt/src/value.rs |  5 ++-
 rust/tvm/src/ir/array.rs | 55 +-
 rust/tvm/src/lib.rs  | 10 +-
 rust/tvm/src/transform.rs|  2 +-
 13 files changed, 211 insertions(+), 129 deletions(-)

diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 6d3481b..e107104 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -29,5 +29,6 @@ members = [
"frontend/tests/callback",
"frontend/examples/resnet",
 "tvm-sys",
-   "tvm-rt"
+   "tvm-rt",
+   "tvm",
 ]
diff --git a/rust/macros/src/object.rs b/rust/macros/src/object.rs
index 96a86dd..670d326 100644
--- a/rust/macros/src/object.rs
+++ b/rust/macros/src/object.rs
@@ -89,12 +89,12 @@ pub fn macro_impl(input: proc_macro::TokenStream) -> 
TokenStream {
 }
 
 impl std::convert::TryFrom for #ref_id {
-type Error = ::anyhow::Error;
+type Error = tvm_rt::Error;
 
 fn try_from(ret_val: tvm_rt::RetValue) -> Result<#ref_id, 
Self::Error> {
 use std::convert::TryInto;
 let oref: ObjectRef = ret_val.try_into()?;
-let ptr = oref.0.ok_or(anyhow::anyhow!("null ptr"))?;
+let ptr = oref.0.ok_or(tvm_rt::Error::Null)?;
 let ptr = ptr.downcast::<#payload_id>()?;
 Ok(#ref_id(Some(ptr)))
 }
@@ -122,7 +122,7 @@ pub fn macro_impl(input: proc_macro::TokenStream) -> 
TokenStream {
 }
 
 impl<'a> std::convert::TryFrom> for #ref_id {
-type Error = anyhow::Error;
+type Error = tvm_rt::Error;
 
 fn try_from(arg_value: tvm_rt::ArgValue<'a>) -> Result<#ref_id, 
Self::Error> {
 use std::convert::TryInto;
@@ -132,7 +132,7 @@ pub fn macro_impl(input: proc_macro::TokenStream) -> 
TokenStream {
 }
 
 impl<'a> std::convert::TryFrom<_rt::ArgValue<'a>> for #ref_id {
-type Error = anyhow::Error;
+type Error = tvm_rt::Error;
 
 fn try_from(arg_value: _rt::ArgValue<'a>) -> Result<#ref_id, 
Self::Error> {
 use std::convert::TryInto;
diff --git a/rust/tvm-rt/src/errors.rs b/rust/tvm-rt/src/errors.rs
index 77dbba7..41e873f 100644
--- a/rust/tvm-rt/src/errors.rs
+++ b/rust/tvm-rt/src/errors.rs
@@ -17,13 +17,10 @@
  * under the License.
  */
 
+use crate::DataType;
 use thiserror::Error;
 
 #[derive(Debug, Error)]
-#[error("Cannot convert from an empty array.")]
-pub struct EmptyArrayError;
-
-#[derive(Debug, Error)]
 #[error("Handle `{name}` is null.")]
 pub struct NullHandleError {
 pub name: String,
@@ -41,5 +38,32 @@ pub struct TypeMismatchError {
 }
 
 #[derive(Debug, Error)]
-#[error("Missing NDArray shape.")]
-pub struct MissingShapeError;
+pub enum NDArrayError {
+#[error("Missing NDArray shape.")]
+MissingShape,
+#[error("Cannot convert from an empty array.")]
+EmptyArray,
+#[error("Invalid datatype when attempting to convert ndarray.")]
+InvalidDatatype(#[from] tvm_sys::datatype::ParseDataTypeError),
+#[error("a shape error occurred in the Rust ndarray library")]
+ShapeError(#[from] ndarray::ShapeError),
+#[error("Expected type `{expected}` but found `{actual}`")]
+DataTypeMismatch { expected: DataType, actual: DataType }
+}
+
+#[derive(Debug, Error)]
+pub enum Error {
+#[error("{0}")]
+Downcast(#[from] tvm_sys::errors::ValueDowncastError),
+#[error("raw pointer passed across boundary was null")]
+Null,
+}
+
+impl Error {
+pub fn downcast(actual_type: String, expected_type: &'static str) -> Error 
{
+Self::Downcast(tvm_sys::errors::ValueDowncastError {
+actual_type,
+expected_type,
+})
+}
+}
diff --git a/rust/tvm-rt/src/function.rs b/rust/tvm-rt/src/function.rs
index 2a5

[incubator-tvm] branch master updated: [RUNTIME] Resolve constexpr issue in debug mode. (#5651)

2020-05-22 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new 896557d  [RUNTIME] Resolve constexpr issue in debug mode. (#5651)
896557d is described below

commit 896557d935999391dcc8bda001fb67d79e2f9ef8
Author: Tianqi Chen 
AuthorDate: Fri May 22 13:36:43 2020 -0700

[RUNTIME] Resolve constexpr issue in debug mode. (#5651)

static constexpr is a bit weird before c++17.
They are not inlined by default and does not have symbols after compilation.
It usually isn't a problem when they are inlined(in c++17 they are inlined 
by default).
But will create compilation error when passed to functions that take 
(const)references.
This PR fixes the problem so that we can compile on debugmode.
---
 include/tvm/runtime/container.h | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/tvm/runtime/container.h b/include/tvm/runtime/container.h
index a52e997..1569c67 100644
--- a/include/tvm/runtime/container.h
+++ b/include/tvm/runtime/container.h
@@ -491,10 +491,10 @@ class ArrayNode : public Object, public 
InplaceArrayBase {
   int64_t capacity_;
 
   /*! \brief Initial size of ArrayNode */
-  static const constexpr int64_t kInitSize = 4;
+  static constexpr int64_t kInitSize = 4;
 
   /*! \brief Expansion factor of the Array */
-  static const constexpr int64_t kIncFactor = 2;
+  static constexpr int64_t kIncFactor = 2;
 
   // CRTP parent class
   friend InplaceArrayBase;
@@ -929,7 +929,9 @@ class Array : public ObjectRef {
   ArrayNode* CopyOnWrite(int64_t reserve_extra) {
 ArrayNode* p = GetArrayNode();
 if (p == nullptr) {
-  return SwitchContainer(std::max(ArrayNode::kInitSize, reserve_extra));
+  // necessary to get around the constexpr address issue before c++17
+  const int64_t kInitSize = ArrayNode::kInitSize;
+  return SwitchContainer(std::max(kInitSize, reserve_extra));
 }
 if (p->capacity_ >= p->size_ + reserve_extra) {
   return CopyOnWrite();



[incubator-tvm] branch main updated: Add pytest-xdist and pytest-profiling to the base installation packages. (#6736)

2020-10-24 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/main by this push:
 new bb4179e  Add pytest-xdist and pytest-profiling to the base 
installation packages. (#6736)
bb4179e is described below

commit bb4179e2867a1d3cb9bd56c707681cc66c07d459
Author: Ramana Radhakrishnan 
AuthorDate: Sat Oct 24 08:27:30 2020 +0100

Add pytest-xdist and pytest-profiling to the base installation packages. 
(#6736)

For building and testing some small portions of the python testsuite,
I've been playing off and on with xdist and pytest-profiling.

We know it's not safe for the entirity of CI yet but this could
enable smaller parts of pipelines that folks use using the
common scripts to be parallelized or indeed profiled for more
insight into where time is spent in building and testing TVM
---
 docker/install/ubuntu_install_python_package.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docker/install/ubuntu_install_python_package.sh 
b/docker/install/ubuntu_install_python_package.sh
index 2ed14c2..c8d9856 100755
--- a/docker/install/ubuntu_install_python_package.sh
+++ b/docker/install/ubuntu_install_python_package.sh
@@ -21,4 +21,4 @@ set -u
 set -o pipefail
 
 # install libraries for python package on ubuntu
-pip3 install six numpy pytest cython decorator scipy tornado typed_ast pytest 
mypy orderedset attrs requests Pillow packaging cloudpickle
+pip3 install six numpy pytest cython decorator scipy tornado typed_ast pytest 
pytest-xdist pytest-profiling mypy orderedset attrs requests Pillow packaging 
cloudpickle



[incubator-tvm] branch main updated: [Docker] Turn on Rust docs and MxNet based ResNet (#6640)

2020-10-24 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/main by this push:
 new ee9b6d6  [Docker] Turn on Rust docs and MxNet based ResNet (#6640)
ee9b6d6 is described below

commit ee9b6d6de52accf6515d69c7f565aeefdf19bddc
Author: Jared Roesch 
AuthorDate: Sat Oct 24 00:15:38 2020 -0700

[Docker] Turn on Rust docs and MxNet based ResNet (#6640)

* Enable ResNet and Rust docs

* Tweak

* Format

* Fix issue with overwriting
---
 python/tvm/contrib/download.py   |  4 ++--
 rust/Cargo.toml  |  1 +
 rust/tvm/examples/resnet/build.rs| 10 --
 rust/tvm/examples/resnet/src/build_resnet.py |  5 +++--
 tests/scripts/task_python_docs.sh| 11 ---
 tests/scripts/task_rust.sh   |  6 ++
 6 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/python/tvm/contrib/download.py b/python/tvm/contrib/download.py
index 9603024..a521c8c 100644
--- a/python/tvm/contrib/download.py
+++ b/python/tvm/contrib/download.py
@@ -126,7 +126,7 @@ else:
 os.makedirs(TEST_DATA_ROOT_PATH, exist_ok=True)
 
 
-def download_testdata(url, relpath, module=None):
+def download_testdata(url, relpath, module=None, overwrite=False):
 """Downloads the test data from the internet.
 
 Parameters
@@ -155,5 +155,5 @@ def download_testdata(url, relpath, module=None):
 else:
 raise ValueError("Unsupported module: " + module)
 abspath = os.path.join(TEST_DATA_ROOT_PATH, module_path, relpath)
-download(url, abspath, overwrite=False, size_compare=False)
+download(url, abspath, overwrite=overwrite, size_compare=False)
 return abspath
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 9935ce7..28312a5 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -23,6 +23,7 @@ members = [
"tvm",
"tvm/tests/basics",
"tvm/tests/callback",
+   "tvm/examples/resnet",
"tvm-graph-rt",
"tvm-graph-rt/tests/test_tvm_basic",
"tvm-graph-rt/tests/test_tvm_dso",
diff --git a/rust/tvm/examples/resnet/build.rs 
b/rust/tvm/examples/resnet/build.rs
index 1e5d8a9..9bf7d86 100644
--- a/rust/tvm/examples/resnet/build.rs
+++ b/rust/tvm/examples/resnet/build.rs
@@ -21,9 +21,10 @@ use anyhow::{Context, Result};
 use std::{io::Write, path::Path, process::Command};
 
 fn main() -> Result<()> {
+let out_dir = std::env::var("CARGO_MANIFEST_DIR")?;
 let output = Command::new("python3")
 .arg(concat!(env!("CARGO_MANIFEST_DIR"), "/src/build_resnet.py"))
-.arg(!("--build-dir={}", env!("CARGO_MANIFEST_DIR")))
+.arg(!("--build-dir={}", out_dir))
 .output()
 .with_context(|| anyhow::anyhow!("failed to run python3"))?;
 if !output.status.success() {
@@ -33,7 +34,7 @@ fn main() -> Result<()> {
 panic!("Failed to execute build script");
 }
 assert!(
-Path::new(!("{}/deploy_lib.o", 
env!("CARGO_MANIFEST_DIR"))).exists(),
+Path::new(!("{}/deploy_lib.o", out_dir)).exists(),
 "Could not prepare demo: {}",
 String::from_utf8(output.stderr)
 .unwrap()
@@ -42,10 +43,7 @@ fn main() -> Result<()> {
 .last()
 .unwrap_or("")
 );
-println!(
-"cargo:rustc-link-search=native={}",
-env!("CARGO_MANIFEST_DIR")
-);
+println!("cargo:rustc-link-search=native={}", out_dir);
 
 Ok(())
 }
diff --git a/rust/tvm/examples/resnet/src/build_resnet.py 
b/rust/tvm/examples/resnet/src/build_resnet.py
index bc100fe..03ac611 100644
--- a/rust/tvm/examples/resnet/src/build_resnet.py
+++ b/rust/tvm/examples/resnet/src/build_resnet.py
@@ -104,10 +104,11 @@ def download_img_labels():
 ]
 )
 synset_name = "synset.txt"
-synset_path = download_testdata(synset_url, synset_name, module="data")
+synset_path = download_testdata(synset_url, synset_name + ".raw", 
module="data", overwrite=True)
 
 with open(synset_path) as fin:
-synset = eval(fin.read())
+data = fin.read()
+synset = eval(data)
 
     with open(synset_name, "w") as f:
 for key in synset:
diff --git a/tests/scripts/task_python_docs.sh 
b/tests/scripts/task_python_docs.sh
index e279b90..cbaffa2 100755
--- a/tests/scripts/task_python_docs.sh
+++ b/tests/scripts/task_python_docs.sh
@@ -73,12 +73,10 @@ npm install
 npm run typedoc
 cd ..
 
-# TODO(@jroesch): add Rust to CI container
-# see: https://github.com/apache/incubato

[incubator-tvm] branch main updated: [RELAY] Refactor FoldConstant to skip TNonComputationalOps (#6720)

2020-10-24 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/main by this push:
 new 372d737  [RELAY] Refactor FoldConstant to skip TNonComputationalOps 
(#6720)
372d737 is described below

commit 372d7374d221fb98f7e7fe5d9d5c937059a35515
Author: Lily Orth-Smith 
AuthorDate: Sat Oct 24 00:23:50 2020 -0700

[RELAY] Refactor FoldConstant to skip TNonComputationalOps (#6720)

* add TNonComputational to qnn ops and change FoldConstant

* remove comments

* check if op in nonComputational map

* forgot to mark device_copy op as TNonComputational

* hacky fix to fuseops pass

* fix typo

* manually skip device_copy in fold_constant

* Update src/relay/transforms/fold_constant.cc

Co-authored-by: Junru Shao 

Co-authored-by: Junru Shao 
---
 src/relay/qnn/op/concatenate.cc   | 1 +
 src/relay/qnn/op/convolution.cc   | 1 +
 src/relay/qnn/op/dense.cc | 1 +
 src/relay/qnn/op/dequantize.cc| 1 +
 src/relay/qnn/op/op_common.h  | 1 +
 src/relay/qnn/op/quantize.cc  | 1 +
 src/relay/qnn/op/requantize.cc| 1 +
 src/relay/transforms/fold_constant.cc | 9 ++---
 8 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/relay/qnn/op/concatenate.cc b/src/relay/qnn/op/concatenate.cc
index 29ecf45..88d2ecc 100644
--- a/src/relay/qnn/op/concatenate.cc
+++ b/src/relay/qnn/op/concatenate.cc
@@ -207,6 +207,7 @@ RELAY_REGISTER_OP("qnn.concatenate")
   "The quantization zero_point of the output tensor.")
 .set_support_level(11)
 .add_type_rel("QnnConcatenate", QnnConcatenateRel)
+.set_attr("TNonComputational", true)
 .set_attr("FTVMQnnCanonicalize", ConcatenateQnnCanonicalize)
 .set_attr("FInferCorrectLayout", 
QnnConcatenateLayout);
 
diff --git a/src/relay/qnn/op/convolution.cc b/src/relay/qnn/op/convolution.cc
index b2b6b09..73ee456 100644
--- a/src/relay/qnn/op/convolution.cc
+++ b/src/relay/qnn/op/convolution.cc
@@ -733,6 +733,7 @@ operator to understand how to scale back the int32 output 
to (u)int8.
   "The quantization zero_point of the weight tensor.")
 .set_support_level(11)
 .add_type_rel("QnnConv2D", QnnConv2DRel)
+.set_attr("TNonComputational", true)
 .set_attr("FTVMQnnCanonicalize", QnnConv2DCanonicalize)
 .set_attr("FInferCorrectLayout", 
QnnConvInferCorrectLayout);
 
diff --git a/src/relay/qnn/op/dense.cc b/src/relay/qnn/op/dense.cc
index 3cfc418..e1cbfaf 100644
--- a/src/relay/qnn/op/dense.cc
+++ b/src/relay/qnn/op/dense.cc
@@ -189,6 +189,7 @@ RELAY_REGISTER_OP("qnn.dense")
   "The quantization zero_point of the weight tensor.")
 .set_support_level(11)
 .add_type_rel("QDense", QnnDenseRel)
+.set_attr("TNonComputational", true)
 .set_attr("FTVMQnnCanonicalize", QnnDenseCanonicalize);
 
 
TVM_REGISTER_GLOBAL("relay.qnn.op._make.dense").set_body_typed(MakeQuantizedDense);
diff --git a/src/relay/qnn/op/dequantize.cc b/src/relay/qnn/op/dequantize.cc
index f0c139c..0a81f3f 100644
--- a/src/relay/qnn/op/dequantize.cc
+++ b/src/relay/qnn/op/dequantize.cc
@@ -136,6 +136,7 @@ The input is always quantized (int8, uint8) and will be 
converted to float32 giv
 .add_argument("input_zero_point", "Tensor", "The quantization zero_point 
of the input tensor.")
 .set_support_level(11)
 .add_type_rel("Dequantize", DequantizeRel)
+.set_attr("TNonComputational", true)
 .set_attr("FTVMQnnCanonicalize", DequantizeQnnCanonicalize);
 
 
TVM_REGISTER_GLOBAL("relay.qnn.op._make.dequantize").set_body_typed(MakeDequantize);
diff --git a/src/relay/qnn/op/op_common.h b/src/relay/qnn/op/op_common.h
index e99c11b..3ca8f64 100644
--- a/src/relay/qnn/op/op_common.h
+++ b/src/relay/qnn/op/op_common.h
@@ -215,6 +215,7 @@ static inline bool QnnBroadcastRel(const Array& 
types, int num_inputs, con
   .add_argument("output_scale", "Tensor", "The scale of the output 
tensor.")   \
   .add_argument("output_zero_point", "Tensor", "The zero_point of the 
output tensor.") \
   .add_type_rel("QnnBroadcast", QnnBroadcastRel)   
\
+  .set_attr("TNonComputational", true)  
\
   .set_attr("FInferCorrectLayout", 
QnnBinaryBroadcastLayout)
 
 }  // namespace qnn
diff --git a/src/relay/qnn/op/quantize.cc b/src/relay/qnn/op/quantize.cc
index 1b5cb5e..0784791 100644
--- a/src/relay/qnn/op/qu

[incubator-tvm] branch main updated (5051943 -> 8695a57)

2020-10-26 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 5051943  [TVMC] 'tvmc run' --rpc-tracker and --rpc-tracker fail due to 
argparse misconfiguration (#6762)
 add 8695a57  More CHECK to ICHECK (#6758)

No new revisions were added by this update.

Summary of changes:
 apps/cpp_rpc/main.cc |   2 +-
 apps/cpp_rpc/rpc_env.cc  |   2 +-
 apps/cpp_rpc/rpc_server.cc   |  18 +-
 apps/cpp_rpc/rpc_tracker_client.h|  14 +-
 apps/extension/src/tvm_ext.cc|   6 +-
 apps/howto_deploy/cpp_deploy.cc  |   6 +-
 apps/ios_rpc/tvmrpc/TVMRuntime.mm|   2 +-
 apps/ios_rpc/tvmrpc/ViewController.mm|   4 +-
 docs/contribute/error_handling.rst   |   4 +-
 docs/dev/convert_layout.rst  |   2 +-
 docs/dev/pass_infra.rst  |   6 +-
 docs/dev/relay_bring_your_own_codegen.rst|  12 +-
 nnvm/include/nnvm/graph.h|   4 +-
 nnvm/include/nnvm/layout.h   |  40 ++--
 nnvm/include/nnvm/op.h   |  12 +-
 nnvm/include/nnvm/tuple.h|   4 +-
 nnvm/src/core/graph.cc   |  10 +-
 nnvm/src/core/op.cc  |   2 +-
 nnvm/src/core/pass.cc|   2 +-
 nnvm/src/core/symbolic.cc|  22 +-
 nnvm/src/pass/correct_layout.cc  |  12 +-
 nnvm/src/pass/gradient.cc|  16 +-
 nnvm/src/pass/graph_algorithm.h  |  10 +-
 nnvm/src/pass/infer_shape_type.cc|  24 +--
 nnvm/src/pass/place_device.cc|  12 +-
 nnvm/src/pass/plan_memory.cc |   4 +-
 nnvm/src/pass/print_graph_ir.cc  |   2 +-
 nnvm/src/pass/saveload_json.cc   |  18 +-
 nnvm/tests/cpp/op_test.cc|   2 +-
 nnvm/tests/cpp/tuple_test.cc |   8 +-
 tests/cpp/arith_simplify_test.cc |   8 +-
 tests/cpp/attrs_test.cc  |  14 +-
 tests/cpp/auto_scheduler_test.cc |  48 ++---
 tests/cpp/build_module_test.cc   |  22 +-
 tests/cpp/container_test.cc  | 288 +--
 tests/cpp/expr_test.cc   |   6 +-
 tests/cpp/ir_functor_test.cc |  48 ++---
 tests/cpp/object_protocol_test.cc|  36 ++--
 tests/cpp/packed_func_test.cc| 138 ++---
 tests/cpp/parallel_for_test.cc   |  15 +-
 tests/cpp/pattern_match_test.cc  | 114 +--
 tests/cpp/relay_build_module_test.cc |  24 +--
 tests/cpp/relay_pass_type_infer_test.cc  |   4 +-
 tests/cpp/relay_transform_sequential_test.cc |  10 +-
 tests/cpp/target_test.cc |  36 ++--
 tests/cpp/tir_analysis_side_effect.cc|  10 +-
 46 files changed, 552 insertions(+), 551 deletions(-)



[incubator-tvm] branch main updated (e59c603 -> 3ccd221)

2020-10-26 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from e59c603  [ARITH] iter_affine_map bug fix, stride generalize (#6753)
 add 3ccd221  [FIX,PYLINT] Fix pylint errors on MacOS with Python 3.8 
(#6746)

No new revisions were added by this update.

Summary of changes:
 python/tvm/autotvm/tuner/ga_tuner.py   | 4 ++--
 python/tvm/relay/frontend/onnx.py  | 2 +-
 python/tvm/relay/frontend/pytorch.py   | 1 +
 python/tvm/relay/frontend/qnn_torch.py | 1 +
 python/tvm/relay/frontend/tensorflow_parser.py | 2 +-
 python/tvm/relay/testing/darknet.py| 2 +-
 6 files changed, 7 insertions(+), 5 deletions(-)



[incubator-tvm] branch master updated (75b8318 -> fa2213f)

2020-08-11 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 75b8318  [Ansor][AutoTVM v2.0] Phase 2: Basic CPU Sketch Search Policy 
(#6184)
 add fa2213f  [Parser] Parser 2.0 part 2  (#6162)

No new revisions were added by this update.

Summary of changes:
 .gitignore  |4 -
 CMakeLists.txt  |3 -
 cmake/modules/ANTLR.cmake   |   40 -
 cmake/util/FindANTLR.cmake  |   65 -
 docker/Dockerfile.ci_cpu|3 -
 docker/Dockerfile.ci_gpu|3 -
 docker/Dockerfile.ci_wasm   |3 -
 docker/install/ubuntu_install_antlr.sh  |   25 -
 docker/install/ubuntu_install_python_package.sh |2 +-
 docs/README.txt |4 +-
 docs/install/from_source.rst|7 -
 include/tvm/ir/attrs.h  |3 +-
 include/tvm/ir/span.h   |   19 +-
 include/tvm/parser/parser.h |2 +-
 include/tvm/parser/source_map.h |  110 +
 include/tvm/relay/adt.h |3 +-
 include/tvm/relay/expr.h|   40 +-
 include/tvm/relay/expr_functor.h|1 +
 include/tvm/relay/function.h|3 +-
 python/setup.py |3 +-
 python/tvm/error.py |7 +
 python/tvm/ir/base.py   |4 +-
 python/tvm/parser/__init__.py   |2 +-
 python/tvm/relay/__init__.py|6 +-
 python/tvm/relay/_parser.py |  771 -
 python/tvm/relay/expr.py|2 +-
 python/tvm/relay/grammar/.gitignore |1 -
 python/tvm/relay/grammar/Relay.g4   |  199 --
 python/tvm/relay/grammar/__init__.py|   16 -
 python/tvm/relay/grammar/py3/.gitattributes |3 -
 python/tvm/relay/grammar/py3/RelayLexer.py  |  256 --
 python/tvm/relay/grammar/py3/RelayParser.py | 3732 ---
 python/tvm/relay/grammar/py3/RelayVisitor.py|  343 ---
 python/tvm/relay/grammar/py3/__init__.py|   16 -
 python/tvm/relay/parser.py  |   30 -
 python/tvm/relay/std/core.rly   |3 +-
 python/tvm/relay/std/gradient.rly   |3 +-
 python/tvm/relay/std/prelude.rly|6 +-
 src/ir/module.cc|6 +-
 src/ir/span.cc  |   26 +-
 src/parser/diagnostic.h |  179 +-
 src/parser/meta_ref.cc  |  100 +
 src/parser/meta_ref.h   |   85 +
 src/parser/op_table.h   |   20 +-
 src/parser/parser.cc|  832 +++--
 src/parser/source_map.cc|  113 +
 src/parser/token.h  |  349 ++-
 src/parser/tokenizer.h  |  306 +-
 src/printer/relay_text_printer.cc   |7 +-
 src/printer/text_printer.cc |   16 +-
 src/printer/text_printer.h  |   18 +-
 src/relay/ir/adt.cc |3 +-
 src/relay/ir/expr.cc|   30 +-
 src/relay/ir/expr_functor.cc|   62 +-
 src/relay/ir/function.cc|3 +-
 src/relay/transforms/type_infer.cc  |   16 +-
 src/runtime/graph/graph_runtime.h   |1 +
 tests/lint/rat-excludes |5 -
 tests/python/relay/test_ir_nodes.py |   12 +-
 tests/python/relay/test_ir_parser.py|  320 +-
 tests/python/relay/test_ir_parser2.py   |  891 --
 tests/python/relay/test_ir_text_printer.py  |   75 +-
 tests/python/relay/test_op_level10.py   |8 +-
 tests/python/relay/test_pass_eta_expand.py  |   24 +-
 tests/python/relay/test_pass_unmatched_cases.py |4 +-
 65 files changed, 1902 insertions(+), 7352 deletions(-)
 delete mode 100644 cmake/modules/ANTLR.cmake
 delete mode 100644 cmake/util/FindANTLR.cmake
 delete mode 100755 docker/install/ubuntu_install_antlr.sh
 create mode 100644 include/tvm/parser/source_map.h
 delete mode 100644 python/tvm/relay/_parser.py
 delete mode 100644 python/tvm/relay/grammar/.gitignore
 delete mode 100644 python/tvm/relay/grammar/Relay.g4
 delete mode 100644 python/tvm/relay/grammar/__init__.py
 delete mode 100644 python/tvm/relay/grammar/py3/.gitattributes
 delete mode 100644 python/tvm/relay/grammar/py3/RelayLexer.py
 delete mode 100644 python/tvm/relay/grammar/py3/RelayParser.py
 delete mode 100644 python/tvm/relay/grammar/py3/RelayVisitor.py
 delete mode 100644 python/tvm

[incubator-tvm] branch master updated: [REFACTOR][RELAY] Move invoke_tvm_op and shape_func to vm dialect (#5958)

2020-07-10 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new ba04c6a  [REFACTOR][RELAY] Move invoke_tvm_op and shape_func to vm 
dialect (#5958)
ba04c6a is described below

commit ba04c6a393371d539ea8ee417520c7909521a370
Author: Zhi <5145158+zhi...@users.noreply.github.com>
AuthorDate: Fri Jul 10 11:03:23 2020 -0700

[REFACTOR][RELAY] Move invoke_tvm_op and shape_func to vm dialect (#5958)

* [REFACTOR][RELAY] Move invoke_tvm_op and shape_func to vm dialect

* address comments
---
 include/tvm/relay/attrs/memory.h   |  13 ---
 include/tvm/relay/attrs/vm.h   |  47 +++
 python/tvm/relay/op/__init__.py|   2 +-
 python/tvm/relay/op/memory/memory.py   |  40 -
 python/tvm/relay/op/vm/__init__.py |   2 +-
 python/tvm/relay/op/vm/vm.py   |  48 +++
 python/tvm/relay/transform/memory_alloc.py |   4 +-
 src/relay/backend/vm/compiler.cc   |   4 +-
 src/relay/op/memory/memory.cc  | 124 
 src/relay/op/vm/vm.cc  | 127 +
 src/relay/transforms/fold_constant.cc  |   4 +-
 11 files changed, 230 insertions(+), 185 deletions(-)

diff --git a/include/tvm/relay/attrs/memory.h b/include/tvm/relay/attrs/memory.h
index 7429c39..b737103 100644
--- a/include/tvm/relay/attrs/memory.h
+++ b/include/tvm/relay/attrs/memory.h
@@ -74,19 +74,6 @@ struct AllocTensorAttrs : public 
tvm::AttrsNode {
   }
 };
 
-/*!
- * \brief Options for the shape function operator.
- */
-struct ShapeFuncAttrs : public tvm::AttrsNode {
-  Array is_input;
-
-  TVM_DECLARE_ATTRS(ShapeFuncAttrs, "relay.attrs.ShapeFuncAttrs") {
-TVM_ATTR_FIELD(is_input).describe(
-"A bool indicating whether the shape function should"
-"expect shape or input in each position.");
-  }
-};
-
 }  // namespace relay
 }  // namespace tvm
 #endif  // TVM_RELAY_ATTRS_MEMORY_H_
diff --git a/include/tvm/relay/attrs/vm.h b/include/tvm/relay/attrs/vm.h
new file mode 100644
index 000..9144f47
--- /dev/null
+++ b/include/tvm/relay/attrs/vm.h
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file tvm/relay/attrs/vm.h
+ * \brief Attributes for Relay vm operators.
+ */
+#ifndef TVM_RELAY_ATTRS_VM_H_
+#define TVM_RELAY_ATTRS_VM_H_
+
+#include 
+
+namespace tvm {
+namespace relay {
+
+/*!
+ * \brief Options for the shape function operator.
+ */
+struct ShapeFuncAttrs : public tvm::AttrsNode {
+  Array is_input;
+
+  TVM_DECLARE_ATTRS(ShapeFuncAttrs, "relay.attrs.ShapeFuncAttrs") {
+TVM_ATTR_FIELD(is_input).describe(
+"A bool indicating whether the shape function should"
+"expect shape or input in each position.");
+  }
+};
+
+}  // namespace relay
+}  // namespace tvm
+#endif  // TVM_RELAY_ATTRS_VM_H_
diff --git a/python/tvm/relay/op/__init__.py b/python/tvm/relay/op/__init__.py
index a45d466..011042b 100644
--- a/python/tvm/relay/op/__init__.py
+++ b/python/tvm/relay/op/__init__.py
@@ -27,7 +27,7 @@ from .reduce import *
 from .tensor import *
 from .transform import *
 from .algorithm import *
-from .vm import *
+from . import vm
 from . import nn
 from . import annotation
 from . import memory
diff --git a/python/tvm/relay/op/memory/memory.py 
b/python/tvm/relay/op/memory/memory.py
index 4092545..b426a0e 100644
--- a/python/tvm/relay/op/memory/memory.py
+++ b/python/tvm/relay/op/memory/memory.py
@@ -19,27 +19,6 @@
 from __future__ import absolute_import as _abs
 from . import _make
 
-def invoke_tvm_op(func, inputs, outputs):
-"""Call a primitive function with the TVM operator calling convention.
-
-Parameters
---
-func : tvm.relay.Expr
-The input expr.
-
-inputs : tvm.relay.Expr
-A tuple of the inputs to pass to the TVM function.
-
-outputs : tvm.relay.Expr
-A tuple of the outputs to pass to the TVM fu

[incubator-tvm] branch master updated (ef9bf7d -> aa84ee2)

2020-06-23 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from ef9bf7d  Fix the python intrin rule (#5895)
 add aa84ee2  Rust Refactor Stage 4: Rewrite Rust graph runtime to use new 
APIs (#5830)

No new revisions were added by this update.

Summary of changes:
 rust/Cargo.toml|  5 ++
 rust/runtime/src/graph.rs  |  1 +
 rust/{runtime => tvm-graph-rt}/Cargo.toml  | 13 ++--
 rust/{runtime => tvm-graph-rt}/src/allocator.rs|  0
 rust/{runtime => tvm-graph-rt}/src/array.rs| 70 +-
 rust/{runtime => tvm-graph-rt}/src/errors.rs   |  2 +
 rust/{runtime => tvm-graph-rt}/src/graph.rs| 60 +--
 rust/{runtime => tvm-graph-rt}/src/lib.rs  | 23 ++-
 rust/{runtime => tvm-graph-rt}/src/module/dso.rs   |  4 +-
 rust/{runtime => tvm-graph-rt}/src/module/mod.rs   | 12 ++--
 .../{runtime => tvm-graph-rt}/src/module/syslib.rs |  4 +-
 rust/{runtime => tvm-graph-rt}/src/threading.rs|  2 +-
 rust/{runtime => tvm-graph-rt}/src/workspace.rs|  2 +-
 rust/{runtime => tvm-graph-rt}/tests/.gitignore|  0
 .../{runtime => tvm-graph-rt}/tests/build_model.py |  0
 .../tests/test_graph_serde.rs  |  0
 .../tests/test_nn/Cargo.toml   |  4 +-
 .../tests/test_nn/build.rs |  0
 .../tests/test_nn/src/build_test_graph.py  |  0
 .../tests/test_nn/src/main.rs  |  0
 .../tests/test_tvm_basic/Cargo.toml|  4 +-
 .../tests/test_tvm_basic/build.rs  |  0
 .../tests/test_tvm_basic/src/build_test_lib.py |  0
 .../tests/test_tvm_basic/src/main.rs   |  0
 .../tests/test_tvm_dso/Cargo.toml  |  4 +-
 .../tests/test_tvm_dso/build.rs|  0
 .../tests/test_tvm_dso/src/build_test_lib.py   |  0
 .../tests/test_tvm_dso/src/main.rs |  0
 .../tests/test_wasm32/.cargo/config|  0
 .../tests/test_wasm32/Cargo.toml   |  4 +-
 .../tests/test_wasm32/build.rs |  0
 .../tests/test_wasm32/src/build_test_lib.py|  0
 .../tests/test_wasm32/src/main.rs  |  0
 rust/tvm-sys/build.rs  |  1 +
 rust/tvm-sys/src/array.rs  |  1 +
 rust/tvm-sys/src/datatype.rs   | 14 -
 tests/lint/check_file_type.py  |  1 +
 37 files changed, 110 insertions(+), 121 deletions(-)
 copy rust/{runtime => tvm-graph-rt}/Cargo.toml (83%)
 copy rust/{runtime => tvm-graph-rt}/src/allocator.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/src/array.rs (86%)
 copy rust/{runtime => tvm-graph-rt}/src/errors.rs (98%)
 copy rust/{runtime => tvm-graph-rt}/src/graph.rs (93%)
 copy rust/{runtime => tvm-graph-rt}/src/lib.rs (84%)
 copy rust/{runtime => tvm-graph-rt}/src/module/dso.rs (96%)
 copy rust/{runtime => tvm-graph-rt}/src/module/mod.rs (85%)
 copy rust/{runtime => tvm-graph-rt}/src/module/syslib.rs (95%)
 copy rust/{runtime => tvm-graph-rt}/src/threading.rs (99%)
 copy rust/{runtime => tvm-graph-rt}/src/workspace.rs (99%)
 copy rust/{runtime => tvm-graph-rt}/tests/.gitignore (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/build_model.py (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_graph_serde.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_nn/Cargo.toml (94%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_nn/build.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_nn/src/build_test_graph.py 
(100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_nn/src/main.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_basic/Cargo.toml (93%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_basic/build.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_basic/src/build_test_lib.py 
(100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_basic/src/main.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_dso/Cargo.toml (93%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_dso/build.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_dso/src/build_test_lib.py 
(100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_tvm_dso/src/main.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_wasm32/.cargo/config (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_wasm32/Cargo.toml (94%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_wasm32/build.rs (100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_wasm32/src/build_test_lib.py 
(100%)
 copy rust/{runtime => tvm-graph-rt}/tests/test_wasm32/src/main.rs (100%)



[incubator-tvm] branch master updated: `tvm` crate stage 3 of Rust refactor (#5769)

2020-06-18 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new d8c80c3   `tvm` crate stage 3 of Rust refactor  (#5769)
d8c80c3 is described below

commit d8c80c382f02052b07da1235190a5b6c7acea994
Author: Jared Roesch 
AuthorDate: Thu Jun 18 11:33:25 2020 -0700

 `tvm` crate stage 3 of Rust refactor  (#5769)

* Adapt to new macro

* Add tvm crate

* Fix out of tree pass with new bindings

* Super slick API working

* Add examples

* Delay egg example and add ASF headers

* Move array.rs around

* Remove outdated tests will restore in CI PR

* Fix some memory issues

* Fix ref counting issue

* Formatting and cleanup

* Remove out-of-tree for now

* Remove out-of-tree
---
 rust/Cargo.toml|   4 +-
 rust/runtime/tests/test_wasm32/Cargo.toml  |   4 +
 rust/runtime/tests/test_wasm32/build.rs|  14 +-
 rust/tvm-macros/src/external.rs|   6 +-
 rust/tvm-macros/src/object.rs  |  31 ++-
 rust/tvm-rt/src/array.rs   |  79 ++
 rust/tvm-rt/src/errors.rs  |   2 +
 rust/tvm-rt/src/function.rs|  20 +-
 rust/tvm-rt/src/lib.rs |   4 +-
 rust/tvm-rt/src/ndarray.rs |  22 +-
 rust/tvm-rt/src/object/mod.rs  |  53 ++--
 rust/tvm-rt/src/object/object_ptr.rs   | 101 ++--
 rust/tvm-rt/src/string.rs  |  42 +--
 rust/tvm-rt/src/to_function.rs |  56 ++--
 rust/tvm-sys/src/lib.rs|  12 +
 rust/tvm/.gitignore|   7 +
 .../test_wasm32/Cargo.toml => tvm/.travis.yml} |  14 +-
 rust/{runtime/tests/test_wasm32 => tvm}/Cargo.toml |  27 +-
 rust/tvm/README.md | 235 +
 rust/tvm/src/ir/mod.rs |  50 
 rust/tvm/src/ir/relay/mod.rs   | 282 +
 rust/tvm/src/lib.rs|  47 
 rust/tvm/src/runtime/mod.rs|  20 ++
 rust/tvm/src/transform.rs  |  93 +++
 src/printer/relay_text_printer.cc  |   2 -
 25 files changed, 1075 insertions(+), 152 deletions(-)

diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 6849c03..d9bb3ab 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -29,5 +29,7 @@ members = [
"frontend/tests/callback",
"frontend/examples/resnet",
"tvm-sys",
-   "tvm-rt"
+   "tvm-macros",
+   "tvm-rt",
+   "tvm",
 ]
diff --git a/rust/runtime/tests/test_wasm32/Cargo.toml 
b/rust/runtime/tests/test_wasm32/Cargo.toml
index 1d3373a..eeead45 100644
--- a/rust/runtime/tests/test_wasm32/Cargo.toml
+++ b/rust/runtime/tests/test_wasm32/Cargo.toml
@@ -20,7 +20,11 @@ name = "test-wasm32"
 version = "0.0.0"
 license = "Apache-2.0"
 authors = ["TVM Contributors"]
+edition = "2018"
 
 [dependencies]
 ndarray="0.12"
 tvm-runtime = { path = "../../" }
+
+[build-dependencies]
+anyhow = "^1.0"
diff --git a/rust/runtime/tests/test_wasm32/build.rs 
b/rust/runtime/tests/test_wasm32/build.rs
index 8b72be2..5c816c3 100644
--- a/rust/runtime/tests/test_wasm32/build.rs
+++ b/rust/runtime/tests/test_wasm32/build.rs
@@ -19,12 +19,14 @@
 
 use std::{path::PathBuf, process::Command};
 
-fn main() {
+use anyhow::{Context, Result};
+
+fn main() -> Result<()> {
 let mut out_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
 out_dir.push("lib");
 
 if !out_dir.is_dir() {
-std::fs::create_dir(_dir).unwrap();
+std::fs::create_dir(_dir).context("failed to create directory for 
WASM outputs")?;
 }
 
 let obj_file = out_dir.join("test.o");
@@ -36,7 +38,8 @@ fn main() {
 ))
 .arg(_dir)
 .output()
-.expect("Failed to execute command");
+.context("failed to execute Python script for generating TVM library")?;
+
 assert!(
 obj_file.exists(),
 "Could not build tvm lib: {}",
@@ -49,12 +52,14 @@ fn main() {
 );
 
 let ar = option_env!("LLVM_AR").unwrap_or("llvm-ar-8");
+
 let output = Command::new(ar)
 .arg("rcs")
 .arg(_file)
 .arg(_file)
 .output()
-.expect("Failed to execute command");
+.context("failed to run LLVM_AR command")?;
+
 assert!(
 lib_file.exis

[incubator-tvm] branch egg created (now d8c80c3)

2020-06-18 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch egg
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at d8c80c3   `tvm` crate stage 3 of Rust refactor  (#5769)

No new revisions were added by this update.



[incubator-tvm] branch master updated: [Rust] Second stage of Rust Refactor (#5527)

2020-06-10 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
 new 60cfb79  [Rust] Second stage of Rust Refactor (#5527)
60cfb79 is described below

commit 60cfb79ce79eb47e4cebc04321fee7f67bfd404b
Author: Jared Roesch 
AuthorDate: Wed Jun 10 02:07:19 2020 -0700

[Rust] Second stage of Rust Refactor (#5527)

* Add tvm-rt crate

* Backport changes from frontend branch

* Format

* Add ASF headers

* Address self-code review

* Replace with helper

* Fix lint

* Fix

* Clean up repro debugging

* WIP

* Remove global resgistry to fix one memory issue

* Fix

* Format

* Format

* Update rust/tvm-rt/README.md

Co-authored-by: Jason Knight 

* Format

* Duplicate TVM macros

* Split macros

* Restore old macro for old crates

* Repair macros

* Fix format

* Format

Co-authored-by: Jason Knight 
---
 include/tvm/ir/expr.h  |   2 +
 include/tvm/runtime/c_runtime_api.h|  19 +
 include/tvm/runtime/container.h|  17 +-
 python/tvm/runtime/object_generic.py   |   2 +-
 rust/Cargo.toml|   3 +-
 rust/macros/Cargo.toml |   6 +-
 rust/runtime/Cargo.toml|   2 +-
 rust/runtime/src/lib.rs|   1 +
 rust/{macros => tvm-macros}/Cargo.toml |   4 +-
 rust/tvm-macros/src/external.rs| 160 
 rust/tvm-macros/src/import_module.rs   | 133 +++
 .../src/errors.rs => tvm-macros/src/lib.rs}|  37 +-
 rust/tvm-macros/src/object.rs  | 163 
 .../src/errors.rs => tvm-macros/src/util.rs}   |  32 +-
 rust/tvm-rt/.gitignore |   7 +
 rust/{runtime => tvm-rt}/Cargo.toml|  34 +-
 rust/tvm-rt/README.md  |  60 +++
 rust/tvm-rt/src/context.rs |  97 +
 rust/tvm-rt/src/errors.rs  |  78 
 rust/tvm-rt/src/function.rs| 303 ++
 rust/tvm-rt/src/lib.rs | 130 ++
 rust/tvm-rt/src/module.rs  | 129 ++
 rust/tvm-rt/src/ndarray.rs | 438 +
 rust/tvm-rt/src/object/mod.rs  | 117 ++
 rust/tvm-rt/src/object/object_ptr.rs   | 353 +
 rust/tvm-rt/src/string.rs  |  92 +
 rust/tvm-rt/src/to_boxed_fn.rs | 227 +++
 rust/tvm-rt/src/to_function.rs | 307 +++
 rust/tvm-rt/src/value.rs   | 161 
 rust/tvm-sys/src/byte_array.rs |  36 ++
 rust/tvm-sys/src/datatype.rs   |  10 +
 rust/tvm-sys/src/errors.rs |   2 +-
 rust/tvm-sys/src/lib.rs|   9 +-
 src/ir/expr.cc |   7 +
 src/printer/relay_text_printer.cc  |   7 +
 src/relay/transforms/to_cps.cc |   2 +-
 src/runtime/object.cc  |  13 +
 src/runtime/object_internal.h  |   9 +
 38 files changed, 3131 insertions(+), 78 deletions(-)

diff --git a/include/tvm/ir/expr.h b/include/tvm/ir/expr.h
index 6797f16..b2ce50d 100644
--- a/include/tvm/ir/expr.h
+++ b/include/tvm/ir/expr.h
@@ -37,6 +37,8 @@
 
 namespace tvm {
 
+using tvm::runtime::String;
+
 /*!
  * \brief Base type of all the expressions.
  * \sa Expr
diff --git a/include/tvm/runtime/c_runtime_api.h 
b/include/tvm/runtime/c_runtime_api.h
index bf24f99..213c705 100644
--- a/include/tvm/runtime/c_runtime_api.h
+++ b/include/tvm/runtime/c_runtime_api.h
@@ -515,6 +515,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.
  *
  * \param obj The object handle.
@@ -564,6 +573,16 @@ TVM_DLL int TVMDeviceCopyDataFromTo(const void* from, 
size_t from_offset, void*
 TVMContext ctx_to, DLDataType type_hint,
 TVMStreamHandle stream);
 
+/*!
+ * \brief Check that an object is derived from another

[incubator-tvm] 01/02: Adapt to new macro

2020-06-10 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit fcdfffa2adfce22244ed19d3234060d7f4968147
Author: Jared Roesch 
AuthorDate: Wed Jun 10 02:29:39 2020 -0700

Adapt to new macro
---
 rust/Cargo.toml   | 4 +++-
 rust/runtime/tests/test_wasm32/Cargo.toml | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 6849c03..c0d0bb8 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -29,5 +29,7 @@ members = [
"frontend/tests/callback",
"frontend/examples/resnet",
"tvm-sys",
-   "tvm-rt"
+   "tvm-macros",
+   "tvm-rt",
+   "tvm"
 ]
diff --git a/rust/runtime/tests/test_wasm32/Cargo.toml 
b/rust/runtime/tests/test_wasm32/Cargo.toml
index 1d3373a..51f15ff 100644
--- a/rust/runtime/tests/test_wasm32/Cargo.toml
+++ b/rust/runtime/tests/test_wasm32/Cargo.toml
@@ -22,5 +22,6 @@ license = "Apache-2.0"
 authors = ["TVM Contributors"]
 
 [dependencies]
+anyhow = "*"
 ndarray="0.12"
 tvm-runtime = { path = "../../" }



[incubator-tvm] 02/02: Add tvm crate

2020-06-10 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 43325abcdf9b1aa8d405a9769aa43dc12f66112d
Author: Jared Roesch 
AuthorDate: Wed Jun 10 02:30:10 2020 -0700

Add tvm crate
---
 rust/tvm/.gitignore  |   7 +
 rust/tvm/.travis.yml |  22 +++
 rust/tvm/Cargo.toml  |  45 +
 rust/tvm/README.md   | 235 +++
 rust/tvm/examples/resnet/Cargo.toml  |  29 
 rust/tvm/examples/resnet/README.md   |  45 +
 rust/tvm/examples/resnet/build.rs|  42 +
 rust/tvm/examples/resnet/src/build_resnet.py | 134 +++
 rust/tvm/examples/resnet/src/main.rs | 160 ++
 rust/tvm/src/ir/array.rs |  74 +
 rust/tvm/src/ir/mod.rs   |  17 ++
 rust/tvm/src/ir/relay/mod.rs | 232 ++
 rust/tvm/src/lib.rs  |  47 ++
 rust/tvm/src/runtime/mod.rs  |   1 +
 rust/tvm/src/transform.rs|  42 +
 rust/tvm/tests/basics/.gitignore |   7 +
 rust/tvm/tests/basics/Cargo.toml |  32 
 rust/tvm/tests/basics/build.rs   |  46 ++
 rust/tvm/tests/basics/src/main.rs|  55 +++
 rust/tvm/tests/basics/src/tvm_add.py |  50 ++
 rust/tvm/tests/callback/Cargo.toml   |  26 +++
 rust/tvm/tests/callback/src/bin/array.rs |  72 
 rust/tvm/tests/callback/src/bin/error.rs |  56 +++
 rust/tvm/tests/callback/src/bin/float.rs |  50 ++
 rust/tvm/tests/callback/src/bin/int.rs   |  49 ++
 rust/tvm/tests/callback/src/bin/string.rs|  54 ++
 rust/tvm/tests/test_ir.rs|  37 +
 27 files changed, 1666 insertions(+)

diff --git a/rust/tvm/.gitignore b/rust/tvm/.gitignore
new file mode 100644
index 000..2430329
--- /dev/null
+++ b/rust/tvm/.gitignore
@@ -0,0 +1,7 @@
+target
+**/*.rs.bk
+Cargo.lock
+/tests/basics/add_*
+/examples/resnet/deploy_*
+/examples/resnet/*.png
+/examples/resnet/synset.*
diff --git a/rust/tvm/.travis.yml b/rust/tvm/.travis.yml
new file mode 100644
index 000..e963b7c
--- /dev/null
+++ b/rust/tvm/.travis.yml
@@ -0,0 +1,22 @@
+# 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.
+
+language: rust
+rust:
+  - nightly
+matrix:
+  fast_finish: true
diff --git a/rust/tvm/Cargo.toml b/rust/tvm/Cargo.toml
new file mode 100644
index 000..ebfb5e6
--- /dev/null
+++ b/rust/tvm/Cargo.toml
@@ -0,0 +1,45 @@
+# 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.
+
+[package]
+name = "tvm"
+version = "0.1.0"
+license = "Apache-2.0"
+description = "Rust frontend support for TVM"
+repository = "https://github.com/apache/incubator-tvm;
+homepage = "https://github.com/apache/incubator-tvm;
+readme = "README.md"
+keywords = ["rust", "tvm"]
+categories = ["api-bindings", "science"]
+authors = ["TVM Contributors"]
+edition = "2018"
+
+[dependencies]
+thiserror = "^1.0"
+anyhow = "^1.0"
+lazy_static = "1.1"
+ndarray = "0.12"
+num-traits = "0.2"
+tvm-rt = { version = "0.1", path = &

[incubator-tvm] branch rust-tvm updated (caa6904 -> 43325ab)

2020-06-10 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


 discard caa6904  All tests pass
 discard 0c55c39  Finish removing anyhow and work with new external! macro
 discard 62b6d1ba Convert external macro to procmacro
 discard fc6fac2  Reworking errors and proc macros
 discard a44a379  Refactor anyhow out of the rt layer
 discard 4cf2dbc  Add tvm crate
 discard 9fc0d4a  Add tvm-rt crate
 add 95b3ad9  [PatternLang] Add ConstantPattern (#5689)
 add 2599c2c  [PYTORCH]Minor bug fixes (#5683)
 add 05b1b23  [Relay] Fix dataflow_pattern.rewrite() hang if Match in IR 
(#5680)
 add 3698d5d  [RELAY] Fix segfault in pretty print when ObjectRef is null 
(#5681)
 add ddf7190  [REFACTOR][RELAY] move fallback_device to config (#5690)
 add 3ee2270  @zhiics -> PPMC (#5692)
 add 06bf8b0  [COMMUNITY] @masahi -> PPMC (#5691)
 add a9ce2f7  Support more dtypes for TVMDSOOp (#5694)
 add ff10e6c  [ONNX]LpPool Support added (#5696)
 add 1ae7162  In memory_plan, check if value is not None, instead of just 
checking value as boolean. (#5700)
 add 2cd5117  [PatternLang]Conditionally Embedding Constants in Partitioned 
Functions (#5693)
 add 879158a  [ONNX] Skip ADD inside Gemm op when vector is zero (#5697)
 add 910edef  [BYOC] Support Tuple Output in C/DNNL Codegen (#5701)
 add c55ed37  [REFACTOR][RELAY] Replace build_config with PassContext 
(#5698)
 add 55aefc2  [PYTORCH]floor_divide support for squeezenet (#5702)
 add 12cfe4a  [AutoTVM][TOPI] Fix bifrost spatial packing conv2d auto tune 
(#5684)
 add b0959d4  [Arith] ExtendedEuclidean merge impl to int_operator (#5625)
 add f280883  fix typo: anchor windoes should be anchor windows (#5706)
 add afc239a  [REFACTOR][PY] relay.op.Op -> tvm.ir.Op (#5705)
 add 43162d6  [PatternLang] Simplify Pattern API Implementations (#5703)
 add 663a5ab  [PYTORCH]ReplicationPad support added (#5708)
 add f272e06  Remove deprecated opengl files (#5711)
 add 13277a5  Remove opengl runtime and cmake (#5712)
 add 3d06063  [BUGFIX][CRT] Fix Compilation Error in CRT (#5713)
 add 062a244  Rename tvm_dso_op to libtvm_dso_op (#5714)
 add 4347b41  [Object] Unify StrMapNode and MapNode (#5687)
 add c1f3b2f  [MXNET]Softmin, trunc op support added (#5715)
 add 927510a  Avoid downloading when TOPHUB_LOCATION is NONE (#5720)
 add 9151a51  [Object][FFI] Introduce runtime::String::CanConvertFrom 
(#5718)
 add 64ac555  [Object] Restore the StrMap behavior in JSON/SHash/SEqual 
(#5719)
 add 36aa895  Fix generating types like float44 and float88 (#5722)
 add 3d61dc8  [ONNX]ReduceL1, ReduceL2, ReduceSumSquare, ReduceLogSum ops 
added (#5721)
 add 43dcbc6  [TENSORFLOW]StatefulPartitionedCall/PartitionedCall Ops 
support added  (#5617)
 add a642089  [AutoTVM, Relay] Clear compile engine after task extraction 
(#5724)
 add 8935990  Fix runtime::String backward compatibility in JSON (#5725)
 add 490510d  codegen llvm: move nvptx-specific intrinsic handling into 
codegen_nvptx (#5726)
 add c2e248f  [TOPI,RELAY][TFLITE] Sparse to dense operator (#5447)
 add 34c95a8  [Frontend][TFLite] Add parser support for shape and range 
(#5329)
 add 8a98782  [REFACTOR] Separate ArgTypeCode from DLDataTypeCode (#5730)
 add fbc2b87  [ONNX]MaxRoiPool, Mod & Xor op support added (#5729)
 add e1b1171  ROCm: Add warp shuffles and enable reductions (#5727)
 add fee5d54  Change 'delete's in Relay VM Instruction dtor to 'delete[]'s 
(#5735)
 add 24597f0  Fix reshape usage in ARM Winograd (#5732)
 add 592711e  [TEST] Fix flaky 
topi/tests/python/test_topi_pooling.py:test_adaptive_pool (#5736)
 add de54754  Fix the values for test_fmod since it fails way too often 
otherwise (#5723)
 add 2ec7caa  fix small bug about dense_grad (#5695)
 add a643eb7  [REFACTOR][ARITH] Remove legacy compute_expr.h (#5738)
 add aa23e72  Add some docs on downstream consistency (#5742)
 add 7053546  sequential cpp test (#5745)
 add 6ae439c  [REFACTOR][TE][TIR] Call::Halide => ProducerLoad, DSL/TIR 
decouple. (#5743)
 add 2e1ef8e  Don't add cast for TF batch norm when type isn't changing 
(#5731)
 add 0ea9969  [ARITH][BACKPORT-0.6] fix a min/max simplify bug (#5749)
 add aa80857  [TOPI][Relay][OP] support dynamic NMS(Non Maximum 
Suppression), symbolic begin, end, and strides for strided_slice (#4312)
 add 9f79199  Add Scatter to Topi/Relay/ONNX via hybrid script (#5619)
 add e0e03a1  [Minor][Test] Clean WASM environment before build (#5759)
 add 54641ec  [Bugfix] Fix reshape (#5739)
 add 10bff27  [REFACTOR][TIR] Provide->ProducerStore, 
Realize->ProducerRealize. (#5750)
 add 60cfb79  [Rust] Second stage of Rust Refactor (#5527)
 new fcdfffa  Adapt to new macro
 new 43325ab  Add tvm crate

[incubator-tvm] 04/04: All tests pass

2020-06-08 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit caa6904a4d070abf1f957a51c23ba7d553e364be
Author: Jared Roesch 
AuthorDate: Mon Jun 8 14:01:09 2020 -0700

All tests pass
---
 rust/tvm-rt/Cargo.toml  | 3 +++
 rust/tvm-rt/src/function.rs | 6 +++---
 rust/tvm-rt/src/lib.rs  | 6 +++---
 rust/tvm-rt/src/ndarray.rs  | 6 +++---
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/rust/tvm-rt/Cargo.toml b/rust/tvm-rt/Cargo.toml
index b234da1..00e225f 100644
--- a/rust/tvm-rt/Cargo.toml
+++ b/rust/tvm-rt/Cargo.toml
@@ -39,5 +39,8 @@ paste = "0.1"
 mashup = "0.1"
 once_cell = "^1.3.1"
 
+[dev-dependencies]
+anyhow = "^1.0"
+
 [features]
 blas = ["ndarray/blas"]
diff --git a/rust/tvm-rt/src/function.rs b/rust/tvm-rt/src/function.rs
index cca918a..ef659b7 100644
--- a/rust/tvm-rt/src/function.rs
+++ b/rust/tvm-rt/src/function.rs
@@ -251,8 +251,7 @@ impl<'a> TryFrom<<'a>> for Function {
 ///
 /// ```
 /// # use tvm_rt::{ArgValue, RetValue};
-/// # use tvm_rt::function::{Function, register};
-/// # use anyhow::{Result};
+/// # use tvm_rt::function::{Function, Result, register};
 ///
 /// fn sum(x: i64, y: i64, z: i64) -> i64 {
 /// x + y + z
@@ -317,6 +316,7 @@ mod tests {
 #[test]
 fn register_and_call_closure0() {
 use crate::function;
+use function::Result;
 
 fn constfn() -> i64 {
 return 10;
@@ -324,7 +324,7 @@ mod tests {
 
 function::register_override(constfn, "constfn".to_owned(), 
true).unwrap();
 let func = Function::get("constfn").unwrap();
-let func = func.to_boxed_fn:: Result>();
+let func = func.to_boxed_fn:: Result>();
 let ret = func().unwrap();
 assert_eq!(ret, 10);
 }
diff --git a/rust/tvm-rt/src/lib.rs b/rust/tvm-rt/src/lib.rs
index 70a8efd..e21b5b7 100644
--- a/rust/tvm-rt/src/lib.rs
+++ b/rust/tvm-rt/src/lib.rs
@@ -115,8 +115,8 @@ mod tests {
 
 #[test]
 fn set_error() {
-let err = errors::EmptyArrayError;
-set_last_error(());
-assert_eq!(get_last_error().trim(), 
errors::EmptyArrayError.to_string());
+let err = errors::NDArrayError::EmptyArray;
+set_last_error();
+assert_eq!(get_last_error().trim(), 
errors::NDArrayError::EmptyArray.to_string());
 }
 }
diff --git a/rust/tvm-rt/src/ndarray.rs b/rust/tvm-rt/src/ndarray.rs
index 9a17502..6e1dcbf 100644
--- a/rust/tvm-rt/src/ndarray.rs
+++ b/rust/tvm-rt/src/ndarray.rs
@@ -190,7 +190,7 @@ impl NDArray {
 /// assert_eq!(ndarray.to_vec::().unwrap(), data);
 /// ```
 pub fn to_vec() -> Result, NDArrayError> {
-if self.shape().is_some() {
+if !self.shape().is_some() {
 return Err(NDArrayError::EmptyArray);
 }
 let earr = NDArray::empty(
@@ -308,7 +308,7 @@ macro_rules! impl_from_ndarray_rustndarray {
 type Error = NDArrayError;
 
 fn try_from(nd: ) -> Result, Self::Error> {
-if nd.shape().is_some() {
+if !nd.shape().is_some() {
 return Err(NDArrayError::MissingShape);
 }
 assert_eq!(nd.dtype(), DataType::from_str($type_name)?, "Type 
mismatch");
@@ -323,7 +323,7 @@ macro_rules! impl_from_ndarray_rustndarray {
 type Error = NDArrayError;
 
 fn try_from(nd:  NDArray) -> Result, 
Self::Error> {
-if nd.shape().is_some() {
+if !nd.shape().is_some() {
 return Err(NDArrayError::MissingShape);
 };
 assert_eq!(nd.dtype(), DataType::from_str($type_name)?, "Type 
mismatch");



[incubator-tvm] 01/04: Reworking errors and proc macros

2020-06-08 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit fc6fac254d02f91dae146c81c618cd17f8bf9d3c
Author: Jared Roesch 
AuthorDate: Sat Jun 6 21:54:58 2020 -0700

Reworking errors and proc macros
---
 rust/macros/src/lib.rs   |  7 +
 rust/tvm-rt/src/errors.rs|  5 +++-
 rust/tvm-rt/src/function.rs  | 53 ++--
 rust/tvm-rt/src/ndarray.rs   | 23 ++--
 rust/tvm-rt/src/object/mod.rs|  2 +-
 rust/tvm-rt/src/object/object_ptr.rs |  2 +-
 rust/tvm-rt/src/to_function.rs   |  2 +-
 rust/tvm-rt/src/value.rs |  6 +---
 rust/tvm/src/ir/array.rs |  5 ++--
 rust/tvm/src/lib.rs  |  9 ++
 10 files changed, 48 insertions(+), 66 deletions(-)

diff --git a/rust/macros/src/lib.rs b/rust/macros/src/lib.rs
index e9ddc25..d0ac1ca 100644
--- a/rust/macros/src/lib.rs
+++ b/rust/macros/src/lib.rs
@@ -18,6 +18,8 @@
  */
 
 use proc_macro::TokenStream;
+
+mod external;
 mod import_module;
 mod object;
 
@@ -31,3 +33,8 @@ pub fn macro_impl(input: TokenStream) -> TokenStream {
 // let input = proc_macro2::TokenStream::from(input);
 TokenStream::from(object::macro_impl(input))
 }
+
+#[proc_macro]
+pub fn external(input: TokenStream) -> TokenStream {
+external::macro_impl(input)
+}
diff --git a/rust/tvm-rt/src/errors.rs b/rust/tvm-rt/src/errors.rs
index 41e873f..f081258 100644
--- a/rust/tvm-rt/src/errors.rs
+++ b/rust/tvm-rt/src/errors.rs
@@ -48,7 +48,10 @@ pub enum NDArrayError {
 #[error("a shape error occurred in the Rust ndarray library")]
 ShapeError(#[from] ndarray::ShapeError),
 #[error("Expected type `{expected}` but found `{actual}`")]
-DataTypeMismatch { expected: DataType, actual: DataType }
+DataTypeMismatch {
+expected: DataType,
+actual: DataType,
+},
 }
 
 #[derive(Debug, Error)]
diff --git a/rust/tvm-rt/src/function.rs b/rust/tvm-rt/src/function.rs
index 17f5f6e..b0122ff 100644
--- a/rust/tvm-rt/src/function.rs
+++ b/rust/tvm-rt/src/function.rs
@@ -25,6 +25,9 @@
 //!
 //! See the tests and examples repository for more examples.
 
+use anyhow::Result;
+use lazy_static::lazy_static;
+use std::convert::TryFrom;
 use std::{
 collections::BTreeMap,
 ffi::{CStr, CString},
@@ -33,9 +36,6 @@ use std::{
 ptr, slice, str,
 sync::Mutex,
 };
-use std::convert::{TryFrom};
-use anyhow::Result;
-use lazy_static::lazy_static;
 
 pub use tvm_sys::{ffi, ArgValue, RetValue};
 
@@ -194,7 +194,10 @@ impl TryFrom for Function {
 fn try_from(ret_value: RetValue) -> Result {
 match ret_value {
 RetValue::FuncHandle(handle) => Ok(Function::new(handle)),
-_ => Err(Error::downcast(format!("{:?}", ret_value), 
"FunctionHandle"))
+_ => Err(Error::downcast(
+format!("{:?}", ret_value),
+"FunctionHandle",
+)),
 }
 }
 }
@@ -211,7 +214,10 @@ impl<'a> TryFrom> for Function {
 fn try_from(arg_value: ArgValue<'a>) -> Result {
 match arg_value {
 ArgValue::FuncHandle(handle) => Ok(Function::new(handle)),
-_ => Err(Error::downcast(format!("{:?}", arg_value), 
"FunctionHandle")),
+_ => Err(Error::downcast(
+format!("{:?}", arg_value),
+"FunctionHandle",
+)),
 }
 }
 }
@@ -222,7 +228,10 @@ impl<'a> TryFrom<<'a>> for Function {
 fn try_from(arg_value: <'a>) -> Result {
 match arg_value {
 ArgValue::FuncHandle(handle) => Ok(Function::new(*handle)),
-_ => Err(Error::downcast(format!("{:?}", arg_value), 
"FunctionHandle")),
+_ => Err(Error::downcast(
+format!("{:?}", arg_value),
+"FunctionHandle",
+)),
 }
 }
 }
@@ -286,38 +295,6 @@ where
 Ok(())
 }
 
-#[macro_export]
-macro_rules! external_func_impl {
-($name:ident , $($ty_param:tt)* , ( $($arg:ident : $ty:ty),* ), 
$ret_type:ty, $ext_name:literal) => {
-::paste::item! {
-#[allow(non_upper_case_globals)]
-static []: ::once_cell::sync::Lazy<&'static 
$crate::Function> =
-::once_cell::sync::Lazy::new(|| {
-$crate::Function::get($ext_name)
-.expect(concat!("unable to load external function", 
stringify!($ext_name), "from TVM registry."))
-});
-}
-
-pub fn $name<$($ty_param),*>($($arg : $ty),*) -> 
anyhow::Result<$ret_type> w,* {
-let func_ref: &$crate::Function = ::past

[incubator-tvm] 03/04: Finish removing anyhow and work with new external! macro

2020-06-08 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 0c55c39477979c75f2bf3e2e9974d90fde74fa26
Author: Jared Roesch 
AuthorDate: Mon Jun 8 13:56:28 2020 -0700

Finish removing anyhow and work with new external! macro
---
 rust/tvm-rt/src/context.rs | 12 
 rust/tvm-rt/src/errors.rs  | 14 --
 rust/tvm-rt/src/function.rs| 12 ++--
 rust/tvm-rt/src/module.rs  | 10 +-
 rust/tvm-rt/src/ndarray.rs |  2 +-
 rust/tvm-rt/src/to_boxed_fn.rs | 29 -
 rust/tvm-rt/src/to_function.rs | 30 +++---
 7 files changed, 59 insertions(+), 50 deletions(-)

diff --git a/rust/tvm-rt/src/context.rs b/rust/tvm-rt/src/context.rs
index 0c01d91..b1bdab5 100644
--- a/rust/tvm-rt/src/context.rs
+++ b/rust/tvm-rt/src/context.rs
@@ -1,13 +1,17 @@
-pub use tvm_sys::context::*;
-use tvm_sys::ffi;
 
 use std::os::raw::c_void;
 use std::ptr;
 
+use crate::errors::Error;
+
+use tvm_sys::ffi;
+
+pub use tvm_sys::context::*;
+
 trait ContextExt {
 /// Checks whether the context exists or not.
 fn exist() -> bool;
-fn sync() -> anyhow::Result<()>;
+fn sync() -> Result<(), Error>;
 fn max_threads_per_block() -> isize;
 fn warp_size() -> isize;
 fn max_shared_memory_per_block() -> isize;
@@ -44,7 +48,7 @@ impl ContextExt for Context {
 }
 
 /// Synchronize the context stream.
-fn sync() -> anyhow::Result<()> {
+fn sync() -> Result<(), Error> {
 check_call!(ffi::TVMSynchronize(
 self.device_type as i32,
 self.device_id as i32,
diff --git a/rust/tvm-rt/src/errors.rs b/rust/tvm-rt/src/errors.rs
index 414484d..197c875 100644
--- a/rust/tvm-rt/src/errors.rs
+++ b/rust/tvm-rt/src/errors.rs
@@ -21,12 +21,6 @@ use crate::DataType;
 use thiserror::Error;
 
 #[derive(Debug, Error)]
-#[error("Handle `{name}` is null.")]
-pub struct NullHandleError {
-pub name: String,
-}
-
-#[derive(Debug, Error)]
 #[error("Function was not set in `function::Builder`")]
 pub struct FunctionNotFoundError;
 
@@ -62,6 +56,14 @@ pub enum Error {
 Null,
 #[error("failed to load module due to invalid path {0}")]
 ModuleLoadPath(String),
+#[error("failed to convert String into CString due to embedded nul 
character")]
+ToCString(#[from] std::ffi::NulError),
+#[error("failed to convert CString into String")]
+FromCString(#[from] std::ffi::IntoStringError),
+#[error("Handle `{0}` is null.")]
+NullHandle(String),
+#[error("{0}")]
+NDArray(#[from] NDArrayError),
 }
 
 impl Error {
diff --git a/rust/tvm-rt/src/function.rs b/rust/tvm-rt/src/function.rs
index 4b34bc1..cca918a 100644
--- a/rust/tvm-rt/src/function.rs
+++ b/rust/tvm-rt/src/function.rs
@@ -138,7 +138,7 @@ impl Function {
 }
 
 /// Calls the function that created from `Builder`.
-pub fn invoke<'a>(, arg_buf: Vec>) -> Result {
+pub fn invoke<'a>(, arg_buf: Vec>) -> Result {
 let num_args = arg_buf.len();
 let (mut values, mut type_codes): (Vec, 
Vec) =
 arg_buf.iter().map(|arg| arg.to_tvm_value()).unzip();
@@ -192,7 +192,7 @@ impl From for RetValue {
 impl TryFrom for Function {
 type Error = Error;
 
-fn try_from(ret_value: RetValue) -> Result {
+fn try_from(ret_value: RetValue) -> Result {
 match ret_value {
 RetValue::FuncHandle(handle) => Ok(Function::new(handle)),
 _ => Err(Error::downcast(
@@ -212,7 +212,7 @@ impl<'a> From for ArgValue<'a> {
 impl<'a> TryFrom> for Function {
 type Error = Error;
 
-fn try_from(arg_value: ArgValue<'a>) -> Result {
+fn try_from(arg_value: ArgValue<'a>) -> Result {
 match arg_value {
 ArgValue::FuncHandle(handle) => Ok(Function::new(handle)),
 _ => Err(Error::downcast(
@@ -226,7 +226,7 @@ impl<'a> TryFrom> for Function {
 impl<'a> TryFrom<<'a>> for Function {
 type Error = Error;
 
-fn try_from(arg_value: <'a>) -> Result {
+fn try_from(arg_value: <'a>) -> Result {
 match arg_value {
 ArgValue::FuncHandle(handle) => Ok(Function::new(*handle)),
 _ => Err(Error::downcast(
@@ -264,7 +264,7 @@ impl<'a> TryFrom<<'a>> for Function {
 /// let ret = boxed_fn(10, 20, 30).unwrap();
 /// assert_eq!(ret, 60);
 /// ```
-pub fn register>(f: F, name: S) -> Result<(), Error>
+pub fn register>(f: F, name: S) -> Result<()>
 where
 F: ToFunction,
 F: Typed,
@@ -275,7 +275,7 @@ where
 /// Register a function with explicit control over whether to override an 
existing registration o

[incubator-tvm] 02/04: Convert external macro to procmacro

2020-06-08 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 62b6d1bac749e53d40fd55b496feec486079
Author: Jared Roesch 
AuthorDate: Mon Jun 8 13:42:32 2020 -0700

Convert external macro to procmacro
---
 rust/macros/src/external.rs| 163 +
 rust/macros/src/lib.rs |   1 +
 rust/macros/src/object.rs  |  58 +++
 rust/macros/src/util.rs|  11 +++
 rust/tvm-rt/Cargo.toml |   1 -
 rust/tvm-rt/src/context.rs |   5 +-
 rust/tvm-rt/src/errors.rs  |   2 +
 rust/tvm-rt/src/function.rs|  11 +--
 rust/tvm-rt/src/lib.rs |   2 +
 rust/tvm-rt/src/module.rs  |  29 
 rust/tvm-rt/src/object/mod.rs  |  14 ++--
 rust/tvm-rt/src/string.rs  |   5 +-
 rust/tvm-rt/src/to_boxed_fn.rs |  36 -
 13 files changed, 255 insertions(+), 83 deletions(-)

diff --git a/rust/macros/src/external.rs b/rust/macros/src/external.rs
new file mode 100644
index 000..989cc6a
--- /dev/null
+++ b/rust/macros/src/external.rs
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ */
+use std::env;
+use quote::quote;
+use proc_macro2::Span;
+use syn::parse::{Parse, ParseStream, Result};
+
+use syn::{Ident, Meta, FnArg, Generics, TraitItemMethod, Lit, NestedMeta, 
Type, ReturnType, Pat};
+
+struct External {
+tvm_name: String,
+ident: Ident,
+generics: Generics,
+inputs: Vec,
+ret_type: ReturnType,
+}
+
+impl Parse for External {
+fn parse(input: ParseStream) -> Result {
+let method: TraitItemMethod = input.parse()?;
+assert_eq!(method.attrs.len(), 1);
+let sig = method.sig;
+let tvm_name = method.attrs[0].parse_meta()?;
+let tvm_name = match tvm_name {
+Meta::List(meta_list) => {
+let name = meta_list.path.get_ident()
+.expect("name");
+assert_eq!(name.to_string(), "name".to_string());
+match meta_list.nested.first() {
+Some(NestedMeta::Lit(Lit::Str(lit))) => lit.value(),
+_ => panic!(),
+}
+}
+_ => panic!()
+};
+assert_eq!(method.default, None);
+assert!(method.semi_token != None);
+let ident = sig.ident;
+let generics = sig.generics;
+let inputs = sig.inputs.iter().map(|param| param.clone()).collect();
+let ret_type = sig.output;
+
+Ok(External {
+tvm_name,
+ident,
+generics,
+inputs,
+ret_type,
+})
+}
+}
+
+struct ExternalInput {
+externs: Vec,
+}
+
+impl Parse for ExternalInput {
+fn parse(input: ParseStream) -> Result {
+let mut externs: Vec = Vec::new();
+
+loop {
+if input.is_empty() { break; }
+externs.push(input.parse()?);
+}
+
+Ok(ExternalInput { externs })
+}
+}
+
+ pub fn macro_impl(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
+let ext_input = syn::parse_macro_input!(input as ExternalInput);
+
+let tvm_rt_crate = if env::var("CARGO_PKG_NAME").unwrap() == "tvm-rt" {
+quote!( crate )
+} else {
+quote!( tvm_rt )
+};
+
+let err_type = quote! { #tvm_rt_crate::Error };
+
+let mut items = Vec::new();
+
+for external in _input.externs {
+let name = 
+let global_name = format!("global_{}", external.ident);
+let global_name = Ident::new(_name, Span::call_site());
+let ext_name = _name;
+
+let ty_params: Vec =
+external.generics.params.iter().map(|ty_param|
+match ty_param {
+syn::GenericParam::Type(param) => param.clone(),
+_ => panic!()
+}).collect();
+
+let args = 
+
+let (args, tys): (Vec, Vec) =
+args.iter().map(|arg| {
+match arg {
+FnArg::Typed(pat_ty

[incubator-tvm] branch rust-tvm updated (a44a379 -> caa6904)

2020-06-08 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch rust-tvm
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from a44a379  Refactor anyhow out of the rt layer
 new fc6fac2  Reworking errors and proc macros
 new 62b6d1ba Convert external macro to procmacro
 new 0c55c39  Finish removing anyhow and work with new external! macro
 new caa6904  All tests pass

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 rust/macros/src/external.rs  | 163 +++
 rust/macros/src/lib.rs   |   8 ++
 rust/macros/src/object.rs|  58 ++---
 rust/macros/src/util.rs  |  11 +++
 rust/tvm-rt/Cargo.toml   |   4 +-
 rust/tvm-rt/src/context.rs   |  17 ++--
 rust/tvm-rt/src/errors.rs|  21 +++--
 rust/tvm-rt/src/function.rs  |  64 +-
 rust/tvm-rt/src/lib.rs   |   8 +-
 rust/tvm-rt/src/module.rs|  31 ---
 rust/tvm-rt/src/ndarray.rs   |  25 +++---
 rust/tvm-rt/src/object/mod.rs|  14 +--
 rust/tvm-rt/src/object/object_ptr.rs |   2 +-
 rust/tvm-rt/src/string.rs|   5 +-
 rust/tvm-rt/src/to_boxed_fn.rs   |  21 ++---
 rust/tvm-rt/src/to_function.rs   |  30 +++
 rust/tvm-rt/src/value.rs |   6 +-
 rust/tvm/src/ir/array.rs |   5 +-
 rust/tvm/src/lib.rs  |   9 +-
 19 files changed, 334 insertions(+), 168 deletions(-)
 create mode 100644 rust/macros/src/external.rs
 create mode 100644 rust/macros/src/util.rs



[incubator-tvm] branch master updated (5046ff2 -> 06d7565)

2020-07-23 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 5046ff2  [DOCS][REFACTOR] Organize Design and Architectures (#6097)
 add 06d7565  [Rust] Clean up conversions between TVM and Rust functions 
(#6114)

No new revisions were added by this update.

Summary of changes:
 rust/tvm-macros/src/external.rs |   2 +-
 rust/tvm-rt/README.md   |   2 +-
 rust/tvm-rt/src/function.rs |  42 ++---
 rust/tvm-rt/src/lib.rs  |   1 -
 rust/tvm-rt/src/to_boxed_fn.rs  | 138 ---
 rust/tvm-rt/src/to_function.rs  | 200 +---
 6 files changed, 94 insertions(+), 291 deletions(-)
 delete mode 100644 rust/tvm-rt/src/to_boxed_fn.rs



[incubator-tvm] branch master updated (6dbc344 -> 0a1c4c2)

2020-07-23 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 6dbc344  [RELAY][Fix] i64 indices (#5235)
 add 0a1c4c2  [Rust] Some rust cleanups (#6116)

No new revisions were added by this update.

Summary of changes:
 rust/tvm-graph-rt/Cargo.toml|  5 ++-
 rust/tvm-graph-rt/src/array.rs  | 20 +-
 rust/tvm-graph-rt/src/errors.rs | 37 ++
 rust/tvm-graph-rt/src/graph.rs  | 51 ++---
 rust/tvm-graph-rt/src/module/dso.rs |  2 +-
 rust/tvm-graph-rt/src/threading.rs  |  2 +-
 rust/tvm-graph-rt/src/workspace.rs  | 13 ---
 rust/tvm-graph-rt/tests/test_wasm32/src/main.rs |  4 +-
 rust/tvm-macros/Cargo.toml  |  2 +-
 rust/tvm-rt/src/object/object_ptr.rs| 33 +++-
 rust/tvm-sys/Cargo.toml |  2 +-
 11 files changed, 98 insertions(+), 73 deletions(-)



[incubator-tvm] branch master updated (4b2c01a -> 37912a1)

2020-08-14 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 4b2c01a  [Parser] Add support for parsing the any dimension.  (#6277)
 add 37912a1  [TESTS] Decrease test times by introducing testing model 
(#6235)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/testing/__init__.py   |   1 +
 python/tvm/relay/testing/init.py   |  10 ++
 python/tvm/relay/testing/synthetic.py  | 120 +
 tests/micro/test_runtime_micro_on_arm.py   |   1 -
 .../relay/test_analysis_extract_fused_functions.py |   4 +-
 tests/python/relay/test_change_batch.py|  10 +-
 tests/python/relay/test_pass_auto_quantize.py  |  13 +--
 tests/python/relay/test_vm.py  |   2 +-
 tests/python/relay/test_vm_serialization.py|   9 +-
 .../unittest/test_autotvm_graph_tuner_utils.py |   4 +-
 tests/python/unittest/test_runtime_micro.py|   1 -
 .../test_runtime_module_based_interface.py |  61 ++-
 .../python/unittest/test_runtime_module_export.py  |  30 +++---
 tests/python/unittest/test_target_codegen_blob.py  |  16 +--
 14 files changed, 209 insertions(+), 73 deletions(-)
 create mode 100644 python/tvm/relay/testing/synthetic.py



[tvm] branch main updated (f4c6517 -> 91c905d)

2020-12-03 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git.


from f4c6517  [Topi] Fix GPU Dynamic Topk by Improving Dynamic Strided 
Slice in Topi (#7018)
 add 91c905d  [Relay][Pass] Clean up DCE tests in preparation for 
refactoring.  (#7029)

No new revisions were added by this update.

Summary of changes:
 .../relay/test_pass_dead_code_elimination.py   | 267 -
 1 file changed, 159 insertions(+), 108 deletions(-)



[tvm] branch main updated: [RELAY,TOPI] Add scatter_nd op (#6854)

2020-12-01 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
 new 0421efb  [RELAY,TOPI] Add scatter_nd op (#6854)
0421efb is described below

commit 0421efba4c3a42c6cf8d692734c24fe8e08e3884
Author: Tristan Konolige 
AuthorDate: Tue Dec 1 11:20:09 2020 -0800

[RELAY,TOPI] Add scatter_nd op (#6854)

* [RELAY,TOPI] Add scatter_nd op

Scatter_nd is the inverse of gather_nd and also happens to be its
gradient. The implementation here is not optimized. There are no cpu or
gpu specific implementations.

* formatting

* Fix tests

* formatting

* specify types on test

* Fix grad test

* scatter_nd cuda impl

* cuda impl

* x86 impl

* formatting

* fix shape rel

* fix tests

* formatting
---
 include/tvm/relay/attrs/transform.h   |   8 ++
 python/tvm/relay/backend/compile_engine.py|   5 +-
 python/tvm/relay/op/_tensor_grad.py   |   7 ++
 python/tvm/relay/op/_transform.py |   9 ++
 python/tvm/relay/op/strategy/cuda.py  |  13 +++
 python/tvm/relay/op/strategy/generic.py   |  22 +
 python/tvm/relay/op/strategy/x86.py   |  13 +++
 python/tvm/relay/op/transform.py  |  24 ++
 python/tvm/relay/testing/__init__.py  |   2 +
 python/tvm/te/operation.py|   6 +-
 python/tvm/topi/cuda/scatter.py   | 106 +++
 python/tvm/topi/scatter.py| 120 +-
 python/tvm/topi/testing/__init__.py   |   1 +
 python/tvm/topi/testing/common.py |  31 +++
 python/tvm/topi/x86/__init__.py   |   1 +
 python/tvm/topi/x86/scatter.py| 109 +++
 src/relay/analysis/type_solver.cc |   9 +-
 src/relay/op/tensor/transform.cc  |  68 +++
 tests/python/relay/test_any.py|   5 +-
 tests/python/relay/test_op_grad_level3.py |   9 ++
 tests/python/topi/python/test_topi_scatter.py |  67 ++
 21 files changed, 627 insertions(+), 8 deletions(-)

diff --git a/include/tvm/relay/attrs/transform.h 
b/include/tvm/relay/attrs/transform.h
index a7830cf..3ed6b83 100644
--- a/include/tvm/relay/attrs/transform.h
+++ b/include/tvm/relay/attrs/transform.h
@@ -129,6 +129,14 @@ struct ScatterAddAttrs : public 
tvm::AttrsNode {
   }
 };
 
+struct ScatterNDAttrs : public tvm::AttrsNode {
+  Array out_shape;
+
+  TVM_DECLARE_ATTRS(ScatterNDAttrs, "relay.attrs.ScatterNDAttrs") {
+TVM_ATTR_FIELD(out_shape).describe("Output shape of the scatter.");
+  }
+};
+
 struct GatherAttrs : public tvm::AttrsNode {
   Integer axis;
 
diff --git a/python/tvm/relay/backend/compile_engine.py 
b/python/tvm/relay/backend/compile_engine.py
index 32affe7..a39f72e 100644
--- a/python/tvm/relay/backend/compile_engine.py
+++ b/python/tvm/relay/backend/compile_engine.py
@@ -122,7 +122,10 @@ def get_valid_implementations(op, attrs, inputs, out_type, 
target):
 The list of all valid op implementations.
 """
 fstrategy = op.get_attr("FTVMStrategy")
-assert fstrategy is not None, "%s doesn't have FTVMStrategy registered" % 
op.name
+assert fstrategy is not None, (
+"%s doesn't have an FTVMStrategy registered. You can register "
+"one in python with `tvm.relay.op.register_strategy`." % op.name
+)
 with target:
 strategy = fstrategy(attrs, inputs, out_type, target)
 analyzer = tvm.arith.Analyzer()
diff --git a/python/tvm/relay/op/_tensor_grad.py 
b/python/tvm/relay/op/_tensor_grad.py
index b070d9f..9c84411 100644
--- a/python/tvm/relay/op/_tensor_grad.py
+++ b/python/tvm/relay/op/_tensor_grad.py
@@ -62,6 +62,7 @@ from .transform import (
 squeeze,
 strided_set,
 arange,
+scatter_nd,
 )
 
 
@@ -803,3 +804,9 @@ def arange_grad(orig, grad):
 grad_step = cast_like(_sum(grad_step), step)
 
 return [grad_start, grad_stop, grad_step]
+
+
+@register_gradient("gather_nd")
+def gather_nd_grad(orig, grad):
+data, indices = orig.args
+return [scatter_nd(grad, indices, data.checked_type.concrete_shape), 
zeros_like(indices)]
diff --git a/python/tvm/relay/op/_transform.py 
b/python/tvm/relay/op/_transform.py
index 439d44b..e1cb9e9 100644
--- a/python/tvm/relay/op/_transform.py
+++ b/python/tvm/relay/op/_transform.py
@@ -115,6 +115,15 @@ def compute_scatter_add(attrs, inputs, output_type):
 
 _reg.register_strategy("scatter_add", strategy.scatter_add_strategy)
 
+# scatter
+@_reg.register_compute("scatter_nd")
+def compute_scatter_nd(attrs, inputs, output_type):
+"""Compute definition of sc

[tvm] branch main updated (7a3278a -> 653f697)

2020-12-10 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git.


from 7a3278a  [Relay][Strategy] Allow cuda cross compilation without 
physical device. (#7063)
 add 653f697  [VTA] update 3rdparty submodule (#7081)

No new revisions were added by this update.

Summary of changes:
 3rdparty/vta-hw  | 2 +-
 python/tvm/relay/op/strategy/cuda.py | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)



[tvm] branch main updated: [Rust] Impl IsObjectRef for Array (#7138)

2020-12-22 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
 new 08a69d4  [Rust] Impl IsObjectRef for Array (#7138)
08a69d4 is described below

commit 08a69d4f92742c8c526d6a7c2a5805d00f5dc725
Author: Andrew Liu 
AuthorDate: Tue Dec 22 16:21:52 2020 -0800

[Rust] Impl IsObjectRef for Array (#7138)

* impl isobjectref for array

* array test

* cargo fmt
---
 rust/tvm-rt/src/array.rs | 34 --
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/rust/tvm-rt/src/array.rs b/rust/tvm-rt/src/array.rs
index 1b0ce83..5abf667 100644
--- a/rust/tvm-rt/src/array.rs
+++ b/rust/tvm-rt/src/array.rs
@@ -45,6 +45,26 @@ external! {
 fn array_size(array: ObjectRef) -> i64;
 }
 
+impl IsObjectRef for Array {
+type Object = Object;
+fn as_ptr() -> Option<> {
+self.object.as_ptr()
+}
+fn into_ptr(self) -> Option> {
+self.object.into_ptr()
+}
+fn from_ptr(object_ptr: Option>) -> Self {
+let object_ref = match object_ptr {
+Some(o) => o.into(),
+_ => panic!(),
+};
+Array {
+object: object_ref,
+_data: PhantomData,
+}
+}
+}
+
 impl Array {
 pub fn from_vec(data: Vec) -> Result> {
 let iter = data.into_iter().map(T::into_arg_value).collect();
@@ -131,8 +151,8 @@ impl FromIterator for Array {
 }
 }
 
-impl From> for ArgValue<'static> {
-fn from(array: Array) -> ArgValue<'static> {
+impl<'a, T: IsObjectRef> From> for ArgValue<'a> {
+fn from(array: Array) -> ArgValue<'a> {
 array.object.into()
 }
 }
@@ -172,6 +192,7 @@ impl<'a, T: IsObjectRef> TryFrom for Array {
 mod tests {
 use super::Array;
 use crate::function::Result;
+use crate::object::{IsObjectRef, ObjectRef};
 use crate::string::String;
 
 #[test]
@@ -183,4 +204,13 @@ mod tests {
 assert_eq!(array.get(2)?.to_string(), "baz");
 Ok(())
 }
+
+#[test]
+fn downcast() -> Result<()> {
+let vec: Vec = vec!["foo".into(), "bar".into(), "baz".into()];
+let array: ObjectRef = 
ObjectRef::from_ptr(Array::from_vec(vec)?.into_ptr());
+let array: Array = 
array.downcast::>().unwrap();
+assert_eq!(array.get(1)?.downcast::().unwrap(), "bar");
+Ok(())
+}
 }



[incubator-tvm] branch main updated (0f5b5fe -> 51d81fb)

2020-11-17 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 0f5b5fe  [TensorFlow] Support NonMaxSuppressionV5 (#6933)
 add 51d81fb  [DOC] Fix typo (#6920)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[incubator-tvm] branch main updated (0f5b5fe -> 51d81fb)

2020-11-17 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 0f5b5fe  [TensorFlow] Support NonMaxSuppressionV5 (#6933)
 add 51d81fb  [DOC] Fix typo (#6920)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[incubator-tvm] branch main updated (0f5b5fe -> 51d81fb)

2020-11-17 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 0f5b5fe  [TensorFlow] Support NonMaxSuppressionV5 (#6933)
 add 51d81fb  [DOC] Fix typo (#6920)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[incubator-tvm] branch main updated (0f5b5fe -> 51d81fb)

2020-11-17 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 0f5b5fe  [TensorFlow] Support NonMaxSuppressionV5 (#6933)
 add 51d81fb  [DOC] Fix typo (#6920)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[incubator-tvm] branch main updated (0f5b5fe -> 51d81fb)

2020-11-17 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 0f5b5fe  [TensorFlow] Support NonMaxSuppressionV5 (#6933)
 add 51d81fb  [DOC] Fix typo (#6920)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[incubator-tvm] branch main updated (3222cad -> 6dc8e22)

2020-11-02 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


from 3222cad  Update stale link to new location (#6819)
 add 6dc8e22  [rust][tvm-graph-rt]: maintain error sources when propagating 
errors, swap Mutex for RwLock (#6815)

No new revisions were added by this update.

Summary of changes:
 rust/tvm-graph-rt/src/errors.rs| 14 +-
 rust/tvm-graph-rt/src/graph.rs | 49 +++---
 rust/tvm-graph-rt/src/module/syslib.rs | 10 +++
 3 files changed, 46 insertions(+), 27 deletions(-)



[incubator-tvm] 23/23: Post-rebase

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit c9339267bf7ae641a7f9c3678c84cf1ff600959e
Author: Jared Roesch 
AuthorDate: Sat Oct 31 15:39:05 2020 -0700

Post-rebase
---
 rust/tvm/src/ir/module.rs | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/rust/tvm/src/ir/module.rs b/rust/tvm/src/ir/module.rs
index db32ce2..869c5e6 100644
--- a/rust/tvm/src/ir/module.rs
+++ b/rust/tvm/src/ir/module.rs
@@ -34,11 +34,8 @@ use super::function::BaseFunc;
 use super::source_map::SourceMap;
 use super::{ty::GlobalTypeVar, relay};
 
-use tvm_macros::Object;
-
 // TODO(@jroesch): define type
 type TypeData = ObjectRef;
-type GlobalTypeVar = ObjectRef;
 
 #[derive(Error, Debug)]
 pub enum Error {



[incubator-tvm] 13/23: Remove type checker

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 0cabfdcee309b12d8907fc3abe2ba8e8718ecac6
Author: Jared Roesch 
AuthorDate: Fri Oct 16 15:56:10 2020 -0700

Remove type checker
---
 tests/python/relay/test_type_infer2.py | 419 -
 1 file changed, 419 deletions(-)

diff --git a/tests/python/relay/test_type_infer2.py 
b/tests/python/relay/test_type_infer2.py
deleted file mode 100644
index 6758d96..000
--- a/tests/python/relay/test_type_infer2.py
+++ /dev/null
@@ -1,419 +0,0 @@
-# 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.
-"""Test that type checker correcly computes types
-   for expressions.
-"""
-import pytest
-import tvm
-
-from tvm import IRModule, te, relay, parser
-from tvm.relay import op, transform, analysis
-from tvm.relay import Any
-
-
-def infer_mod(mod, annotate_spans=True):
-if annotate_spans:
-mod = relay.transform.AnnotateSpans()(mod)
-
-mod = transform.InferType()(mod)
-return mod
-
-
-def infer_expr(expr, annotate_spans=True):
-mod = IRModule.from_expr(expr)
-mod = infer_mod(mod, annotate_spans)
-mod = transform.InferType()(mod)
-entry = mod["main"]
-return entry if isinstance(expr, relay.Function) else entry.body
-
-
-def assert_has_type(expr, typ, mod=None):
-if not mod:
-mod = tvm.IRModule({})
-
-mod["main"] = expr
-mod = infer_mod(mod)
-checked_expr = mod["main"]
-checked_type = checked_expr.checked_type
-if checked_type != typ:
-raise RuntimeError("Type mismatch %s vs %s" % (checked_type, typ))
-
-
-def initialize_box_adt(mod):
-# initializes simple ADT for tests
-box = relay.GlobalTypeVar("box")
-tv = relay.TypeVar("tv")
-constructor = relay.Constructor("constructor", [tv], box)
-data = relay.TypeData(box, [tv], [constructor])
-mod[box] = data
-return box, constructor
-
-
-def test_monomorphic_let():
-"Program: let %x = 1; %x"
-# TODO(@jroesch): this seems whack.
-sb = relay.ScopeBuilder()
-x = relay.var("x", dtype="float64", shape=())
-x = sb.let("x", relay.const(1.0, "float64"))
-sb.ret(x)
-xchecked = infer_expr(sb.get())
-assert xchecked.checked_type == relay.scalar_type("float64")
-
-
-def test_single_op():
-"Program: fn (%x : float32) { let %t1 = f(%x); %t1 }"
-x = relay.var("x", shape=[])
-func = relay.Function([x], op.log(x))
-ttype = relay.TensorType([], dtype="float32")
-assert_has_type(func, relay.FuncType([ttype], ttype))
-
-
-def test_add_broadcast_op():
-"""
-Program:
-fn (%x: Tensor[(10, 4), float32], %y: Tensor[(5, 10, 1), float32])
--> Tensor[(5, 10, 4), float32] {
-%x + %y
-}
-"""
-x = relay.var("x", shape=(10, 4))
-y = relay.var("y", shape=(5, 10, 1))
-z = x + y
-func = relay.Function([x, y], z)
-t1 = relay.TensorType((10, 4), "float32")
-t2 = relay.TensorType((5, 10, 1), "float32")
-t3 = relay.TensorType((5, 10, 4), "float32")
-expected_ty = relay.FuncType([t1, t2], t3)
-assert_has_type(func, expected_ty)
-
-
-def test_dual_op():
-"""Program:
-fn (%x : Tensor[(10, 10), float32]) {
-  let %t1 = log(x);
-  let %t2 = add(%t1, %x);
-  %t1
-}
-"""
-tp = relay.TensorType((10, 10), "float32")
-x = relay.var("x", tp)
-sb = relay.ScopeBuilder()
-t1 = sb.let("t1", relay.log(x))
-t2 = sb.let("t2", relay.add(t1, x))
-sb.ret(t2)
-f = relay.Function([x], sb.get())
-fchecked = infer_expr(f)
-assert fchecked.checked_type == relay.FuncType([tp], tp)
-
-
-def test_decl():
-"""Program:
-def @f(%x : Tensor[(10, 10), float32]) {
-log(%x)
-}
-"""
-tp 

[incubator-tvm] 06/23: Update CMake and delete old API

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit db245535a4ea5b8bed3c26a94825d2fcc9b5
Author: Jared Roesch 
AuthorDate: Thu Oct 15 01:03:03 2020 -0700

Update CMake and delete old API
---
 CMakeLists.txt  |   1 +
 cmake/modules/RustExt.cmake |  25 ++-
 include/tvm/parser/source_map.h |   2 -
 rust/compiler-ext/Cargo.toml|   5 +-
 rust/compiler-ext/src/lib.rs| 334 ++--
 rust/tvm-rt/Cargo.toml  |  15 +-
 rust/tvm-sys/Cargo.toml |   1 +
 rust/tvm-sys/build.rs   |   1 +
 rust/tvm/Cargo.toml |  22 ++-
 rust/tvm/src/bin/tyck.rs|   1 -
 rust/tvm/src/ir/diagnostics.rs  |  42 +++--
 rust/tvm/src/ir/mod.rs  |   2 +-
 rust/tvm/src/ir/relay/mod.rs|   3 +-
 rust/tvm/src/ir/source_map.rs   |  61 
 rust/tvm/src/ir/span.rs |  95 +---
 src/ir/expr.cc  |  11 ++
 src/parser/source_map.cc|  11 --
 17 files changed, 237 insertions(+), 395 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f82754..58bb2f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -353,6 +353,7 @@ include(cmake/modules/contrib/ArmComputeLib.cmake)
 include(cmake/modules/contrib/TensorRT.cmake)
 include(cmake/modules/Git.cmake)
 include(cmake/modules/LibInfo.cmake)
+include(cmake/modules/RustExt.cmake)
 
 include(CheckCXXCompilerFlag)
 if(NOT MSVC)
diff --git a/cmake/modules/RustExt.cmake b/cmake/modules/RustExt.cmake
index 45e46bd..2ad726e9 100644
--- a/cmake/modules/RustExt.cmake
+++ b/cmake/modules/RustExt.cmake
@@ -1,7 +1,14 @@
-if(USE_RUST_EXT)
-set(RUST_SRC_DIR "rust")
-set(CARGO_OUT_DIR "rust/target"
-set(COMPILER_EXT_PATH 
"${CARGO_OUT_DIR}/target/release/libcompiler_ext.dylib")
+if(USE_RUST_EXT AND NOT USE_RUST_EXT EQUAL OFF)
+set(RUST_SRC_DIR "${CMAKE_SOURCE_DIR}/rust")
+set(CARGO_OUT_DIR "${CMAKE_SOURCE_DIR}/rust/target")
+
+if(USE_RUST_EXT STREQUAL "STATIC")
+set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.a")
+elseif(USE_RUST_EXT STREQUAL "DYNAMIC")
+set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.so")
+else()
+message(FATAL_ERROR "invalid setting for RUST_EXT")
+endif()
 
 add_custom_command(
 OUTPUT "${COMPILER_EXT_PATH}"
@@ -9,5 +16,11 @@ if(USE_RUST_EXT)
 MAIN_DEPENDENCY "${RUST_SRC_DIR}"
 WORKING_DIRECTORY "${RUST_SRC_DIR}/compiler-ext")
 
-target_link_libraries(tvm "${COMPILER_EXT_PATH}" PRIVATE)
-endif(USE_RUST_EXT)
+add_custom_target(rust_ext ALL DEPENDS "${COMPILER_EXT_PATH}")
+
+# TODO(@jroesch, @tkonolige): move this to CMake target
+# target_link_libraries(tvm "${COMPILER_EXT_PATH}" PRIVATE)
+list(APPEND TVM_LINKER_LIBS ${COMPILER_EXT_PATH})
+
+add_definitions(-DRUST_COMPILER_EXT=1)
+endif()
diff --git a/include/tvm/parser/source_map.h b/include/tvm/parser/source_map.h
index 424af5c..a160c22 100644
--- a/include/tvm/parser/source_map.h
+++ b/include/tvm/parser/source_map.h
@@ -103,8 +103,6 @@ class SourceMap : public ObjectRef {
 
   TVM_DLL SourceMap() : SourceMap(Map()) {}
 
-  TVM_DLL static SourceMap Global();
-
   void Add(const Source& source);
 
   SourceMapNode* operator->() {
diff --git a/rust/compiler-ext/Cargo.toml b/rust/compiler-ext/Cargo.toml
index 76d10eb..3b13bc5 100644
--- a/rust/compiler-ext/Cargo.toml
+++ b/rust/compiler-ext/Cargo.toml
@@ -6,8 +6,11 @@ edition = "2018"
 # TODO(@jroesch): would be cool to figure out how to statically link instead.
 
 [lib]
-crate-type = ["cdylib"]
+crate-type = ["staticlib", "cdylib"]
 
 # See more keys and their definitions at 
https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
+tvm = { path = "../tvm", default-features = false, features = 
["static-linking"] }
+log = "*"
+env_logger = "*"
diff --git a/rust/compiler-ext/src/lib.rs b/rust/compiler-ext/src/lib.rs
index 58bdd0c..3e37d21 100644
--- a/rust/compiler-ext/src/lib.rs
+++ b/rust/compiler-ext/src/lib.rs
@@ -17,321 +17,19 @@
  * under the License.
  */
 
- use std::os::raw::c_int;
- use tvm::initialize;
- use tvm::ir::{tir, PrimExpr};
- use tvm::runtime::function::register_override;
- use tvm::runtime::map::Map;
- use tvm::runtime::object::{IsObject, IsObjectRef};
- 
- use ordered_float::NotNan;
- 
- mod interval;
- mod math;
- 
- use math::{BoundsMap, Expr, RecExpr};
- use tvm::ir::arith::ConstIntBound;
- use tvm_rt::{ObjectRef, array::Array};
- 
- macro_rules! downcast_match {
- ($id:ident; { $($t:ty => $arm:expr $(,)? )+ , else => $default:expr }) => 
{
- $(

[incubator-tvm] 09/23: Improve Rust bindings

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 4cd1bbc79a71873676927c22528f5911e3f4072d
Author: Jared Roesch 
AuthorDate: Thu Oct 15 20:24:43 2020 -0700

Improve Rust bindings
---
 rust/tvm/src/ir/diagnostics/codespan.rs| 131 +
 .../src/ir/{diagnostics.rs => diagnostics/mod.rs}  |  69 +--
 rust/tvm/src/ir/source_map.rs  |   3 +-
 rust/tvm/test.rly  |   3 +-
 src/ir/diagnostic.cc   |   1 +
 5 files changed, 138 insertions(+), 69 deletions(-)

diff --git a/rust/tvm/src/ir/diagnostics/codespan.rs 
b/rust/tvm/src/ir/diagnostics/codespan.rs
new file mode 100644
index 000..80a8784
--- /dev/null
+++ b/rust/tvm/src/ir/diagnostics/codespan.rs
@@ -0,0 +1,131 @@
+use std::collections::HashMap;
+use std::sync::{Arc, Mutex};
+
+use codespan_reporting::diagnostic::{Diagnostic as CDiagnostic, Label, 
Severity};
+use codespan_reporting::files::SimpleFiles;
+use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
+
+use crate::ir::source_map::*;
+use super::*;
+
+enum StartOrEnd {
+Start,
+End,
+}
+
+enum FileSpanToByteRange {
+AsciiSource,
+Utf8 {
+/// Map character regions which are larger then 1-byte to length.
+lengths: HashMap,
+source: String,
+}
+}
+
+impl FileSpanToByteRange {
+fn new(source: String) -> FileSpanToByteRange {
+let mut last_index = 0;
+let mut is_ascii = true;
+if source.is_ascii() {
+FileSpanToByteRange::AsciiSource
+} else {
+panic!()
+}
+
+// for (index, _) in source.char_indices() {
+// if last_index - 1 != last_index {
+// is_ascii = false;
+// } else {
+// panic!();
+// }
+// last_index = index;
+// }
+}
+}
+
+struct SpanToByteRange {
+map: HashMap
+}
+
+impl SpanToByteRange {
+fn new() -> SpanToByteRange {
+SpanToByteRange { map: HashMap::new() }
+}
+
+pub fn add_source( self, source: Source) {
+let source_name: String = 
source.source_name.name.as_str().expect("foo").into();
+
+if self.map.contains_key(_name) {
+panic!()
+} else {
+let source = source.source.as_str().expect("fpp").into();
+self.map.insert(source_name, FileSpanToByteRange::new(source));
+}
+}
+}
+
+struct ByteRange {
+file_id: FileId,
+start_pos: usize,
+end_pos: usize,
+}
+
+
+pub fn to_diagnostic(diag: super::Diagnostic) -> CDiagnostic {
+let severity = match diag.level {
+DiagnosticLevel::Error => Severity::Error,
+DiagnosticLevel::Warning => Severity::Warning,
+DiagnosticLevel::Note => Severity::Note,
+DiagnosticLevel::Help => Severity::Help,
+DiagnosticLevel::Bug => Severity::Bug,
+};
+
+let file_id = "foo".into(); // diag.span.source_name;
+
+let message: String = diag.message.as_str().unwrap().into();
+let inner_message: String = "expected `String`, found `Nat`".into();
+let diagnostic = CDiagnostic::new(severity)
+.with_message(message)
+.with_code("EXXX")
+.with_labels(vec![
+Label::primary(file_id, 328..331).with_message(inner_message)
+]);
+
+diagnostic
+}
+
+struct DiagnosticState {
+files: SimpleFiles,
+span_map: SpanToByteRange,
+}
+
+impl DiagnosticState {
+fn new() -> DiagnosticState {
+DiagnosticState {
+files: SimpleFiles::new(),
+span_map: SpanToByteRange::new(),
+}
+}
+}
+
+fn renderer(state:  DiagnosticState, diag_ctx: DiagnosticContext) {
+let source_map = diag_ctx.module.source_map.clone();
+for diagnostic in diag_ctx.diagnostics.clone() {
+match source_map.source_map.get(_name) {
+Err(err) => panic!(),
+Ok(source) => state.span_map.add_source(source),
+}
+println!("Diagnostic: {}", diagnostic.message);
+}
+}
+
+pub fn init() -> Result<()> {
+let diag_state = Arc::new(Mutex::new(DiagnosticState::new()));
+let render_fn = move |diag_ctx: DiagnosticContext| {
+// let mut guard = diag_state.lock().unwrap();
+// renderer( *guard, diag_ctx);
+};
+
+override_renderer(Some(render_fn))?;
+Ok(())
+}
diff --git a/rust/tvm/src/ir/diagnostics.rs b/rust/tvm/src/ir/diagnostics/mod.rs
similarity index 76%
rename from rust/tvm/src/ir/diagnostics.rs
rename to rust/tvm/src/ir/diagnostics/mod.rs
index 4975a45..fce214a 100644
--- a/rust/tvm/src/ir/diagnostics.rs
+++ b/rust/tvm/src/ir/diagnostics/mod.rs
@@ -18,7 +18,7 @@
  */
 
 use su

[incubator-tvm] 14/23: Format and cleanup

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 04a9779359380ae383405f5f72a66e79631ee2d5
Author: Jared Roesch 
AuthorDate: Fri Oct 16 16:31:37 2020 -0700

Format and cleanup
---
 python/tvm/ir/diagnostics/__init__.py   |  1 +
 rust/compiler-ext/src/lib.rs|  3 +-
 rust/tvm-rt/src/array.rs| 11 +++--
 rust/tvm-rt/src/errors.rs   |  4 +-
 rust/tvm-rt/src/function.rs |  2 +-
 rust/tvm/src/bin/tyck.rs|  8 +--
 rust/tvm/src/ir/diagnostics/codespan.rs | 87 +++--
 rust/tvm/src/ir/mod.rs  |  2 +-
 rust/tvm/src/ir/module.rs   |  5 +-
 rust/tvm/src/ir/relay/mod.rs|  2 +-
 rust/tvm/src/ir/relay/visitor.rs| 24 -
 rust/tvm/src/ir/source_map.rs   | 13 ++---
 rust/tvm/src/ir/span.rs |  2 +-
 src/ir/expr.cc  | 11 -
 14 files changed, 79 insertions(+), 96 deletions(-)

diff --git a/python/tvm/ir/diagnostics/__init__.py 
b/python/tvm/ir/diagnostics/__init__.py
index 0ad2a7a..3a6402c 100644
--- a/python/tvm/ir/diagnostics/__init__.py
+++ b/python/tvm/ir/diagnostics/__init__.py
@@ -37,6 +37,7 @@ def get_renderer():
 """
 return _ffi_api.GetRenderer()
 
+
 @tvm.register_func("diagnostics.override_renderer")
 def override_renderer(render_func):
 """
diff --git a/rust/compiler-ext/src/lib.rs b/rust/compiler-ext/src/lib.rs
index c136d06..346f40f 100644
--- a/rust/compiler-ext/src/lib.rs
+++ b/rust/compiler-ext/src/lib.rs
@@ -36,8 +36,7 @@ tvm::export!(test_fn, test_fn2);
 #[no_mangle]
 fn compiler_ext_initialize() -> i32 {
 let _ = env_logger::try_init();
-tvm_export("rust_ext")
-.expect("failed to initialize Rust compiler_ext");
+tvm_export("rust_ext").expect("failed to initialize Rust compiler_ext");
 log::debug!("done!");
 return 0;
 }
diff --git a/rust/tvm-rt/src/array.rs b/rust/tvm-rt/src/array.rs
index 032ca79..66e32a7 100644
--- a/rust/tvm-rt/src/array.rs
+++ b/rust/tvm-rt/src/array.rs
@@ -18,8 +18,8 @@
  */
 
 use std::convert::{TryFrom, TryInto};
-use std::marker::PhantomData;
 use std::iter::{IntoIterator, Iterator};
+use std::marker::PhantomData;
 
 use crate::errors::Error;
 use crate::object::{IsObjectRef, Object, ObjectPtr, ObjectRef};
@@ -93,8 +93,7 @@ impl Iterator for IntoIter {
 
 fn next( self) -> Option {
 if self.pos < self.size {
-let item = self.array.get(self.pos)
-.expect("should not fail");
+let item = self.array.get(self.pos).expect("should not fail");
 self.pos += 1;
 Some(item)
 } else {
@@ -109,7 +108,11 @@ impl IntoIterator for Array {
 
 fn into_iter(self) -> Self::IntoIter {
 let size = self.len() as isize;
-IntoIter { array: self, pos: 0, size: size }
+IntoIter {
+array: self,
+pos: 0,
+size: size,
+}
 }
 }
 
diff --git a/rust/tvm-rt/src/errors.rs b/rust/tvm-rt/src/errors.rs
index 3de9f3c..31ce385 100644
--- a/rust/tvm-rt/src/errors.rs
+++ b/rust/tvm-rt/src/errors.rs
@@ -68,7 +68,9 @@ pub enum Error {
 Infallible(#[from] std::convert::Infallible),
 #[error("a panic occurred while executing a Rust packed function")]
 Panic,
-#[error("one or more error diagnostics were emitted, please check 
diagnostic render for output.")]
+#[error(
+"one or more error diagnostics were emitted, please check diagnostic 
render for output."
+)]
 DiagnosticError(String),
 #[error("{0}")]
 Raw(String),
diff --git a/rust/tvm-rt/src/function.rs b/rust/tvm-rt/src/function.rs
index 173b60a..4c6f56e 100644
--- a/rust/tvm-rt/src/function.rs
+++ b/rust/tvm-rt/src/function.rs
@@ -128,7 +128,7 @@ impl Function {
 type_codes.as_mut_ptr() as *mut c_int,
 num_args as c_int,
  ret_val as *mut _,
- ret_type_code as *mut _
+ ret_type_code as *mut _,
 )
 };
 
diff --git a/rust/tvm/src/bin/tyck.rs b/rust/tvm/src/bin/tyck.rs
index 13470e7..e9c2663 100644
--- a/rust/tvm/src/bin/tyck.rs
+++ b/rust/tvm/src/bin/tyck.rs
@@ -20,9 +20,11 @@ fn main() -> Result<()> {
 let opt = Opt::from_args();
 println!("{:?}", );
 let _module = match IRModule::parse_file(opt.input) {
-Err(ir::module::Error::TVM(Error::DiagnosticError(_))) => { return 
Ok(()) },
-Err(e) => { return Err(e.into()); },
-Ok(module) => module
+Err(ir::module::Error::TVM(Error::DiagnosticError(_))) => return 
Ok(()),
+Err(e) => {
+return E

[incubator-tvm] 01/23: Add initial boilerplate for Rust diagnostic interface.

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 1097cbf8a23708b7408dfbab7c419e363af57728
Author: Jared Roesch 
AuthorDate: Fri Oct 9 01:18:15 2020 -0700

Add initial boilerplate for Rust diagnostic interface.
---
 python/tvm/ir/diagnostics/__init__.py |   2 +-
 rust/tvm/src/ir/diagnostics.rs| 239 ++
 rust/tvm/src/ir/mod.rs|   1 +
 3 files changed, 241 insertions(+), 1 deletion(-)

diff --git a/python/tvm/ir/diagnostics/__init__.py 
b/python/tvm/ir/diagnostics/__init__.py
index 6503743..0ad2a7a 100644
--- a/python/tvm/ir/diagnostics/__init__.py
+++ b/python/tvm/ir/diagnostics/__init__.py
@@ -37,7 +37,7 @@ def get_renderer():
 """
 return _ffi_api.GetRenderer()
 
-
+@tvm.register_func("diagnostics.override_renderer")
 def override_renderer(render_func):
 """
 Sets a custom renderer for diagnostics.
diff --git a/rust/tvm/src/ir/diagnostics.rs b/rust/tvm/src/ir/diagnostics.rs
new file mode 100644
index 000..799a10c
--- /dev/null
+++ b/rust/tvm/src/ir/diagnostics.rs
@@ -0,0 +1,239 @@
+/*
+ * 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.
+ */
+
+/// The diagnostic interface to TVM, used for reporting and rendering
+/// diagnostic information by the compiler. This module exposes
+/// three key abstractions: a Diagnostic, the DiagnosticContext,
+/// and the DiagnosticRenderer.
+
+use tvm_macros::{Object, external};
+use super::module::IRModule;
+use crate::runtime::{function::{Function, Typed}, array::Array, string::String 
as TString};
+use crate::runtime::object::{Object, ObjectRef};
+use crate::runtime::function::Result;
+use super::span::Span;
+
+type SourceName = ObjectRef;
+
+/// The diagnostic level, controls the printing of the message.
+#[repr(C)]
+pub enum DiagnosticLevel {
+Bug = 10,
+Error = 20,
+Warning = 30,
+Note = 40,
+Help = 50,
+}
+
+/// A compiler diagnostic.
+#[repr(C)]
+#[derive(Object)]
+#[ref_name = "Diagnostic"]
+#[type_key = "Diagnostic"]
+pub struct DiagnosticNode {
+pub base: Object,
+/// The level.
+pub level: DiagnosticLevel,
+/// The span at which to report an error.
+pub span: Span,
+/// The diagnostic message.
+pub message: TString,
+}
+
+impl Diagnostic {
+pub fn new(level: DiagnosticLevel, span: Span, message: TString) {
+todo!()
+}
+
+pub fn bug(span: Span) -> DiagnosticBuilder {
+todo!()
+}
+
+pub fn error(span: Span) -> DiagnosticBuilder {
+todo!()
+}
+
+pub fn warning(span: Span) -> DiagnosticBuilder {
+todo!()
+}
+
+pub fn note(span: Span) -> DiagnosticBuilder {
+todo!()
+}
+
+pub fn help(span: Span) -> DiagnosticBuilder {
+todo!()
+}
+}
+
+/// A wrapper around std::stringstream to build a diagnostic.
+pub struct DiagnosticBuilder {
+/// The level.
+pub level: DiagnosticLevel,
+
+/// The source name.
+pub source_name: SourceName,
+
+/// The span of the diagnostic.
+pub span: Span,
+}
+
+//   /*! \brief Display diagnostics in a given display format.
+//*
+//* A diagnostic renderer is responsible for converting the
+//* raw diagnostics into consumable output.
+//*
+//* For example the terminal renderer will render a sequence
+//* of compiler diagnostics to std::out and std::err in
+//* a human readable form.
+//*/
+//   class DiagnosticRendererNode : public Object {
+//public:
+// TypedPackedFunc renderer;
+
+// // override attr visitor
+// void VisitAttrs(AttrVisitor* v) {}
+
+// static constexpr const char* _type_key = "DiagnosticRenderer";
+// TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticRendererNode, Object);
+//   };
+
+//   class DiagnosticRenderer : public ObjectRef {
+//public:
+// TVM_DLL DiagnosticRenderer(TypedPackedFunc 
render);
+// TVM_DLL DiagnosticRenderer()
+// : DiagnosticRenderer(TypedPackedFunc()) {}
+
+// void Render(const DiagnosticContext&am

[incubator-tvm] branch cargo-build created (now c933926)

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a change to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git.


  at c933926  Post-rebase

This branch includes the following new commits:

 new 1097cbf  Add initial boilerplate for Rust diagnostic interface.
 new 77ba309  Codespan example almost working
 new cb37856  WIP
 new 131e40a  Hacking on Rust inside of TVM
 new b2b59c2  Borrow code from Egg
 new db24553  Update CMake and delete old API
 new e0f9801  Fix Linux build
 new 20c6a28  Clean up exporting to show off new diagnostics
 new 4cd1bbc  Improve Rust bindings
 new eeb86c6  Fix calling
 new 4261461  Fix
 new 6e13467  Rust Diagnostics work
 new 0cabfdc  Remove type checker
 new 04a9779  Format and cleanup
 new 6828374  Fix the extension code
 new 1874350  More cleanup
 new 8e295b7  Fix some CR
 new 49246bf  WIP
 new a9ee3cb  WIP
 new b8dcc35  WIP
 new 478326c  Debug segfault
 new e8bb83d  WIP
 new c933926  Post-rebase

The 23 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[incubator-tvm] 21/23: Debug segfault

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 478326c8d7c2ccce10b77aa28e4b22bafbfdf877
Author: Jared Roesch 
AuthorDate: Sun Oct 25 17:26:47 2020 -0700

Debug segfault
---
 python/tvm/__init__.py |  2 ++
 python/tvm/relay/__init__.py   |  3 +-
 python/tvm/relay/analysis/__init__.py  |  2 +-
 python/tvm/relay/analysis/analysis.py  |  6 ++--
 python/tvm/relay/analysis/annotated_regions.py |  2 +-
 python/tvm/relay/analysis/call_graph.py|  4 +--
 python/tvm/relay/analysis/sparse_dense.py  | 15 -
 python/tvm/relay/build_module.py   |  6 +++-
 python/tvm/relay/op/op.py  | 40 
 python/tvm/relay/transform/__init__.py |  2 +-
 python/tvm/relay/transform/memory_alloc.py |  7 ++---
 python/tvm/relay/transform/transform.py|  5 +--
 python/tvm/topi/cuda/__init__.py   |  2 --
 python/tvm/topi/cuda/sparse.py |  3 +-
 rust/tvm/Cargo.toml|  2 +-
 rust/tvm/src/ir/relay/mod.rs   |  1 -
 rust/tvm/src/python.rs | 43 +++---
 17 files changed, 91 insertions(+), 54 deletions(-)

diff --git a/python/tvm/__init__.py b/python/tvm/__init__.py
index 569e8f0..60f81f4 100644
--- a/python/tvm/__init__.py
+++ b/python/tvm/__init__.py
@@ -67,6 +67,8 @@ from . import support
 # Contrib initializers
 from .contrib import rocm as _rocm, nvcc as _nvcc, sdaccel as _sdaccel
 
+def cleanup():
+_ffi.base._LIB = None
 
 def tvm_wrap_excepthook(exception_hook):
 """Wrap given excepthook with TVM additional work."""
diff --git a/python/tvm/relay/__init__.py b/python/tvm/relay/__init__.py
index cd96ecc..7e6ed4f 100644
--- a/python/tvm/relay/__init__.py
+++ b/python/tvm/relay/__init__.py
@@ -60,8 +60,7 @@ from . import qnn
 from .scope_builder import ScopeBuilder
 
 # Load Memory Passes
-from .transform import memory_alloc
-from .transform import memory_plan
+from .transform import memory_alloc, memory_plan
 
 # Required to traverse large programs
 setrecursionlimit(1)
diff --git a/python/tvm/relay/analysis/__init__.py 
b/python/tvm/relay/analysis/__init__.py
index b4ea7f3..4ea4de7 100644
--- a/python/tvm/relay/analysis/__init__.py
+++ b/python/tvm/relay/analysis/__init__.py
@@ -26,7 +26,7 @@ from .annotated_regions import AnnotatedRegionSet
 from . import call_graph
 from .call_graph import CallGraph
 
-# Feature
+# # Feature
 from . import feature
 from . import sparse_dense
 
diff --git a/python/tvm/relay/analysis/analysis.py 
b/python/tvm/relay/analysis/analysis.py
index 7e49461..48e9ce0 100644
--- a/python/tvm/relay/analysis/analysis.py
+++ b/python/tvm/relay/analysis/analysis.py
@@ -20,9 +20,9 @@
 This file contains the set of passes for Relay, which exposes an interface for
 configuring the passes and scripting them in Python.
 """
-from tvm.ir import IRModule
-from tvm.relay import transform, build_module
-from tvm.runtime.ndarray import cpu
+from ...ir import IRModule
+from ...relay import transform, build_module
+from ...runtime.ndarray import cpu
 
 from . import _ffi_api
 from .feature import Feature
diff --git a/python/tvm/relay/analysis/annotated_regions.py 
b/python/tvm/relay/analysis/annotated_regions.py
index 437b97b..a18ccb9 100644
--- a/python/tvm/relay/analysis/annotated_regions.py
+++ b/python/tvm/relay/analysis/annotated_regions.py
@@ -17,7 +17,7 @@
 # pylint: disable=no-else-return, unidiomatic-typecheck, invalid-name, 
unused-import
 """Regions used in Relay."""
 
-from tvm.runtime import Object
+from ...runtime import Object
 from . import _ffi_api
 
 
diff --git a/python/tvm/relay/analysis/call_graph.py 
b/python/tvm/relay/analysis/call_graph.py
index 966659a..fd9704d 100644
--- a/python/tvm/relay/analysis/call_graph.py
+++ b/python/tvm/relay/analysis/call_graph.py
@@ -17,8 +17,8 @@
 # pylint: disable=no-else-return, unidiomatic-typecheck, invalid-name, 
unused-import
 """Call graph used in Relay."""
 
-from tvm.ir import IRModule
-from tvm.runtime import Object
+from ...ir import IRModule
+from ...runtime import Object
 from ..expr import GlobalVar
 from . import _ffi_api
 
diff --git a/python/tvm/relay/analysis/sparse_dense.py 
b/python/tvm/relay/analysis/sparse_dense.py
index d521748..51fab34 100644
--- a/python/tvm/relay/analysis/sparse_dense.py
+++ b/python/tvm/relay/analysis/sparse_dense.py
@@ -22,8 +22,8 @@ to block sparse model
 """
 from collections import namedtuple
 import numpy as np
-import scipy.sparse as sp
-import tvm
+
+from ... import nd, runtime
 from . import _ffi_api
 
 
@@ -73,6 +73,7 @@ def process_params(expr, params, block_size, 
sparsity_threshold):
 re

[incubator-tvm] 15/23: Fix the extension code

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 68283745b9c283db611579205a3b925eb09e9faa
Author: Jared Roesch 
AuthorDate: Fri Oct 16 16:32:13 2020 -0700

Fix the extension code
---
 src/contrib/rust_extension.cc | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/src/contrib/rust_extension.cc b/src/contrib/rust_extension.cc
new file mode 100644
index 000..075cbc6
--- /dev/null
+++ b/src/contrib/rust_extension.cc
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file src/contrib/rust_extension.cc
+ * \brief Expose Rust extensions initialization.
+ */
+#ifdef RUST_COMPILER_EXT
+
+extern "C" {
+  int compiler_ext_initialize();
+  static int test = compiler_ext_initialize();
+}
+
+#endif



[incubator-tvm] 02/23: Codespan example almost working

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit 77ba30993a7883c142b05e511e8a5a7a91116b2f
Author: Jared Roesch 
AuthorDate: Fri Oct 9 23:59:51 2020 -0700

Codespan example almost working
---
 rust/tvm-sys/src/packed_func.rs  |   1 +
 rust/tvm/Cargo.toml  |   2 +
 rust/tvm/src/bin/tyck.rs |  24 
 rust/tvm/src/ir/diagnostics.rs   | 121 +--
 rust/tvm/src/ir/relay/visitor.rs |  24 
 5 files changed, 143 insertions(+), 29 deletions(-)

diff --git a/rust/tvm-sys/src/packed_func.rs b/rust/tvm-sys/src/packed_func.rs
index f7b289c..7b8d529 100644
--- a/rust/tvm-sys/src/packed_func.rs
+++ b/rust/tvm-sys/src/packed_func.rs
@@ -101,6 +101,7 @@ macro_rules! TVMPODValue {
 TVMArgTypeCode_kTVMOpaqueHandle => 
Handle($value.v_handle),
 TVMArgTypeCode_kTVMDLTensorHandle => 
ArrayHandle($value.v_handle as TVMArrayHandle),
 TVMArgTypeCode_kTVMObjectHandle => 
ObjectHandle($value.v_handle),
+TVMArgTypeCode_kTVMObjectRValueRefArg => 
ObjectHandle(*($value.v_handle as *mut *mut c_void)),
 TVMArgTypeCode_kTVMModuleHandle => 
ModuleHandle($value.v_handle),
 TVMArgTypeCode_kTVMPackedFuncHandle => 
FuncHandle($value.v_handle),
 TVMArgTypeCode_kTVMNDArrayHandle => 
NDArrayHandle($value.v_handle),
diff --git a/rust/tvm/Cargo.toml b/rust/tvm/Cargo.toml
index 55fc179..71a4b93 100644
--- a/rust/tvm/Cargo.toml
+++ b/rust/tvm/Cargo.toml
@@ -41,6 +41,8 @@ paste = "0.1"
 mashup = "0.1"
 once_cell = "^1.3.1"
 pyo3 = { version = "0.11.1", optional = true }
+codespan-reporting = "0.9.5"
+structopt = { version = "0.3" }
 
 [features]
 default = ["python"]
diff --git a/rust/tvm/src/bin/tyck.rs b/rust/tvm/src/bin/tyck.rs
new file mode 100644
index 000..9300412
--- /dev/null
+++ b/rust/tvm/src/bin/tyck.rs
@@ -0,0 +1,24 @@
+use std::path::PathBuf;
+
+use anyhow::Result;
+use structopt::StructOpt;
+
+use tvm::ir::diagnostics::codespan;
+use tvm::ir::IRModule;
+
+
+#[derive(Debug, StructOpt)]
+#[structopt(name = "tyck", about = "Parse and type check a Relay program.")]
+struct Opt {
+/// Input file
+#[structopt(parse(from_os_str))]
+input: PathBuf,
+}
+
+fn main() -> Result<()> {
+codespan::init().expect("Rust based diagnostics");
+let opt = Opt::from_args();
+println!("{:?}", );
+let file = IRModule::parse_file(opt.input)?;
+Ok(())
+}
diff --git a/rust/tvm/src/ir/diagnostics.rs b/rust/tvm/src/ir/diagnostics.rs
index 799a10c..e434d3f 100644
--- a/rust/tvm/src/ir/diagnostics.rs
+++ b/rust/tvm/src/ir/diagnostics.rs
@@ -24,13 +24,31 @@
 
 use tvm_macros::{Object, external};
 use super::module::IRModule;
-use crate::runtime::{function::{Function, Typed}, array::Array, string::String 
as TString};
-use crate::runtime::object::{Object, ObjectRef};
+use crate::runtime::{function::{self, Function, ToFunction, Typed}, 
array::Array, string::String as TString};
+use crate::runtime::object::{Object, ObjectPtr, ObjectRef};
 use crate::runtime::function::Result;
 use super::span::Span;
 
 type SourceName = ObjectRef;
 
+// Get the the diagnostic renderer.
+external! {
+#[name("node.ArrayGetItem")]
+fn get_renderer() -> DiagnosticRenderer;
+
+#[name("diagnostics.DiagnosticRenderer")]
+fn diagnostic_renderer(func: Function) -> DiagnosticRenderer;
+
+#[name("diagnostics.Emit")]
+fn emit(ctx: DiagnosticContext, diagnostic: Diagnostic) -> ();
+
+#[name("diagnostics.DiagnosticContextRender")]
+fn diagnostic_context_render(ctx: DiagnosticContext) -> ();
+
+#[name("diagnostics.ClearRenderer")]
+fn clear_renderer() -> ();
+}
+
 /// The diagnostic level, controls the printing of the message.
 #[repr(C)]
 pub enum DiagnosticLevel {
@@ -171,26 +189,20 @@ pub struct DiagnosticContextNode {
 pub renderer: DiagnosticRenderer,
 }
 
-// Get the the diagnostic renderer.
-external! {
-#[name("node.ArrayGetItem")]
-fn get_renderer() -> DiagnosticRenderer;
-
-#[name("diagnostics.DiagnosticRenderer")]
-fn diagnostic_renderer(func: Function) -> DiagnosticRenderer;
-
-#[name("diagnostics.Emit")]
-fn emit(ctx: DiagnosticContext, diagnostic: Diagnostic) -> ();
-
-#[name("diagnostics.DiagnosticContextRender")]
-fn diagnostic_context_render(ctx: DiagnosticContext) -> ();
-}
-
 /// A diagnostic context which records active errors
 /// and contains a renderer.
 impl DiagnosticContext {
-pub fn new(module: IRModule, renderer: Diagnostic

[incubator-tvm] 05/23: Borrow code from Egg

2020-11-05 Thread jroesch
This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit b2b59c229e9b8c2002d8c8cd520748df6b38e074
Author: Jared Roesch 
AuthorDate: Tue Oct 13 15:26:54 2020 -0700

Borrow code from Egg
---
 rust/compiler-ext/src/lib.rs | 344 ++-
 1 file changed, 337 insertions(+), 7 deletions(-)

diff --git a/rust/compiler-ext/src/lib.rs b/rust/compiler-ext/src/lib.rs
index 31e1bb2..58bdd0c 100644
--- a/rust/compiler-ext/src/lib.rs
+++ b/rust/compiler-ext/src/lib.rs
@@ -1,7 +1,337 @@
-#[cfg(test)]
-mod tests {
-#[test]
-fn it_works() {
-assert_eq!(2 + 2, 4);
-}
-}
+/*
+ * 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.
+ */
+
+ use std::os::raw::c_int;
+ use tvm::initialize;
+ use tvm::ir::{tir, PrimExpr};
+ use tvm::runtime::function::register_override;
+ use tvm::runtime::map::Map;
+ use tvm::runtime::object::{IsObject, IsObjectRef};
+ 
+ use ordered_float::NotNan;
+ 
+ mod interval;
+ mod math;
+ 
+ use math::{BoundsMap, Expr, RecExpr};
+ use tvm::ir::arith::ConstIntBound;
+ use tvm_rt::{ObjectRef, array::Array};
+ 
+ macro_rules! downcast_match {
+ ($id:ident; { $($t:ty => $arm:expr $(,)? )+ , else => $default:expr }) => 
{
+ $( if let Ok($id) = $id.downcast_clone::<$t>() { $arm } else )+
+ { $default }
+ }
+ }
+ 
+ #[derive(Default)]
+ struct VarMap {
+ vars: Vec<(tvm::ir::tir::Var, egg::Symbol)>,
+ objs: Vec,
+ }
+ 
+ impl VarMap {
+ // FIXME this should eventually do the right thing for TVM variables
+ // right now it depends on them having unique names
+ fn make_symbol( self, var: tvm::ir::tir::Var) -> egg::Symbol {
+ let sym = egg::Symbol::from(var.name_hint.as_str().unwrap());
+ for (_, sym2) in  {
+ if sym == *sym2 {
+ return sym;
+ }
+ }
+ 
+ self.vars.push((var, sym));
+ sym
+ }
+ 
+ fn get_symbol(, sym: egg::Symbol) -> tvm::ir::tir::Var {
+ for (v, sym2) in  {
+ if sym == *sym2 {
+ return v.clone();
+ }
+ }
+ panic!("Should have found a var")
+ }
+ 
+ fn push_obj( self, obj: impl IsObjectRef) -> usize {
+ let i = self.objs.len();
+ self.objs.push(obj.upcast());
+ i
+ }
+ 
+ fn get_obj(, i: usize) -> T {
+ self.objs[i].clone().downcast().expect("bad downcast")
+ }
+ }
+ 
+ fn to_egg(vars:  VarMap, prim: ) -> RecExpr {
+ fn build(vars:  VarMap, p: , recexpr:  RecExpr) -> 
egg::Id {
+ macro_rules! r {
+ ($e:expr) => {
+ build(vars, &$e, recexpr)
+ };
+ }
+ 
+ let dt = recexpr.add(Expr::DataType(p.datatype));
+ let e = downcast_match!(p; {
+ tir::Add => Expr::Add([dt, r!(p.a), r!(p.b)]),
+ tir::Sub => Expr::Sub([dt, r!(p.a), r!(p.b)]),
+ tir::Mul => Expr::Mul([dt, r!(p.a), r!(p.b)]),
+ 
+ tir::Div => Expr::Div([dt, r!(p.a), r!(p.b)]),
+ tir::Mod => Expr::Mod([dt, r!(p.a), r!(p.b)]),
+ tir::FloorDiv => Expr::FloorDiv([dt, r!(p.a), r!(p.b)]),
+ tir::FloorMod => Expr::FloorMod([dt, r!(p.a), r!(p.b)]),
+ 
+ tir::Min => Expr::Min([dt, r!(p.a), r!(p.b)]),
+ tir::Max => Expr::Max([dt, r!(p.a), r!(p.b)]),
+ 
+ tir::Ramp => Expr::Ramp([dt, r!(p.start), r!(p.stride), 
recexpr.add(Expr::Int(p.lanes.into()))]),
+ tir::Select => Expr::Select([dt, r!(p.condition), 
r!(p.true_value), r!(p.false_value)]),
+ 
+ tir::Eq => Expr::Equal([dt, r!(p.a), r!(p.b)]),
+ tir::Ne => Expr::NotEqual([dt, r!(p.a), r!(p.b)]),
+ tir::Lt => Expr::Less([dt, r!(p.a), r!(p.b)]),
+ tir::Le => Expr::LessEqual([dt, r!(p.a), r!(p.b)]),
+ tir::Gt => Expr::Greater([dt, r!(p.a), r!(p.b)]),
+ tir::Ge => Expr::GreaterEqual([dt, r!(p.a), r!(p.b)]),
+ 

  1   2   3   4   >