[GitHub] [incubator-tvm] kevinthesun commented on a change in pull request #4312: [TOPI][Relay][OP] Dynamic NMS and strided_slice

2020-04-24 Thread GitBox


kevinthesun commented on a change in pull request #4312:
URL: https://github.com/apache/incubator-tvm/pull/4312#discussion_r414959052



##
File path: src/relay/op/tensor/transform.cc
##
@@ -1891,81 +1952,163 @@ Array > StridedSliceInferCorrectLayout(
   }
 
   CHECK(old_in_layouts.defined());
-  CHECK_EQ(old_in_layouts.size(), 1);
+  CHECK_GE(old_in_layouts.size(), 1);
   CHECK(old_in_shapes.defined());
-  CHECK_EQ(old_in_shapes.size(), 1);
+  CHECK_GE(old_in_shapes.size(), 1);
 
   auto layout = old_in_layouts[0];
   if (layout.defined() && new_in_layouts.defined()) {
-CHECK_EQ(new_in_layouts.size(), 1);
+CHECK_GE(new_in_layouts.size(), 1);
 auto new_layout = new_in_layouts[0];
 auto shape = old_in_shapes[0];
 
 // NOTE: Discard "const" qualifier here.
 auto *params = 
const_cast(attrs.as());
+CHECK(params != nullptr);
+Array begin, end, strides;
+const ConstantNode *cbegin, *cend, *cstrides;
+if ((cbegin = params->begin.as()) &&
+(cend = params->end.as()) &&
+(cstrides = params->strides.as())) {
+  int64_t* strides_val = ToVector(cstrides->data);
+  for (int64_t i = 0; i < cstrides->data.Shape().front(); ++i) {
+strides.push_back(strides_val[i]);
+  }
+  int64_t* begin_val = ToVector(cbegin->data);
+  for (int64_t i = 0; i < cbegin->data.Shape().front(); ++i) {
+begin.push_back(begin_val[i]);
+  }
+  int64_t* end_val = ToVector(cend->data);
+  for (int64_t i = 0; i < cend->data.Shape().front(); ++i) {
+end.push_back(end_val[i]);
+  }
+}
 
 Array new_begin, new_end;
 
-for (size_t i = 0; i < params->begin.size(); i++) {
+for (size_t i = 0; i < begin.size(); i++) {
   const LayoutAxis& axis = layout[i];
   if (!axis.IsPrimal()) {
 // original layout that contains splitted axes is not supported
 return {{Layout::Undef()}, {Layout::Undef()}};
   }
   auto factor = new_layout.FactorOf(axis);
   if (factor == -1) {
-new_begin.push_back(params->begin[i]);
-new_end.push_back(params->end[i]);
+new_begin.push_back(begin[i]);
+new_end.push_back(end[i]);
   } else {
-if (params->strides.defined() && i < params->strides.size()) {
-  auto stride = params->strides[i];
+if (strides.defined() && i < strides.size()) {
+  auto stride = strides[i];
   // arbitrary stride is not supported
   if (stride.defined() && stride->value != 1) {
 return {{Layout::Undef()}, {Layout::Undef()}};
   }
 }
-int64_t begin = params->begin[i].defined() ? params->begin[i]->value : 
0;
-int64_t end = params->end[i].defined() ? params->end[i]->value :
+int64_t bg = begin[i].defined() ? begin[i]->value : 0;
+int64_t ed = end[i].defined() ? end[i]->value :
 shape[i].as()->value;
-if (begin % factor || end % factor) {
+if (bg % factor || ed % factor) {
   // transform to original layout
   return {{Layout::Undef()}, {Layout::Undef()}};
 }
-new_begin.push_back(tvm::Integer(begin / factor));
-new_end.push_back(tvm::Integer(end / factor));
+new_begin.push_back(tvm::Integer(bg / factor));
+new_end.push_back(tvm::Integer(ed / factor));
   }
 }
-layout = new_layout;
-params->begin = new_begin;
-params->end = new_end;
-  }
-  return {{layout}, {layout}};
-}
 
+layout = new_layout;
 
-// Positional relay function to create StridedSlice operator used by frontend 
FFI.
-Expr MakeStridedSlice(Expr data,
-  Array begin,
-  Array end,
-  Array strides) {
-  auto attrs = make_object();
-  attrs->begin = std::move(begin);
-  attrs->end = std::move(end);
-  attrs->strides = std::move(strides);
-  static const Op& op = Op::Get("strided_slice");
-  return Call(op, {data}, Attrs(attrs), {});
+DLContext ctx;
+ctx.device_type = kDLCPU;
+ctx.device_id = 0;
+auto begin_ndarray = runtime::NDArray::Empty({int64_t(new_begin.size())},
+ DataType::Int(64), ctx);
+auto end_ndarray = runtime::NDArray::Empty({int64_t(new_begin.size())},
+   DataType::Int(64), ctx);
+auto strides_ndarray = runtime::NDArray::Empty({int64_t(new_begin.size())},
+   DataType::Int(64), ctx);
+int64_t* begin_data = static_cast(begin_ndarray->data);
+int64_t* end_data = static_cast(end_ndarray->data);
+for (size_t i = 0; i < new_begin.size(); ++i) {
+  begin_data[i] = new_begin[i];
+  end_data[i] = new_end[i];
+}
+params->begin = Constant(begin_ndarray);
+params->end = Constant(end_ndarray);
+  }
+  return {{layout, Layout("C"), Layout("C"), Layout("C")}, {layout}};
+}
+
+inline te::Tensor DynamicStridedSlice(const 

[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414956089



##
File path: python/tvm/contrib/binutil.py
##
@@ -220,17 +228,32 @@ def tvm_callback_relocate_binary(
 stack_pointer_init=stack_pointer_init)
 
 tmp_dir = util.tempdir()
-rel_obj_path = tmp_dir.relpath("relocated.obj")
-rel_ld_script_path = tmp_dir.relpath("relocated.lds")
-with open(rel_ld_script_path, "w") as f:
+rel_obj_path = tmp_dir.relpath('relocated.obj')
+rel_ld_script_path = tmp_dir.relpath('relocate.lds')
+with open(rel_ld_script_path, 'w') as f:
 f.write(ld_script_contents)
 run_cmd([
-"{}ld".format(toolchain_prefix),
+'{}ld'.format(toolchain_prefix),
 binary_path,
-"-T", rel_ld_script_path,
-"-o", rel_obj_path])
-with open(rel_obj_path, "rb") as f:
+'-T', rel_ld_script_path,
+'-o', rel_obj_path])
+
+with open(rel_obj_path, 'rb') as f:
 rel_bin = bytearray(f.read())
+
+gdb_init_dir = os.environ.get('MICRO_GDB_INIT_DIR')
+if gdb_init_dir is not None:
+gdb_init_path = f'{gdb_init_dir}/.gdbinit'
+with open(gdb_init_path, 'r') as f:
+gdbinit_contents = f.read().split('\n')
+new_contents = []
+for line in gdbinit_contents:
+new_contents.append(line)
+if line.startswith('target'):
+new_contents.append(f'add-symbol-file {rel_obj_path}')
+with open(gdb_init_path, 'w') as f:
+f.write('\n'.join(new_contents))

Review comment:
   I think that's also going to change soon, so would prefer to fix then





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414955744



##
File path: python/tvm/micro/base.py
##
@@ -133,44 +152,91 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
 self._exit()
 
 
-def create_micro_mod(c_mod, dev_config):
+def _calc_max_workspace_usage(src):
+# TODO factor in alignment to the calculation (alloc sizes will be aligned 
up to the word size)
+alloc_re = re.compile(
+r'.*\* ?(.+) = (\(.+\))? TVMBackendAllocWorkspace\(.+, .+, 
\(uint64_t\)(.+), .+, .+\).*')
+free_re = re.compile(r'.*if \(TVMBackendFreeWorkspace\(.+, .+, 
(\(void\*\))? (.+)\) != 0\) {.*')
+max_usage = 0
+alloc_map = {}
+for line in src.split('\n'):
+if line.strip().startswith('//'):
+continue
+match = alloc_re.match(line)
+if match is not None:
+alloc_map[match.group(1)] = int(match.group(3))
+max_usage = max(max_usage, sum(alloc_map.values()))
+else:
+match = free_re.match(line)
+if match is not None:
+print(alloc_map)
+del alloc_map[match.group(2)]
+return max_usage
+
+

Review comment:
   yeah more robust memory analysis will come in a follow-on. can you 
explain what you mean by crash if it doesn't match the format given? I don't 
know it will crash if it finds 0 allocs, it will just not catch anything





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414955794



##
File path: python/tvm/micro/device/host.py
##
@@ -38,59 +52,65 @@ def create_micro_lib(obj_path, src_path, lib_type, 
options=None):
 
 options : Optional[List[str]]
 additional options to pass to GCC
+
+lib_src_paths : Optional[List[str]]
+paths to additional source files to be compiled into the library
 """
 if options is None:
 options = []
-if sys.maxsize > 2**32 and sys.platform.startswith("linux"):
-options += ["-mcmodel=large"]
+else:
+options = list(options)
+# Cannot increase optimization level on host due to code loading method.
+options.append('-O0')

Review comment:
   let's just leave as is for now--the runtime will change a lot soon





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414955335



##
File path: python/tvm/contrib/debugger/debug_runtime.py
##
@@ -181,6 +181,7 @@ def _run_debug(self):
 """
 self.debug_datum._time_list = [
 [float(t) * 1e-6] for t in self.run_individual(10, 1, 1)
+#[float(t) * 1e-6] for t in self.run_individual(1, 1, 1)

Review comment:
   done





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] masahi commented on pull request #5431: misc fixes for ROCm

2020-04-24 Thread GitBox


masahi commented on pull request #5431:
URL: https://github.com/apache/incubator-tvm/pull/5431#issuecomment-619299391


   Thanks @t-vi for fixing this. I recently did a clean install of rocm 3.3 and 
hit segfault from CodeGenLLVM destructor because of this. Now TVM + rocm is 
working again.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] masahi commented on pull request #5433: fix miopen padding

2020-04-24 Thread GitBox


masahi commented on pull request #5433:
URL: https://github.com/apache/incubator-tvm/pull/5433#issuecomment-619299101


   Thanks @t-vi 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[incubator-tvm] branch master updated (83930a3 -> 2dbe626)

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

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


from 83930a3  [PYTORCH]Rsub, Embedded, OneHot ops support (#5434)
 add 2dbe626  fix miopen pad (#5433)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/op/strategy/rocm.py | 4 +++-
 topi/python/topi/rocm/conv2d.py  | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)



[GitHub] [incubator-tvm] yongfeng-nv commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


yongfeng-nv commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414946295



##
File path: src/te/operation/compute_op.cc
##
@@ -231,20 +231,18 @@ void ComputeOpNode::PropBoundToInputs(
   // undefined behaviour), so we can intersect the estimated set of 
the argument with the
   // range expected by the tensor. However, intersection may result in 
overly complex
   // expressions, so we perform a more relaxed form of intersection.
-  IntSet arg_intset = EvalSet(call->args[i], dom_map);
+  IntSet arg_intset = analyzer->int_set(call->args[i], 
ConvertDomMap(dom_map));
   const arith::IntervalSetNode* arg_interval = 
arg_intset.as();
   if (arg_interval) {
 PrimExpr shape_i_min_value = make_zero(t->shape[i].dtype());
 PrimExpr shape_i_max_value = t->shape[i] - 1;
 PrimExpr min_value = arg_interval->min_value;
 PrimExpr max_value = arg_interval->max_value;
 // Prefer the shape bounds only when we can prove they are tighter.
-if (arith::is_neg_inf(min_value) ||
-analyzer->CanProve(shape_i_min_value >= min_value)) {
+if ((arith::is_pos_inf(max_value) && arith::is_neg_inf(min_value)) 
||
+(analyzer->CanProve(shape_i_min_value >= min_value) &&
+ analyzer->CanProve(shape_i_max_value <= max_value))) {

Review comment:
   `tests/python/unittest/test_target_codegen_blob.py` exposes a case, 
where `shape_i` is `[0, 0]` and arg_interval is `[threadIdx.y, 
threadIdx.y]`,where `threadIdx.y`'s range is `[0, 7]`.  Either `[0, 0]` or 
`[threadIdx.y, threadIdx.y]` is fine.  The current logic ends with 
`[threadIdx.y, 0]`, messing up further transforms and triggering an assertion 
later.  We'd better to update both ends at the same time, i.e. treating 
IntervalSet as an atomic object.  Adding this explanation as comment in the 
code.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] masahi commented on pull request #5434: [PYTORCH]Rsub, Embedded, OneHot ops support

2020-04-24 Thread GitBox


masahi commented on pull request #5434:
URL: https://github.com/apache/incubator-tvm/pull/5434#issuecomment-619298153


   Thanks @siju-samuel 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[incubator-tvm] branch master updated (52bf1b3 -> 83930a3)

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

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


from 52bf1b3  [RELAY][PYTORCH]cosh,sinh,log2,log10,log1p op support (#5395)
 add 83930a3  [PYTORCH]Rsub, Embedded, OneHot ops support (#5434)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/pytorch.py  | 47 
 tests/python/frontend/pytorch/test_forward.py | 53 +++
 2 files changed, 100 insertions(+)



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

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

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


from 3cc4971  [RUNTIME][OBJECT] Introduce static slots for common objects. 
(#5423)
 add 52bf1b3  [RELAY][PYTORCH]cosh,sinh,log2,log10,log1p op support (#5395)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/pytorch.py  | 13 +
 python/tvm/relay/op/_tensor.py|  4 ++
 python/tvm/relay/op/_tensor_grad.py   | 34 ++
 python/tvm/relay/op/tensor.py | 60 +++
 python/tvm/relay/op/transform.py  |  2 +-
 python/tvm/te/__init__.py |  1 +
 python/tvm/tir/op.py  |  2 +-
 src/relay/op/tensor/unary.cc  | 44 +
 src/target/intrin_rule.cc | 12 +
 tests/python/frontend/pytorch/test_forward.py | 25 ++
 tests/python/relay/test_op_grad_level1.py |  6 ++-
 topi/include/topi/elemwise.h  |  4 ++
 topi/python/topi/math.py  | 68 +++
 topi/src/elemwise.cc  | 20 
 14 files changed, 292 insertions(+), 3 deletions(-)



[GitHub] [incubator-tvm] yongfeng-nv commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


yongfeng-nv commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414944483



##
File path: include/tvm/arith/analyzer.h
##
@@ -411,8 +412,9 @@ class TVM_DLL Analyzer {
*
* \param var The variable.
* \param expr The expression we bind to.
+   * \param override Whether do we allow override of existing information.

Review comment:
   Rephrasing the comments.  Thanks





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] yongfeng-nv commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


yongfeng-nv commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414940958



##
File path: src/arith/int_set.cc
##
@@ -311,6 +311,16 @@ inline IntervalSet Combine(Analyzer* 
analyzer,
   LOG(FATAL) << "Modular by zero in CombineInterval Mod";
 }
 if (analyzer->CanProveGreaterEqual(divisor, 0)) {
+  if (b->min_value.as()) {

Review comment:
   Make sense.  I will make the change.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tmoreau89 opened a new pull request #5442: [Docs] VTA install doc migration from md to rst

2020-04-24 Thread GitBox


tmoreau89 opened a new pull request #5442:
URL: https://github.com/apache/incubator-tvm/pull/5442


   Addresses issue #5396
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] roastduck commented on pull request #5382: [TE] Fix MakeLoopNest for warp memory

2020-04-24 Thread GitBox


roastduck commented on pull request #5382:
URL: https://github.com/apache/incubator-tvm/pull/5382#issuecomment-619291622


   Do you mean requiring the users to tag the iter_var or we do it in 
InferBound? If the former, maybe we can merge this PR first and then start an 
RFC for the API change. If the latter, can you point out where to tag the 
iter_var? I am not familiar with InferBound.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414919556



##
File path: topi/python/topi/arm_cpu/cortex_m7/micro_kernel/gemm.py
##
@@ -0,0 +1,221 @@
+# 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.
+# pylint: disable=invalid-name, no-value-for-parameter
+"""Defines gemm intrinsics for SIMD matrix multiplication."""
+
+import random
+import string
+
+import tvm
+from tvm import te
+
+##
+# MxKxN MatMul Intrinsic #
+##
+
+# NOTE this is transposed matmul (A * B^T)
+def intrin_gemm_MxKxN(M, K, N, in_dtype, out_dtype):
+"""Defines a SIMD-accelerated transposed matmul."""
+# we generate a unique ID for every intrinsic definition, to prevent name
+# collisions in the generated source (e.g., if there are multiple operators
+# in the same module that use the same intrinsic)
+#
+# TODO to cut down on memory usage, we should cache each intrinsic
+# instantiation and include it only once, eliminating the need for unique
+# IDs
+UNIQ_ID_LEN = 8
+uniq_id = ''.join(random.choices(string.ascii_uppercase, k=UNIQ_ID_LEN))
+
+if isinstance(M, tvm.tir.IntImm):
+M = M.value
+if isinstance(K, tvm.tir.IntImm):
+K = K.value
+if isinstance(N, tvm.tir.IntImm):
+N = N.value
+assert K % 4 == 0
+# TODO support more dtypes?
+assert in_dtype == 'int8'
+assert out_dtype == 'int32'
+A = te.placeholder((M, K), name='a', dtype=in_dtype)
+B = te.placeholder((N, K), name='b', dtype=in_dtype)
+k = te.reduce_axis((0, K), name='k')
+C = te.compute(
+(M, N),
+lambda i, j: te.sum(A[i, k].astype(out_dtype) * B[j, 
k].astype(out_dtype), axis=k),
+name='c')
+A_buf = tvm.tir.decl_buffer(
+A.shape, A.dtype,
+name="A",
+offset_factor=1,
+strides=[te.var("A_s"), 1])
+B_buf = tvm.tir.decl_buffer(
+B.shape, B.dtype,
+name="B",
+offset_factor=1,
+strides=[te.var("B_s"), 1])
+C_buf = tvm.tir.decl_buffer(
+C.shape, C.dtype,
+name="C",
+offset_factor=1,
+strides=[te.var("C_s"), 1])
+def intrin_func(ins, outs):
+aa, bb = ins
+cc = outs[0]
+def _reduce_update():
+ib = tvm.tir.ir_builder.create()
+ib.emit(tvm.tir.call_extern("int32", 
f"gemm_{M}x{K}x{N}_update_{uniq_id}",
+aa.access_ptr("r"),
+bb.access_ptr("r"),
+cc.access_ptr("w"),
+aa.strides[0],
+bb.strides[0],
+cc.strides[0]))
+return ib.get()
+def _reduce_reset():
+ib = tvm.tir.ir_builder.create()
+ib.emit(tvm.tir.call_extern("int32", 
f"gemm_{M}x{K}x{N}_reset_{uniq_id}",
+cc.access_ptr("w"),
+cc.strides[0]))
+return ib.get()
+def _body():
+ib = tvm.tir.ir_builder.create()
+# # NOTE we need the reset in the body for cases where the buffer
+# # we're accumulating into is uninitialized (e.g., if it's the
+# # result of a workspace allocation, because there are no 
guarantees
+# # on the contents).
+# ib.emit(tvm.tir.call_extern("int32", f"gemm_{M}x{K}x{N}_reset",
+# cc.access_ptr("w"),
+# cc.strides[0]))
+# ib.emit(tvm.tir.call_extern("int32", f"gemm_{M}x{K}x{N}_update",
+# aa.access_ptr("r"),
+# bb.access_ptr("r"),
+# cc.access_ptr("w"),
+# aa.strides[0],
+# bb.strides[0],
+# cc.strides[0]))
+ib.emit(tvm.tir.call_extern("int32", 
f"gemm_{M}x{K}x{N}_body_{uniq_id}",
+  

[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414919196



##
File path: tests/python/unittest/test_runtime_micro.py
##
@@ -25,8 +25,25 @@
 from tvm.micro import create_micro_mod
 from tvm.relay.testing import resnet
 
-# Use the host emulated micro device.
-DEV_CONFIG = micro.device.host.default_config()
+# # Use the host emulated micro device.
+DEV_CONFIG_A = micro.device.host.generate_config()
+DEV_CONFIG_B = micro.device.host.generate_config()
+TARGET = 'c -device=micro_dev'

Review comment:
   we still have test_interleave_sessions for now though?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414919333



##
File path: topi/python/topi/arm_cpu/conv2d_spatial_pack.py
##
@@ -173,7 +173,7 @@ def schedule_conv2d_spatial_pack_nchw(cfg, s, data_vec, 
kernel_vec,
  axis_lens=[cfg['tile_oh'].size[-1],
 cfg['tile_ow'].size[-1],
 cfg['tile_co'].size[-1]],
- max_unroll=16,
+ max_unroll=None,

Review comment:
   done





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414918682



##
File path: src/runtime/micro/openocd_low_level_device.cc
##
@@ -210,9 +210,9 @@ class OpenOCDLowLevelDevice final : public LowLevelDevice {
   // NOTE: OpenOCD will call any request larger than this constant an "absurd
   // request".
   /*! \brief maximum number of bytes allowed in a single memory transfer */
-  static const constexpr ssize_t kMemTransferLimit = 64000;
+  static const constexpr ssize_t kMemTransferLimit = 8000;

Review comment:
   I can't remember anymore exactly where this limit hits, but iirc it's 
due to mac os x pipe buffering. I think it's because we are reading the pipe 
line by line on the TVM side, but if you issue a memory transfer that prints 
more than ~24k of characters, the os pipe buffer fills up before the newline 
char is sent and we deadlock. updated comment.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] areusch commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


areusch commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414918275



##
File path: src/runtime/micro/micro_session.cc
##
@@ -489,6 +629,16 @@ PackedFunc MicroSession::GetFunction(
 return PackedFunc([sptr_to_self](TVMArgs args, TVMRetValue* rv) {
   MicroSession::ExitWithScope();
 });
+// TODO(weberlo): add a `clear_batch_timer` func
+  } else if (name == "get_last_batch_time") {
+return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
+  *rv = this->GetLastBatchTime();
+});
+// TODO(weberlo): remove this func
+  } else if (name == "get_last_batch_cycles") {
+return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
+  *rv = this->GetLastBatchCycles();
+});

Review comment:
   right now it returns either last host or last device time based on 
`use_device_timer`. I agree we should rethink the timing API, but perhaps we 
can move it to next PR, when I would want to implement an API between the host 
and device, and we can better define the concept of batch time (and the units 
it is logged in) there?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] mbrookhart commented on a change in pull request #5441: Add TopK to ONNX Frontend

2020-04-24 Thread GitBox


mbrookhart commented on a change in pull request #5441:
URL: https://github.com/apache/incubator-tvm/pull/5441#discussion_r414914928



##
File path: python/tvm/relay/frontend/onnx.py
##
@@ -1470,6 +1470,23 @@ def _impl_v9(cls, inputs, attr, params):
 output = AttrCvt(op_name='argwhere')(inputs, attr, params)
 return _op.transpose(output, axes=(1, 0))
 
+class TopK(OnnxOpConverter):
+"""Operator converter for TopK
+"""
+@classmethod
+def _impl_v1(cls, inputs, attr, params):
+if len(inputs) != 2:
+raise ValueError("Expect 2 input only")
+inp = inputs[0]
+axis = attr.get("axis", len(infer_shape(inp)) - 1)
+largest = attr.get("largest", 1)
+
+if largest == 0:
+raise ValueError("TVM only supports finding TopK largest elements")

Review comment:
   It's a boolean value stored as an int. Anything but zero is technically 
true, and I only want to throw on the false case.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] weberlo commented on a change in pull request #5417: [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7

2020-04-24 Thread GitBox


weberlo commented on a change in pull request #5417:
URL: https://github.com/apache/incubator-tvm/pull/5417#discussion_r414765031



##
File path: python/tvm/autotvm/tuner/tuner.py
##
@@ -150,7 +150,15 @@ def tune(self, n_trial, measure_option, 
early_stopping=None, callbacks=(), si_pr
  i + k + 1, si_prefix, format_si_prefix(flops, 
si_prefix),
  format_si_prefix(self.best_flops, si_prefix), 
res, config)
 
-i += len(results)
+num_successes = 0
+for result in results:
+if isinstance(result.costs[0], float):
+num_successes += 1
+if num_successes != len(results):
+logger.debug('not counting %d failures towards trial count',
+ len(results) - num_successes)
+i += num_successes
+

Review comment:
   we should probably remove this for the time being. I added this when 
µTVM autotuning support was still pretty unstable, because there were _a lot_ 
of failed trials

##
File path: python/tvm/contrib/binutil.py
##
@@ -220,17 +228,32 @@ def tvm_callback_relocate_binary(
 stack_pointer_init=stack_pointer_init)
 
 tmp_dir = util.tempdir()
-rel_obj_path = tmp_dir.relpath("relocated.obj")
-rel_ld_script_path = tmp_dir.relpath("relocated.lds")
-with open(rel_ld_script_path, "w") as f:
+rel_obj_path = tmp_dir.relpath('relocated.obj')
+rel_ld_script_path = tmp_dir.relpath('relocate.lds')
+with open(rel_ld_script_path, 'w') as f:
 f.write(ld_script_contents)
 run_cmd([
-"{}ld".format(toolchain_prefix),
+'{}ld'.format(toolchain_prefix),
 binary_path,
-"-T", rel_ld_script_path,
-"-o", rel_obj_path])
-with open(rel_obj_path, "rb") as f:
+'-T', rel_ld_script_path,
+'-o', rel_obj_path])
+
+with open(rel_obj_path, 'rb') as f:
 rel_bin = bytearray(f.read())
+
+gdb_init_dir = os.environ.get('MICRO_GDB_INIT_DIR')
+if gdb_init_dir is not None:
+gdb_init_path = f'{gdb_init_dir}/.gdbinit'
+with open(gdb_init_path, 'r') as f:
+gdbinit_contents = f.read().split('\n')
+new_contents = []
+for line in gdbinit_contents:
+new_contents.append(line)
+if line.startswith('target'):
+new_contents.append(f'add-symbol-file {rel_obj_path}')
+with open(gdb_init_path, 'w') as f:
+f.write('\n'.join(new_contents))

Review comment:
   It might be worth splitting these lines into a separate µTVM debugging 
tools PR

##
File path: python/tvm/micro/device/host.py
##
@@ -38,59 +52,65 @@ def create_micro_lib(obj_path, src_path, lib_type, 
options=None):
 
 options : Optional[List[str]]
 additional options to pass to GCC
+
+lib_src_paths : Optional[List[str]]
+paths to additional source files to be compiled into the library
 """
 if options is None:
 options = []
-if sys.maxsize > 2**32 and sys.platform.startswith("linux"):
-options += ["-mcmodel=large"]
+else:
+options = list(options)
+# Cannot increase optimization level on host due to code loading method.
+options.append('-O0')

Review comment:
   `-Os` (and maybe `-O1`) work. it's just `-O2` that's been causing 
problems on the host

##
File path: python/tvm/contrib/debugger/debug_runtime.py
##
@@ -181,6 +181,7 @@ def _run_debug(self):
 """
 self.debug_datum._time_list = [
 [float(t) * 1e-6] for t in self.run_individual(10, 1, 1)
+#[float(t) * 1e-6] for t in self.run_individual(1, 1, 1)

Review comment:
   remove

##
File path: src/runtime/micro/host_driven/utvm_runtime.c
##
@@ -34,89 +34,148 @@ extern "C" {
 
 #include "utvm_runtime.h"
 
-// Task pointers must be patched before calling a function.
-UTVMTask utvm_task = {
-.func = NULL,
-.arg_values = NULL,
-.arg_type_codes = NULL,
-.num_args = 0,
-};
-
-size_t utvm_word_size = 0;  // NOLINT(*)
+// TODO(areusch): move defines into header
+#define TASK_QUEUE_SIZE 20
+volatile UTVMTask utvm_tasks[TASK_QUEUE_SIZE] = { };
+volatile uint32_t utvm_num_tasks = 0;
+volatile uint32_t utvm_task_times[TASK_QUEUE_SIZE] = { };
 
 // These pointers are patched at load time to point to the workspace section.
-char* utvm_workspace_start = NULL;  // NOLINT(*)
-char* utvm_workspace_end = NULL;// NOLINT(*)
-char* utvm_workspace_curr = NULL;   // NOLINT(*)
+volatile char* utvm_workspace_start = NULL;  // NOLINT(*)
+volatile char* utvm_workspace_end = NULL;// NOLINT(*)
+volatile char* utvm_workspace_curr = NULL;   // NOLINT(*)
+#define MAX_WS_ALLOCS 10
+volatile char* utvm_alloc_ends[MAX_WS_ALLOCS] = {};  // NOLINT(*)
+volatile uint32_t utvm_alloc_idx = 0;
 // Keep track of how many active allocations there are on the 

[GitHub] [incubator-tvm] yzhliu commented on issue #3670: [RFC] AlterOpLayout Pass Refactoring

2020-04-24 Thread GitBox


yzhliu commented on issue #3670:
URL: https://github.com/apache/incubator-tvm/issues/3670#issuecomment-619263443


   @mbrookhart not at all, please feel free to proceed :)



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] hcho3 commented on issue #4953: [CI][Docker] xgboost 1.0.1 causes segfault on test_autotvm_xgboost_model.py

2020-04-24 Thread GitBox


hcho3 commented on issue #4953:
URL: https://github.com/apache/incubator-tvm/issues/4953#issuecomment-619255802


   @leandron @areusch @tqchen I've put up RC1 for the upcoming XGBoost 1.1.0 
release. Feel free to try it:
   ```
   python3 -m pip install xgboost==1.1.0rc1
   ```
   
   The unit test should not crash.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] mbrookhart commented on issue #3670: [RFC] AlterOpLayout Pass Refactoring

2020-04-24 Thread GitBox


mbrookhart commented on issue #3670:
URL: https://github.com/apache/incubator-tvm/issues/3670#issuecomment-619253852


   @yzhliu I've hit a couple of issue that would be completely solved by this 
change :). Any chance you've made progress? If not, would you be offended if I 
gave it a shot over the next few weeks?



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] yzhliu commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


yzhliu commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414870644



##
File path: include/tvm/arith/analyzer.h
##
@@ -411,8 +412,9 @@ class TVM_DLL Analyzer {
*
* \param var The variable.
* \param expr The expression we bind to.
+   * \param override Whether do we allow override of existing information.

Review comment:
   ```suggestion
  * \param override Whether do we allow override of existing binding 
variables.
   ```
   suggest to be more specific.

##
File path: src/arith/int_set.cc
##
@@ -311,6 +311,16 @@ inline IntervalSet Combine(Analyzer* 
analyzer,
   LOG(FATAL) << "Modular by zero in CombineInterval Mod";
 }
 if (analyzer->CanProveGreaterEqual(divisor, 0)) {
+  if (b->min_value.as()) {

Review comment:
   use `divisor` to keep consistent?

##
File path: src/te/operation/compute_op.cc
##
@@ -231,20 +231,18 @@ void ComputeOpNode::PropBoundToInputs(
   // undefined behaviour), so we can intersect the estimated set of 
the argument with the
   // range expected by the tensor. However, intersection may result in 
overly complex
   // expressions, so we perform a more relaxed form of intersection.
-  IntSet arg_intset = EvalSet(call->args[i], dom_map);
+  IntSet arg_intset = analyzer->int_set(call->args[i], 
ConvertDomMap(dom_map));
   const arith::IntervalSetNode* arg_interval = 
arg_intset.as();
   if (arg_interval) {
 PrimExpr shape_i_min_value = make_zero(t->shape[i].dtype());
 PrimExpr shape_i_max_value = t->shape[i] - 1;
 PrimExpr min_value = arg_interval->min_value;
 PrimExpr max_value = arg_interval->max_value;
 // Prefer the shape bounds only when we can prove they are tighter.
-if (arith::is_neg_inf(min_value) ||
-analyzer->CanProve(shape_i_min_value >= min_value)) {
+if ((arith::is_pos_inf(max_value) && arith::is_neg_inf(min_value)) 
||
+(analyzer->CanProve(shape_i_min_value >= min_value) &&
+ analyzer->CanProve(shape_i_max_value <= max_value))) {

Review comment:
   could you elaborate a bit why do we need this change?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] jwfromm commented on a change in pull request #5441: Add TopK to ONNX Frontend

2020-04-24 Thread GitBox


jwfromm commented on a change in pull request #5441:
URL: https://github.com/apache/incubator-tvm/pull/5441#discussion_r414874263



##
File path: python/tvm/relay/frontend/onnx.py
##
@@ -1470,6 +1470,23 @@ def _impl_v9(cls, inputs, attr, params):
 output = AttrCvt(op_name='argwhere')(inputs, attr, params)
 return _op.transpose(output, axes=(1, 0))
 
+class TopK(OnnxOpConverter):
+"""Operator converter for TopK
+"""
+@classmethod
+def _impl_v1(cls, inputs, attr, params):
+if len(inputs) != 2:
+raise ValueError("Expect 2 input only")
+inp = inputs[0]
+axis = attr.get("axis", len(infer_shape(inp)) - 1)
+largest = attr.get("largest", 1)
+
+if largest == 0:
+raise ValueError("TVM only supports finding TopK largest elements")

Review comment:
   maybe assert that `largest > 0` to catch negative cases as well.

##
File path: python/tvm/relay/frontend/onnx.py
##
@@ -1470,6 +1470,23 @@ def _impl_v9(cls, inputs, attr, params):
 output = AttrCvt(op_name='argwhere')(inputs, attr, params)
 return _op.transpose(output, axes=(1, 0))
 
+class TopK(OnnxOpConverter):
+"""Operator converter for TopK
+"""
+@classmethod
+def _impl_v1(cls, inputs, attr, params):
+if len(inputs) != 2:
+raise ValueError("Expect 2 input only")
+inp = inputs[0]
+axis = attr.get("axis", len(infer_shape(inp)) - 1)

Review comment:
   why not use `-1` as axis instead of inferring shape here?

##
File path: tests/python/frontend/onnx/test_forward.py
##
@@ -2330,6 +2330,44 @@ def verify_nonzero(indata, outdata, dtype):
 result = np.array((np.nonzero(input_data)))  # expected output [[0, 1, 2, 
2], [0, 1, 0, 1]]
 verify_nonzero(input_data, result, dtype=np.int64)
 
+def test_topk():
+def verify_topk(input_dims, K, axis=-1):
+output_dims = list(input_dims)
+output_dims[axis] = K
+
+node = helper.make_node('TopK',
+inputs=['X', 'K'],
+outputs=['Values', 'Indicies'],
+axis=axis)
+
+graph = helper.make_graph([node],
+  "topk_test",
+  inputs=[helper.make_tensor_value_info("X", 
TensorProto.FLOAT, list(input_dims)),
+  helper.make_tensor_value_info("K", 
TensorProto.INT64, [1,])],
+  initializer=[helper.make_tensor("K", 
TensorProto.INT64, [1], [K])],
+  
outputs=[helper.make_tensor_value_info("Values", TensorProto.FLOAT, 
output_dims), 
+   
helper.make_tensor_value_info("Indicies", TensorProto.INT64, output_dims)])
+
+model = helper.make_model(graph, producer_name='topk_test')
+
+indata = np.random.uniform(-10, 10, input_dims).astype(np.float32)
+onnx_out = get_onnxruntime_output(model, [indata, k])
+print(onnx_out)
+
+for target, ctx in [('llvm', tvm.cpu())]:
+tvm_out = get_tvm_output(model, indata, target, ctx, [output_dims, 
output_dims], 
+output_dtype=['float32', 'int64'])
+print(tvm_out)
+tvm.testing.assert_allclose(onnx_out, tvm_out, rtol=1e-05, 
atol=1e-05)
+
+for shape in [[10], [10, 10], [10, 10, 10]]:
+for k in [1, 5, 10]:
+verify_topk(shape, k)
+
+verify_topk([10,10,10], 5, 0)
+verify_topk([10,10,10], 5, 1)
+verify_topk([10,10,10], 5, 2)

Review comment:
   It's probably worth testing at least one other input dimension.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] wpan11nv edited a comment on pull request #5382: [TE] Fix MakeLoopNest for warp memory

2020-04-24 Thread GitBox


wpan11nv edited a comment on pull request #5382:
URL: https://github.com/apache/incubator-tvm/pull/5382#issuecomment-619201349


   Can we make it explicit, e.g by tagging the binding iter_var with "warp" 
scope. For CUDA, when the block configuration is (1, 32), threadIdx.y may be 
the thread var to access the warp scope memory.
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] mbrookhart opened a new pull request #5441: Add TopK to ONNX Frontend

2020-04-24 Thread GitBox


mbrookhart opened a new pull request #5441:
URL: https://github.com/apache/incubator-tvm/pull/5441


   @masahi @jwfromm
   
   Thanks!
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] yzhliu commented on pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


yzhliu commented on pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#issuecomment-619238149


   @icemelon9 is this what you're looking for?



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] wpan11nv edited a comment on pull request #5382: [TE] Fix MakeLoopNest for warp memory

2020-04-24 Thread GitBox


wpan11nv edited a comment on pull request #5382:
URL: https://github.com/apache/incubator-tvm/pull/5382#issuecomment-619201349


   Can we make it explicit, e.g by tagging the binding iter_var with "warp" 
scope. For CUDA, when the block configuration is (1, 32), threadIdx.y may 
"define" the warp scope.
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] zhiics edited a comment on pull request #5438: [POC][IR] Initial stab at std::string->String upgrade

2020-04-24 Thread GitBox


zhiics edited a comment on pull request #5438:
URL: https://github.com/apache/incubator-tvm/pull/5438#issuecomment-619216822


   @tqchen ahh, I see. I was thinking if it is necessary to have some stuff 
like Load/Save for tvm::String separately, so that we don't need to put them 
under serialization.cc. Looks it is not really needed. Thanks.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] zhiics commented on pull request #5438: [POC][IR] Initial stab at std::string->String upgrade

2020-04-24 Thread GitBox


zhiics commented on pull request #5438:
URL: https://github.com/apache/incubator-tvm/pull/5438#issuecomment-619216822


   @tqchen ahh, I see. I was thinking if it is necessary to have similar stuff 
like Load/Save for tvm::String, so that we don't need to put them under 
serialization.cc. Looks it is not really needed. Thanks.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] michalpiszczek commented on a change in pull request #5437: [TFLite Runtime] Add TFLite Runtime dependencies to CI CPU docker build

2020-04-24 Thread GitBox


michalpiszczek commented on a change in pull request #5437:
URL: https://github.com/apache/incubator-tvm/pull/5437#discussion_r414833737



##
File path: docker/install/ubuntu_install_tflite.sh
##
@@ -26,12 +26,18 @@ cd flatbuffers
 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
 make install -j8
 cd ..
-rm -rf flatbuffers
 
 # Install flatbuffers python packages.
 pip3 install flatbuffers
 pip2 install flatbuffers
 
+# Build the TFLite static library, necessary for building with TFLite ON.
+# The library is built at:
+# tensorflow/tensorflow/lite/tools/make/gen/*/lib/libtensorflow-lite.a.
+git clone https://github.com/tensorflow/tensorflow --branch=r2.0

Review comment:
   @u99127 Good catch, thank you. I noticed your PR updating the version 
yesterday but I forgot I was specifying 2.0 here. Will update :) 





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] dreamqin68 opened a new issue #5440: import vta: Cannot find config in /3rdparty/vta-hw/config/vta_config.json

2020-04-24 Thread GitBox


dreamqin68 opened a new issue #5440:
URL: https://github.com/apache/incubator-tvm/issues/5440


   I installed VTA according to the VTA Simulator Installation guide. Then I 
set the environment. But when I imported vta, there was a bug.
   
   `Traceback (most recent call last):
   
 File "", line 1, in 
   
 File "/home/dream/tvm/vta/python/vta/__init__.py", line 27, in 
   from .bitstream import get_bitstream_path, download_bitstream
   
 File "/home/dream/tvm/vta/python/vta/bitstream.py", line 24, in 
   from .environment import get_env
   
 File "/home/dream/tvm/vta/python/vta/environment.py", line 325, in 
   Environment.current = _init_env()
   
 File "/home/dream/tvm/vta/python/vta/environment.py", line 321, in 
_init_env
   raise RuntimeError("Cannot find config in %s" % str(config_path))
   
   RuntimeError: Cannot find config in /3rdparty/vta-hw/config/vta_config.json`
   
   In fact, I found `vta_config.json` in `/3rdparty/vta-hw/config/`. 
   
   I don't know how to fix it.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] u99127 commented on a change in pull request #5437: [TFLite Runtime] Add TFLite Runtime dependencies to CI CPU docker build

2020-04-24 Thread GitBox


u99127 commented on a change in pull request #5437:
URL: https://github.com/apache/incubator-tvm/pull/5437#discussion_r414830870



##
File path: docker/install/ubuntu_install_tflite.sh
##
@@ -26,12 +26,18 @@ cd flatbuffers
 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
 make install -j8
 cd ..
-rm -rf flatbuffers
 
 # Install flatbuffers python packages.
 pip3 install flatbuffers
 pip2 install flatbuffers
 
+# Build the TFLite static library, necessary for building with TFLite ON.
+# The library is built at:
+# tensorflow/tensorflow/lite/tools/make/gen/*/lib/libtensorflow-lite.a.
+git clone https://github.com/tensorflow/tensorflow --branch=r2.0

Review comment:
   why not 2.1.0 which is the latest stable version and what we install in 
the tree. I don’t think it’s worth the version skew.
   
   
   Ramana 





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] wpan11nv edited a comment on pull request #5428: [CODEGEN][CUDA] Fix a bug when vectorized load was involved for…

2020-04-24 Thread GitBox


wpan11nv edited a comment on pull request #5428:
URL: https://github.com/apache/incubator-tvm/pull/5428#issuecomment-619214302


   Could you please add a few tests.Do you mean loading uchar2x4? We could 
load/store them as uint16_t x  4.  I do not see similar code  in PrintType 
below:
   
   
https://github.com/apache/incubator-tvm/blob/master/src/target/source/codegen_cuda.cc#L186



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] wpan11nv commented on pull request #5428: [CODEGEN][CUDA] Fix a bug when vectorized load was involved for…

2020-04-24 Thread GitBox


wpan11nv commented on pull request #5428:
URL: https://github.com/apache/incubator-tvm/pull/5428#issuecomment-619214302


   Could you please add a few tests.Do you mean supporting loading uchar2x4? We 
could load/store them as uint16_t x  4.  I do not see similar code  in 
PrintType below:
   
   
https://github.com/apache/incubator-tvm/blob/master/src/target/source/codegen_cuda.cc#L186



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on pull request #5438: [POC][IR] Initial stab at std::string->String upgrade

2020-04-24 Thread GitBox


tqchen commented on pull request #5438:
URL: https://github.com/apache/incubator-tvm/pull/5438#issuecomment-619211235


   @jroesch @zhiics 
   wrt to the String serialization. Right now String is serialized as an normal 
object. So if the content of String is printable, it will show up as
   
   ```python
   {type_key: "runtime.String", repr_str: "mystring"}
   ```
   
   If the content of the string is not printable, then it will show up as 
   
   ```python
   {type_key: "runtime.String", repr_b64: "base64encoding"}
   ```
   
   So the new IR entry will look like (note that the name field actually stores 
the index to the node table
   ```
   [
 {"type_key": "TypeVar", "attrs" : { "name": "2" }},
 {type_key: "runtime.String", repr_str: "myname"}
   ]
   ```
   This mechanism is baked into json serialization so it is a bit hard to move 
out. Of course we could also say that String should mostly be printable, and 
use a special serialization(e.g. just print as str when it is an old  str 
attribute) Thet is a special case though and makes the json serialization 
harder to work with when directly serialize a String object itself.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[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(-)



[GitHub] [incubator-tvm] tqchen commented on a change in pull request #5438: [POC][IR] Initial stab at std::string->String upgrade

2020-04-24 Thread GitBox


tqchen commented on a change in pull request #5438:
URL: https://github.com/apache/incubator-tvm/pull/5438#discussion_r414821178



##
File path: python/tvm/ir/json_compact.py
##
@@ -84,12 +91,26 @@ def _update_global_key(item, _):
 del item["global_key"]
 return item
 
+def _update_from_std_str(key):
+def _convert(item, nodes):
+str_val = item["attrs"][key]
+jdata = json.loads(tvm.ir.save_json(tvm.runtime.String(str_val)))

Review comment:
   Can you elaborate a bit about what do you mean? Right now all tvm 
objects are serialized through save_json, what we are doing here is to get that 
particular entry and append to the end of the nodes. 





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] anijain2305 opened a new pull request #5439: TFlite e2e FP32 Object detection model

2020-04-24 Thread GitBox


anijain2305 opened a new pull request #5439:
URL: https://github.com/apache/incubator-tvm/pull/5439


   TBD
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] wpan11nv commented on pull request #5382: [TE] Fix MakeLoopNest for warp memory

2020-04-24 Thread GitBox


wpan11nv commented on pull request #5382:
URL: https://github.com/apache/incubator-tvm/pull/5382#issuecomment-619201349


   Can we make it explicit, e.g by tagging the binding iter_var with "warp" 
scope. The existing "warp" scope attribute on stage looks odd to me.  Should it 
be an attribute on iter_var's? For CUDA, when the block configuration is (1, 
32), threadIdx.y may "define" the warp scope.
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] comaniac commented on pull request #5409: [BYOC] Don't annotate constants

2020-04-24 Thread GitBox


comaniac commented on pull request #5409:
URL: https://github.com/apache/incubator-tvm/pull/5409#issuecomment-619198333


   > I'm concerned that if we enforce annotation of individual constant nodes, 
MergeCompilerRegions will become a necessary pass to run. Otherwise we'll 
generate partitions just containing a ConstantNode.
   
   It seems to me that if someone runs `AnnotateTarget`, there's no reason for 
her to skip `MergeCompilerRegions`. If she wrote her own annotate pass, then 
those cases should be handled by herself. Originally I was even thinking to put 
`AnnotateTarget` and `MergeCompilerRegions` in the same pass, but we have 
consented to have separate passes so that we can have higher flexibility for 
the merging algorithm.
   
   > It looks like the refactor to AnnotatedRegionSet has broken this 'fix'. I 
think the important property to maintain is that 'every node should belong to a 
region' rather than 'every node should be annotated'.
   
   I agree with you that every node should belong to a region is an important 
property we should maintain in `AnnotateRegionSet`. I'm just concerned about 
treating `ConstantNode` as a special node. In this case, we have to be aware of 
`ConstantNode` everywhere in this infra, or we will easily introduce bugs when 
improving one of them otherwise. I'm hoping that we could deal with the 
constant nodes in `AnnotateTarget` pass and let other passes treat constant 
nodes as other nodes. For example like you have illustrated, this graph 
requires `AnnotateRegionSet` to deal with consant nodes:
   
   ```
   input
 |
   begin
 |
op -- const
 |
   end
   ```
   
   but for this graph, `AnnotateRegionSet` can treat `const` as a normal op:
   
   ```
   input
 |
   begin
 |
op -- begin -- end -- const -- begin
 |
end
   ```



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] zhiics commented on a change in pull request #5438: [POC][IR] Initial stab at std::string->String upgrade

2020-04-24 Thread GitBox


zhiics commented on a change in pull request #5438:
URL: https://github.com/apache/incubator-tvm/pull/5438#discussion_r414804149



##
File path: python/tvm/ir/json_compact.py
##
@@ -84,12 +91,26 @@ def _update_global_key(item, _):
 del item["global_key"]
 return item
 
+def _update_from_std_str(key):
+def _convert(item, nodes):
+str_val = item["attrs"][key]
+jdata = json.loads(tvm.ir.save_json(tvm.runtime.String(str_val)))

Review comment:
   Should we bring the serialization of tvm:String out of save_json? 





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on pull request #5423: [RUNTIME][OBJECT] Introduce static slots for common objects.

2020-04-24 Thread GitBox


tqchen commented on pull request #5423:
URL: https://github.com/apache/incubator-tvm/pull/5423#issuecomment-619192968


   ping @jroesch 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] yongfeng-nv commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


yongfeng-nv commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414674995



##
File path: src/te/operation/compute_op.cc
##
@@ -231,20 +231,18 @@ void ComputeOpNode::PropBoundToInputs(
   // undefined behaviour), so we can intersect the estimated set of 
the argument with the
   // range expected by the tensor. However, intersection may result in 
overly complex
   // expressions, so we perform a more relaxed form of intersection.
-  IntSet arg_intset = EvalSet(call->args[i], dom_map);
+  IntSet arg_intset = analyzer->int_set(call->args[i], 
ConvertDomMap(dom_map));
   const arith::IntervalSetNode* arg_interval = 
arg_intset.as();
   if (arg_interval) {
 PrimExpr shape_i_min_value = make_zero(t->shape[i].dtype());
 PrimExpr shape_i_max_value = t->shape[i] - 1;
 PrimExpr min_value = arg_interval->min_value;
 PrimExpr max_value = arg_interval->max_value;
 // Prefer the shape bounds only when we can prove they are tighter.
-if (arith::is_neg_inf(min_value) ||
-analyzer->CanProve(shape_i_min_value >= min_value)) {
+if (arith::is_pos_inf(max_value) || arith::is_neg_inf(min_value) ||

Review comment:
   No, I only mean to change a bound's ends in pair.  Correcting the code.  
Thank you for pointing it out.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] michalpiszczek commented on pull request #5436: [TFLite Runtime] Re-enable test for remote execution via RPC

2020-04-24 Thread GitBox


michalpiszczek commented on pull request #5436:
URL: https://github.com/apache/incubator-tvm/pull/5436#issuecomment-619160168


   @tmoreau89 @tqchen I've created a separate PR with just the docker changes 
here: https://github.com/apache/incubator-tvm/pull/5437



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen edited a comment on pull request #5423: [RUNTIME][OBJECT] Introduce static slots for common objects.

2020-04-24 Thread GitBox


tqchen edited a comment on pull request #5423:
URL: https://github.com/apache/incubator-tvm/pull/5423#issuecomment-619153621


   The code still works, the overflow children will need to go through the 
overflow path, and call 
https://github.com/apache/incubator-tvm/blob/master/include/tvm/runtime/object.h#L889
 (which is slightly slower than bound checking).
   
   Note that the original code set all the child_slots to 0, so everything 
overflows (and goes to the fallback path for non-final type checking)



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen edited a comment on pull request #5423: [RUNTIME][OBJECT] Introduce static slots for common objects.

2020-04-24 Thread GitBox


tqchen edited a comment on pull request #5423:
URL: https://github.com/apache/incubator-tvm/pull/5423#issuecomment-619153621


   The code still works, the overflow children will need to go through the 
overflow path, and call 
https://github.com/apache/incubator-tvm/blob/master/include/tvm/runtime/object.h#L889
 (which is slightly slower than bound checking).
   
   Note that the original code set all the child_slots to 0, so everything 
overflows.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on pull request #5423: [RUNTIME][OBJECT] Introduce static slots for common objects.

2020-04-24 Thread GitBox


tqchen commented on pull request #5423:
URL: https://github.com/apache/incubator-tvm/pull/5423#issuecomment-619153621


   The code still works, the overflow children will need to go through the 
overflow path, and call 
https://github.com/apache/incubator-tvm/blob/master/include/tvm/runtime/object.h#L889(which
 is slightly slower than bound checking).
   
   Note that the original code set all the child_slots to 0, so everything 
overflows.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on pull request #5438: [IR] Initial stab at std::string->String upgrade

2020-04-24 Thread GitBox


tqchen commented on pull request #5438:
URL: https://github.com/apache/incubator-tvm/pull/5438#issuecomment-619151418


   cc @jroesch @icemelon9 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen opened a new pull request #5438: [IR] Initial stab at std::string->String upgrade

2020-04-24 Thread GitBox


tqchen opened a new pull request #5438:
URL: https://github.com/apache/incubator-tvm/pull/5438


   This PR is an example of String Update with backward compact(see 
json_compact.py)



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] michalpiszczek opened a new pull request #5437: [TFLite Runtime] Add TFLite Runtime dependencies to CI CPU docker build

2020-04-24 Thread GitBox


michalpiszczek opened a new pull request #5437:
URL: https://github.com/apache/incubator-tvm/pull/5437


   This PR contains only the docker build changes needed to re-enable the tests 
in: https://github.com/apache/incubator-tvm/pull/5436. 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tmoreau89 commented on pull request #5436: [TFLite Runtime] Re-enable test for remote execution via RPC

2020-04-24 Thread GitBox


tmoreau89 commented on pull request #5436:
URL: https://github.com/apache/incubator-tvm/pull/5436#issuecomment-619150720


   @michalpiszczek one suggestion is just to leave the CI commented out, and 
scope this PR to just changing the dockerfile



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] jroesch commented on pull request #5423: [RUNTIME][OBJECT] Introduce static slots for common objects.

2020-04-24 Thread GitBox


jroesch commented on pull request #5423:
URL: https://github.com/apache/incubator-tvm/pull/5423#issuecomment-619150640


   My one worry is that this is a bit fragile, what happens if the number of 
children changes but we forget to update the bound? 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] maheshambule commented on pull request #5330: [Frontend][TFLite] support for FILL and SPLIT_V operators

2020-04-24 Thread GitBox


maheshambule commented on pull request #5330:
URL: https://github.com/apache/incubator-tvm/pull/5330#issuecomment-619145838


   @u99127 I have merged the master and removed the duplicate code.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5330: [Frontend][TFLite] support for FILL and SPLIT_V operators

2020-04-24 Thread GitBox


maheshambule commented on a change in pull request #5330:
URL: https://github.com/apache/incubator-tvm/pull/5330#discussion_r414740666



##
File path: python/tvm/relay/frontend/tflite.py
##
@@ -1067,6 +1069,27 @@ def convert_zeros_like(self, op):
 
 return out
 
+def convert_fill(self, op):
+"""Convert TFLite FILL"""
+try:
+from tflite.Operator import Operator
+except ImportError:
+raise ImportError("The tflite package must be installed")
+

Review comment:
   Merged master and removed.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on a change in pull request #5423: [RUNTIME][OBJECT] Introduce static slots for common objects.

2020-04-24 Thread GitBox


tqchen commented on a change in pull request #5423:
URL: https://github.com/apache/incubator-tvm/pull/5423#discussion_r414735177



##
File path: include/tvm/ir/expr.h
##
@@ -161,7 +163,8 @@ class RelayExprNode : public BaseExprNode {
   template
   inline const TTypeNode* type_as() const;
 
-  static constexpr const char* _type_key = "relay.Expr";
+  static constexpr const char* _type_key = "RelayExpr";

Review comment:
   This change is mainly for the Base class(given the c++ name is RelayExpr 
under the root). The relay sub-classes are under the relay namespace.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] jroesch commented on a change in pull request #5423: [RUNTIME][OBJECT] Introduce static slots for common objects.

2020-04-24 Thread GitBox


jroesch commented on a change in pull request #5423:
URL: https://github.com/apache/incubator-tvm/pull/5423#discussion_r414733387



##
File path: include/tvm/ir/expr.h
##
@@ -161,7 +163,8 @@ class RelayExprNode : public BaseExprNode {
   template
   inline const TTypeNode* type_as() const;
 
-  static constexpr const char* _type_key = "relay.Expr";
+  static constexpr const char* _type_key = "RelayExpr";

Review comment:
   I'm not sure I like this change, its better to have the keys name spaced 
to Relay imo.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] mbrookhart commented on a change in pull request #5231: [POC] Pattern Language, Matcher, Rewriter, and Function Paritioner

2020-04-24 Thread GitBox


mbrookhart commented on a change in pull request #5231:
URL: https://github.com/apache/incubator-tvm/pull/5231#discussion_r414721399



##
File path: python/tvm/relay/df_pattern/__init__.py
##
@@ -0,0 +1,488 @@
+# 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 Relay Pattern Language and tooling."""
+from tvm.relay import Expr
+from ...ir.base import Node
+from ...ir import make_node
+from ...runtime import Object
+from ... import _ffi as tvm_ffi
+from ..op import get
+from . import _ffi as ffi
+
+
+def register_df_node(type_key=None):
+"""Register a Relay node type.
+
+Parameters
+--
+type_key : str or cls
+The type key of the node.
+"""
+if not isinstance(type_key, str):
+return tvm_ffi.register_object(
+"relay.df_pattern." + type_key.__name__)(type_key)
+return tvm_ffi.register_object(type_key)

Review comment:
   @jroesch can you comment on this? This was one of your contributions to 
the python API.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on pull request #5432: Corrected TVM autotuning on GPU

2020-04-24 Thread GitBox


tqchen commented on pull request #5432:
URL: https://github.com/apache/incubator-tvm/pull/5432#issuecomment-619126547


   Thanks @JishinMaster !



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[incubator-tvm] branch master updated (9a989e5 -> 9687307)

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

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


from 9a989e5  misc fixes for ROCm (pointer lifetime, runtime::String 
refactor) (#5431)
 add 9687307  Corrected TVM autotuning on GPU (#5432)

No new revisions were added by this update.

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



[GitHub] [incubator-tvm] tqchen commented on pull request #5436: [TFLite Runtime] Re-enable test for remote execution via RPC

2020-04-24 Thread GitBox


tqchen commented on pull request #5436:
URL: https://github.com/apache/incubator-tvm/pull/5436#issuecomment-619125877


   @michalpiszczek please PR the docker changes separately as we need to first 
build the docker binary and update them to the CI env.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] zhiics commented on issue #5427: [Relay] Lack complex tests for parser

2020-04-24 Thread GitBox


zhiics commented on issue #5427:
URL: https://github.com/apache/incubator-tvm/issues/5427#issuecomment-619123723


   I think I met some other issues before with the roundtrip parser. If I 
remember correctly, they don't support functions in prelude 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] zhiics edited a comment on issue #5427: [Relay] Lack complex tests for parser

2020-04-24 Thread GitBox


zhiics edited a comment on issue #5427:
URL: https://github.com/apache/incubator-tvm/issues/5427#issuecomment-619123723


   I think I met some other issues before with the roundtrip parser. If I 
remember correctly, they don't support all functions in prelude 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] michalpiszczek opened a new pull request #5436: [TFLite Runtime] Re-enable test for remote execution via RPC

2020-04-24 Thread GitBox


michalpiszczek opened a new pull request #5436:
URL: https://github.com/apache/incubator-tvm/pull/5436


   Follow up to: https://github.com/apache/incubator-tvm/pull/5425
   
   Changes: 
   - Re-enables a test for remote execution with the TFLite runtime via RPC
   - The test for local execution is left skipped due to flakiness with reading 
the output tensor
   - The tests are made discoverable by pytest
   - Modifies the build steps for the CI CPU image to include dependencies 
needed by the TFLite runtime
   
   cc @tqchen @tmoreau89 @ZihengJiang



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on pull request #5433: fix miopen padding

2020-04-24 Thread GitBox


tqchen commented on pull request #5433:
URL: https://github.com/apache/incubator-tvm/pull/5433#issuecomment-619108217


   thanks @t-vi  please rebase



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen opened a new issue #5435: [FFI] Improve FFI Type Error Message

2020-04-24 Thread GitBox


tqchen opened a new issue #5435:
URL: https://github.com/apache/incubator-tvm/issues/5435


   Currently, the PrintType for Array/Map does not try to nest into the 
content, but the FFI type checking do. This can create confusion when there is 
an error message. We should improve the TypeName printing to be able to do such 
kind of nesting(at least one-level of it) for more to be more informative.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on issue #5427: [Relay] Lack complex tests for parser

2020-04-24 Thread GitBox


tqchen commented on issue #5427:
URL: https://github.com/apache/incubator-tvm/issues/5427#issuecomment-619099214


   It would be great if we can add some of these models(or found the root cause 
get a fragement) and add them to the round trip test



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] tqchen commented on pull request #5431: misc fixes for ROCm

2020-04-24 Thread GitBox


tqchen commented on pull request #5431:
URL: https://github.com/apache/incubator-tvm/pull/5431#issuecomment-619098492


   Thansk @t-vi !



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[incubator-tvm] branch master updated: misc fixes for ROCm (pointer lifetime, runtime::String refactor) (#5431)

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

tqchen 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 9a989e5  misc fixes for ROCm (pointer lifetime, runtime::String 
refactor) (#5431)
9a989e5 is described below

commit 9a989e57e12d38b4fe58ab22e89506f27ad5d76c
Author: Thomas Viehmann 
AuthorDate: Fri Apr 24 17:56:52 2020 +0200

misc fixes for ROCm (pointer lifetime, runtime::String refactor) (#5431)
---
 src/target/llvm/codegen_amdgpu.cc | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/target/llvm/codegen_amdgpu.cc 
b/src/target/llvm/codegen_amdgpu.cc
index 61121f6..8935809 100644
--- a/src/target/llvm/codegen_amdgpu.cc
+++ b/src/target/llvm/codegen_amdgpu.cc
@@ -219,8 +219,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string 
target) {
  << " -mattr=-code-object-v3 "
  << target.substr(4, target.length() - 4);
   std::unique_ptr tm = GetLLVMTargetMachine(config.str());
-  std::unique_ptr cg(new CodeGenAMDGPU());
   std::unique_ptr ctx(new llvm::LLVMContext());
+  // careful: cg will hold a naked pointer reference to ctx, so it should
+  // have a shorter lifetime than the ctx.
+  std::unique_ptr cg(new CodeGenAMDGPU());
 
   cg->Init("TVMAMDGPUModule", tm.get(), ctx.get(), false, false);
 
@@ -233,10 +235,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string 
target) {
 
   const auto *find_rocm_bitcodes =
   tvm::runtime::Registry::Get("tvm_callback_rocm_bitcode_path");
-  Array bitcode_files = (*find_rocm_bitcodes)();
+  Array bitcode_files = (*find_rocm_bitcodes)();
 
-  for (auto  : bitcode_files) {
-std::string path = bitcode.as()->value;
+  for (auto _path : bitcode_files) {
+std::string path = bitcode_path;
 llvm::SMDiagnostic err;
 std::unique_ptr mlib = llvm::parseIRFile(path, err, *ctx);
 if (mlib.get() == nullptr) {



[GitHub] [incubator-tvm] yongfeng-nv commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


yongfeng-nv commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414674995



##
File path: src/te/operation/compute_op.cc
##
@@ -231,20 +231,18 @@ void ComputeOpNode::PropBoundToInputs(
   // undefined behaviour), so we can intersect the estimated set of 
the argument with the
   // range expected by the tensor. However, intersection may result in 
overly complex
   // expressions, so we perform a more relaxed form of intersection.
-  IntSet arg_intset = EvalSet(call->args[i], dom_map);
+  IntSet arg_intset = analyzer->int_set(call->args[i], 
ConvertDomMap(dom_map));
   const arith::IntervalSetNode* arg_interval = 
arg_intset.as();
   if (arg_interval) {
 PrimExpr shape_i_min_value = make_zero(t->shape[i].dtype());
 PrimExpr shape_i_max_value = t->shape[i] - 1;
 PrimExpr min_value = arg_interval->min_value;
 PrimExpr max_value = arg_interval->max_value;
 // Prefer the shape bounds only when we can prove they are tighter.
-if (arith::is_neg_inf(min_value) ||
-analyzer->CanProve(shape_i_min_value >= min_value)) {
+if (arith::is_pos_inf(max_value) || arith::is_neg_inf(min_value) ||

Review comment:
   No, I only mean to change a bound's ends in pair.  Correcting the code.  
Thank you for point it out.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] siju-samuel opened a new pull request #5434: [PYTORCH]Rsub, Embedded, OneHot ops support

2020-04-24 Thread GitBox


siju-samuel opened a new pull request #5434:
URL: https://github.com/apache/incubator-tvm/pull/5434


   - rsub
   - embedded
   - one_hot
   
   #5133
   @masahi  please help me to review this pytorch frontend ops. Thanks.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] mbaret commented on pull request #5409: [BYOC] Don't annotate constants

2020-04-24 Thread GitBox


mbaret commented on pull request #5409:
URL: https://github.com/apache/incubator-tvm/pull/5409#issuecomment-619080360


   It looks like the refactor to AnnotatedRegionSet has broken this 'fix'. I 
think the important property to maintain is that 'every node should belong to a 
region' rather than 'every node should be annotated'. By this, I mean that the 
following structure:
   ```
   input
 |
   begin
 |
op -- const
 |
   end
   ```
   while not explicitly annotating every node, should imply that the const is 
still in a region, just not as an input or output. If we put a begin before the 
const, that implies there's a data flow path into the region through the 
constant, which isn't strictly true. Maybe this would require a slightly 
modified traversal in AnnotatedRegionSet to handle this case.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] t-vi opened a new pull request #5433: fix miopen padding

2020-04-24 Thread GitBox


t-vi opened a new pull request #5433:
URL: https://github.com/apache/incubator-tvm/pull/5433


   The MIOpen convolution accidentally passed the pad left + pad right (and top 
+ bottom) instead of just the value applied to both sides. This patch fixes 
this, and also conditions the use of MIOpen in the op strategy on equality of 
the padding on the corresponding sides.
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] JishinMaster opened a new pull request #5432: Corrected TVM autotuning on GPU

2020-04-24 Thread GitBox


JishinMaster opened a new pull request #5432:
URL: https://github.com/apache/incubator-tvm/pull/5432


   Added missing "tir" in tvm.tir.analysis.verify_gpu_code(f, kwargs) , which 
made the tuning on GPU (tested with RTX2080) fail.
   
   Requesting a review from @eqy or @merrymercy



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] t-vi opened a new pull request #5431: misc fixes for ROCm

2020-04-24 Thread GitBox


t-vi opened a new pull request #5431:
URL: https://github.com/apache/incubator-tvm/pull/5431


   This fixes two things in the AMDGPU LLVM codegen.
   - pointer lifetime of the LLVM context passed to codegen as a pointer
   - the runtime::String refactor caused typing issues for one of the nodes
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] dhruvaray commented on pull request #5430: [RELAY,TOPI][TFLITE] Sparse to dense operator - WIP

2020-04-24 Thread GitBox


dhruvaray commented on pull request #5430:
URL: https://github.com/apache/incubator-tvm/pull/5430#issuecomment-619016587


   Closing this as I messed up on the rebase. Please ignore



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] zhiics commented on a change in pull request #5345: [RELAY] Move frontend utils

2020-04-24 Thread GitBox


zhiics commented on a change in pull request #5345:
URL: https://github.com/apache/incubator-tvm/pull/5345#discussion_r414572622



##
File path: python/tvm/relay/frontend/tflite.py
##
@@ -2219,6 +2218,20 @@ def get_expr(self, input_tensor_idx):
 def has_expr(self, input_tensor_idx):
 return self.exp_tab.has_expr(get_tensor_name(self.subgraph, 
input_tensor_idx))
 
+
+def get_scalar_from_constant(expr):
+""" Returns scalar value from Relay constant scalar. """
+assert isinstance(expr, _expr.Constant) and not expr.data.shape, \
+"Expr is not a constant scalar."
+value = expr.data.asnumpy()
+if value.dtype == np.dtype(np.int32):
+return int(value)
+if value.dtype == np.dtype(np.float32):
+return float(value)
+assert False, "Constant expr must be float32/int32"
+return None  # To suppress pylint

Review comment:
   I am okay with this type of minimal code duplication. 
   
   Can we just do this for both cases?
   
   ```python
   assert value.dtype == np.dtype(np.int32) or value.dtype == 
np.dtype(np.float32), "value must be float32/int32"
   return np. asscalar(value)
   ```





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] zhiics commented on a change in pull request #5345: [RELAY] Move frontend utils

2020-04-24 Thread GitBox


zhiics commented on a change in pull request #5345:
URL: https://github.com/apache/incubator-tvm/pull/5345#discussion_r414572622



##
File path: python/tvm/relay/frontend/tflite.py
##
@@ -2219,6 +2218,20 @@ def get_expr(self, input_tensor_idx):
 def has_expr(self, input_tensor_idx):
 return self.exp_tab.has_expr(get_tensor_name(self.subgraph, 
input_tensor_idx))
 
+
+def get_scalar_from_constant(expr):
+""" Returns scalar value from Relay constant scalar. """
+assert isinstance(expr, _expr.Constant) and not expr.data.shape, \
+"Expr is not a constant scalar."
+value = expr.data.asnumpy()
+if value.dtype == np.dtype(np.int32):
+return int(value)
+if value.dtype == np.dtype(np.float32):
+return float(value)
+assert False, "Constant expr must be float32/int32"
+return None  # To suppress pylint

Review comment:
   I am okay with this type of minimal code duplication. 
   
   Can we just do for both case?
   
   ```python
   assert value.dtype == np.dtype(np.int32) or value.dtype == 
np.dtype(np.float32), "value must be float32/int32"
   return np. asscalar(value)
   ```





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] hzfan commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


hzfan commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414552082



##
File path: src/te/operation/compute_op.cc
##
@@ -231,20 +231,18 @@ void ComputeOpNode::PropBoundToInputs(
   // undefined behaviour), so we can intersect the estimated set of 
the argument with the
   // range expected by the tensor. However, intersection may result in 
overly complex
   // expressions, so we perform a more relaxed form of intersection.
-  IntSet arg_intset = EvalSet(call->args[i], dom_map);
+  IntSet arg_intset = analyzer->int_set(call->args[i], 
ConvertDomMap(dom_map));
   const arith::IntervalSetNode* arg_interval = 
arg_intset.as();
   if (arg_interval) {
 PrimExpr shape_i_min_value = make_zero(t->shape[i].dtype());
 PrimExpr shape_i_max_value = t->shape[i] - 1;
 PrimExpr min_value = arg_interval->min_value;
 PrimExpr max_value = arg_interval->max_value;
 // Prefer the shape bounds only when we can prove they are tighter.
-if (arith::is_neg_inf(min_value) ||
-analyzer->CanProve(shape_i_min_value >= min_value)) {
+if (arith::is_pos_inf(max_value) || arith::is_neg_inf(min_value) ||

Review comment:
   The condition seems quite loose. `max_value` gets updated when 
`arith::is_neg_inf(min_value)` holds. Is this intended?
   





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] hzfan commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


hzfan commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414548737



##
File path: src/te/operation/compute_op.cc
##
@@ -231,20 +231,18 @@ void ComputeOpNode::PropBoundToInputs(
   // undefined behaviour), so we can intersect the estimated set of 
the argument with the
   // range expected by the tensor. However, intersection may result in 
overly complex
   // expressions, so we perform a more relaxed form of intersection.
-  IntSet arg_intset = EvalSet(call->args[i], dom_map);
+  IntSet arg_intset = analyzer->int_set(call->args[i], 
ConvertDomMap(dom_map));
   const arith::IntervalSetNode* arg_interval = 
arg_intset.as();
   if (arg_interval) {
 PrimExpr shape_i_min_value = make_zero(t->shape[i].dtype());
 PrimExpr shape_i_max_value = t->shape[i] - 1;
 PrimExpr min_value = arg_interval->min_value;
 PrimExpr max_value = arg_interval->max_value;
 // Prefer the shape bounds only when we can prove they are tighter.
-if (arith::is_neg_inf(min_value) ||
-analyzer->CanProve(shape_i_min_value >= min_value)) {
+if (arith::is_pos_inf(max_value) || arith::is_neg_inf(min_value) ||

Review comment:
   The condition seems quite loose. `max_value` gets updated when 
`arith::is_neg_inf(min_value)` holds. Is this intended?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] hzfan commented on a change in pull request #5367: Improve IntervalSet's floormod

2020-04-24 Thread GitBox


hzfan commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r414548737



##
File path: src/te/operation/compute_op.cc
##
@@ -231,20 +231,18 @@ void ComputeOpNode::PropBoundToInputs(
   // undefined behaviour), so we can intersect the estimated set of 
the argument with the
   // range expected by the tensor. However, intersection may result in 
overly complex
   // expressions, so we perform a more relaxed form of intersection.
-  IntSet arg_intset = EvalSet(call->args[i], dom_map);
+  IntSet arg_intset = analyzer->int_set(call->args[i], 
ConvertDomMap(dom_map));
   const arith::IntervalSetNode* arg_interval = 
arg_intset.as();
   if (arg_interval) {
 PrimExpr shape_i_min_value = make_zero(t->shape[i].dtype());
 PrimExpr shape_i_max_value = t->shape[i] - 1;
 PrimExpr min_value = arg_interval->min_value;
 PrimExpr max_value = arg_interval->max_value;
 // Prefer the shape bounds only when we can prove they are tighter.
-if (arith::is_neg_inf(min_value) ||
-analyzer->CanProve(shape_i_min_value >= min_value)) {
+if (arith::is_pos_inf(max_value) || arith::is_neg_inf(min_value) ||

Review comment:
   The condition seems quite loose. `max_value` gets updated when 
`arith::is_neg_inf(min_value)` holds. Is this intended?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] dhruvaray opened a new pull request #5430: [RELAY,TOPI][TFLITE] Sparse to dense operator

2020-04-24 Thread GitBox


dhruvaray opened a new pull request #5430:
URL: https://github.com/apache/incubator-tvm/pull/5430


   Added support for sparse_to_dense operator
   
   @u99127, @FrozenGene, @siju-samuel @jwfromm @kazum - Kindly review



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[incubator-tvm] branch master updated: [FRONTEND][TFLITE]Gather, StridedSlice op support added (#4788)

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

zhaowu 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 8efd546  [FRONTEND][TFLITE]Gather, StridedSlice op support added 
(#4788)
8efd546 is described below

commit 8efd54606537411e6a3d62490b52857a411572e8
Author: Samuel 
AuthorDate: Fri Apr 24 16:23:38 2020 +0530

[FRONTEND][TFLITE]Gather, StridedSlice op support added (#4788)

* [FRONTEND][TFLITE]Gather, StridedSlice op added

* Review comments fixed
---
 python/tvm/relay/frontend/tflite.py  | 214 +++
 tests/python/frontend/tflite/test_forward.py |  75 ++
 2 files changed, 289 insertions(+)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index 8c335c9..275d0ce 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -17,6 +17,7 @@
 # pylint: disable=invalid-name, unused-argument, too-many-lines, 
import-outside-toplevel
 """Tensorflow lite frontend."""
 import math
+import itertools
 import numpy as np
 import tvm
 from tvm.ir import IRModule
@@ -82,6 +83,7 @@ class OperatorConverter(object):
 'FLOOR_MOD': self.convert_floor_mod,
 'FLOOR': self.convert_floor,
 'FULLY_CONNECTED': self.convert_fully_connected,
+'GATHER': self.convert_gather,
 'GREATER_EQUAL': self.convert_greater_equal,
 'GREATER': self.convert_greater,
 'HARD_SWISH': self.convert_hard_swish,
@@ -125,6 +127,7 @@ class OperatorConverter(object):
 'SQUARE': self.convert_square,
 'SQUARED_DIFFERENCE': self.convert_squared_difference,
 'SQUEEZE': self.convert_squeeze,
+'STRIDED_SLICE': self.convert_strided_slice,
 'SUB': self.convert_sub,
 'SUM': self._convert_reduce_sum,
 'TAN': self.convert_tan,
@@ -983,6 +986,217 @@ class OperatorConverter(object):
 """Convert tflite LOGICAL_OR"""
 return self._convert_logical_binary(_op.logical_or, op)
 
+def convert_gather(self, op):
+"""Method to Convert TFLite GATHER operator"""
+try:
+from tflite.BuiltinOptions import BuiltinOptions
+from tflite.GatherOptions import GatherOptions
+from tflite.TensorType import TensorType
+except ImportError:
+raise ImportError("The tflite package must be installed")
+
+input_tensors = self.get_input_tensors(op)
+assert len(input_tensors) == 2, "input tensors length should be 2"
+
+data = self.get_expr(input_tensors[0].tensor_idx)
+
+indices = input_tensors[1]
+indices_type = indices.tensor.Type()
+assert indices_type in (TensorType.INT32, TensorType.INT64)
+indices_type_str = self.get_tensor_type_str(indices_type)
+indices = self.exp_tab.new_const(self.get_tensor_value(indices),
+ dtype=indices_type_str)
+
+assert op.BuiltinOptionsType() == BuiltinOptions.GatherOptions
+op_options = op.BuiltinOptions()
+gather_options = GatherOptions()
+gather_options.Init(op_options.Bytes, op_options.Pos)
+axis = gather_options.Axis()
+
+# Check the indices are with in bounds.
+data_shape = list(input_tensors[0].tensor.ShapeAsNumpy())
+data_dim = len(data_shape)
+
+axis_n = axis
+if axis_n < 0:
+axis_n += axis_n + data_dim
+assert axis_n >= 0, "Axis out of bounds"
+assert axis_n < data_dim, "Axis out of bounds"
+
+indices_val = self.get_tensor_value(input_tensors[1])
+indices_shape = list(indices_val.shape)
+indices_len = len(indices_shape)
+
+out_shape = []
+for i in range(data_dim):
+if axis_n == i:
+for j in range(indices_len):
+out_shape.append(indices_shape[j])
+else:
+out_shape.append(data_shape[i])
+
+loopover = [range(s) for s in out_shape]
+for idx in list(itertools.product(*loopover)):
+indices_position = [idx[j] for j in range(axis_n, 
axis_n+indices_len)]
+
+real_indices = [idx[j] for j in range(axis_n)]
+real_indices.append(indices_val[tuple(indices_position)])
+real_indices.extend([idx[j] for j in range(axis_n + indices_len, 
len(idx))])
+for r, d in zip(real_indices, data_shape):
+if r >= d:
+raise ValueError("TFLite out of bound indices are not 
supported.")
+
+# Use mode 'fast' since indices are already checked within bounds.
+out = _op.take(data, indices, axis=axis, mode="fast")
+return out
+
+def convert_strided_slice(self, op):
+"""Method to Convert TFLite 

[GitHub] [incubator-tvm] FrozenGene commented on pull request #4788: [FRONTEND][TFLITE]Gather, StridedSlice op support added

2020-04-24 Thread GitBox


FrozenGene commented on pull request #4788:
URL: https://github.com/apache/incubator-tvm/pull/4788#issuecomment-618942742


   Thanks @siju-samuel @wyc-ruiker @u99127 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] masahi commented on pull request #5383: [PYTORCH]where, addcdiv, addcmul op support

2020-04-24 Thread GitBox


masahi commented on pull request #5383:
URL: https://github.com/apache/incubator-tvm/pull/5383#issuecomment-618941150


   Thanks @siju-samuel 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[incubator-tvm] branch master updated: [PYTORCH]where, addcdiv, addcmul op support (#5383)

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

masahi 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 ba38222  [PYTORCH]where, addcdiv, addcmul op support (#5383)
ba38222 is described below

commit ba38222990feb7c2dbb18bd2e23ae7551d440fd3
Author: Samuel 
AuthorDate: Fri Apr 24 16:19:26 2020 +0530

[PYTORCH]where, addcdiv, addcmul op support (#5383)

* [PYTORCH]Where, addcdiv, addcmul op support

* Review comments fixed
---
 python/tvm/relay/frontend/pytorch.py  | 72 +++
 tests/python/frontend/pytorch/test_forward.py | 69 +
 2 files changed, 110 insertions(+), 31 deletions(-)

diff --git a/python/tvm/relay/frontend/pytorch.py 
b/python/tvm/relay/frontend/pytorch.py
index 0ade8af..a8eb9c4 100644
--- a/python/tvm/relay/frontend/pytorch.py
+++ b/python/tvm/relay/frontend/pytorch.py
@@ -279,15 +279,7 @@ def _select():
 def _take():
 def _impl(inputs, input_types):
 data = inputs[0]
-import torch
-
-if isinstance(inputs[1], _expr.Var):
-indices = _op.cast(inputs[1], "int32")
-elif isinstance(inputs[1], torch.Tensor):
-indices = _wrap_const(inputs[1].numpy())
-else:
-msg = "Data type %s could not be parsed in take operator." % 
(type(inputs[1]))
-raise AssertionError(msg)
+indices = _op.cast(inputs[1], "int32")
 
 return _op.transform.take(data, indices=indices)
 return _impl
@@ -337,6 +329,40 @@ def _repeat_interleave():
 return _op.transform.repeat(data, repeats=repeats, axis=axis)
 return _impl
 
+
+def _addcdiv():
+def _impl(inputs, input_types):
+data = inputs[0]
+c = _expr.const(inputs[3])
+t1 = inputs[1]
+t2 = inputs[2]
+
+return data + (c * (t1 / t2))
+return _impl
+
+
+def _addcmul():
+def _impl(inputs, input_types):
+data = inputs[0]
+c = _expr.const(inputs[3])
+t1 = inputs[1]
+t2 = inputs[2]
+
+return data + (c * (t1 * t2))
+return _impl
+
+
+def _where():
+def _impl(inputs, input_types):
+cond = inputs[0]
+x = inputs[1]
+y = inputs[2]
+
+return _op.where(cond, x, y)
+
+return _impl
+
+
 def _ones():
 def _impl(inputs, input_types):
 data = inputs[0]
@@ -1382,16 +1408,7 @@ def _bitwise_not():
 def _bitwise_xor():
 def _impl(inputs, input_types):
 lhs = inputs[0]
-
-import torch
-if isinstance(inputs[1], _expr.Var):
-rhs = inputs[1]
-elif isinstance(inputs[1], torch.Tensor):
-rhs = _wrap_const(inputs[1].numpy())
-else:
-msg = "Data type %s could not be parsed in bitwise_xor operator." 
% (type(inputs[1]))
-raise AssertionError(msg)
-
+rhs = inputs[1]
 lhs = _op.cast(lhs, "bool") if input_types[0] == "bool" else 
_op.cast(lhs, "int")
 rhs = _op.cast(rhs, "bool") if input_types[1] == "bool" else 
_op.cast(rhs, "int")
 
@@ -1410,17 +1427,7 @@ def _logical_not():
 def _logical_xor():
 def _impl(inputs, input_types):
 lhs = _op.cast(inputs[0], "bool")
-
-import torch
-if isinstance(inputs[1], _expr.Var):
-rhs = inputs[1]
-elif isinstance(inputs[1], torch.Tensor):
-rhs = _wrap_const(inputs[1].numpy())
-else:
-msg = "Data type %s could not be parsed in logical_xor operator." 
% (type(inputs[1]))
-raise AssertionError(msg)
-
-rhs = _op.cast(rhs, "bool")
+rhs = _op.cast(inputs[1], "bool")
 
 return _op.logical_xor(lhs, rhs)
 return _impl
@@ -1551,6 +1558,8 @@ def _get_convert_map(prelude):
 "aten::arange"  : _arange(),
 "aten::div" : _elemwise("divide"),
 "aten::div_": _elemwise("divide"),
+"aten::addcdiv" : _addcdiv(),
+"aten::addcmul" : _addcmul(),
 "aten::ones": _ones(),
 "aten::ones_like"   : _ones_like(),
 "aten::zeros"   : _zeros(),
@@ -1570,6 +1579,7 @@ def _get_convert_map(prelude):
 "aten::split_with_sizes": _split_with_sizes(),
 "aten::select"  : _select(),
 "aten::take": _take(),
+"aten::where"   : _where(),
 "aten::topk": _topk(),
 "aten::relu": _relu(),
 "aten::relu_"   : _relu(),
@@ -1832,7 +1842,7 @@ def _get_constant(node):
 tensor = node.t(attr_name)
 if 

[GitHub] [incubator-tvm] siju-samuel commented on pull request #5383: [PYTORCH]where, addcdiv, addcmul op support

2020-04-24 Thread GitBox


siju-samuel commented on pull request #5383:
URL: https://github.com/apache/incubator-tvm/pull/5383#issuecomment-618937603


   @masahi  Could you please review and merge. Thanks.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] lixiaoquan opened a new pull request #5429: [RELAY][TF] Support symbolic newshape for Reshape

2020-04-24 Thread GitBox


lixiaoquan opened a new pull request #5429:
URL: https://github.com/apache/incubator-tvm/pull/5429


   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] libaihong opened a new pull request #5428: [CODEGEN][CUDA] Fix a bug when vectorized load was involved for…

2020-04-24 Thread GitBox


libaihong opened a new pull request #5428:
URL: https://github.com/apache/incubator-tvm/pull/5428


   When I test with vectorized load for char2, there is a cuda 
compilation error:
   
   _RuntimeError: Compilation error:
   /tmp/tmpa87wlle2/my_kernel.cu(3093): error: no operator "=" matches these 
operands
   operand types are: char2 = int
   /tmp/tmpa87wlle2/my_kernel.cu(3094): error: no operator "&" matches these 
operands
   operand types are: char2 & int
   /tmp/tmpa87wlle2/my_kernel.cu(3096): error: no operator ">>" matches these 
operands
   operand types are: char2 >> int
   /tmp/tmpa87wlle2/my_kernel.cu(3097): error: no operator ">>" matches these 
operands
   operand types are: char2 >> int_
   
   
   The error occurs at the pieces of cuda codes generated by TVM as below:
   `char2 _66;`
   `_66=((signed char)(_67.x) << 0); `
   `_66=_66 & ~(0x00ff << 8) |((signed char)(_67.y) << 8);`
   `((signed char*)T_cast)[_1.x] = ((char)(_66 >> 0));`
   `((signed char*)T_cast)[_1.y] = ((char)(_66 >> 8));`
   
   The “_66” is a char2 vector, but it is used as a scalar, which is the cause 
of this issue. However, the root cause is that the vectorized load/store for 
char2 is not supported. After fix this problem, the generated cuda codes are 
listed as following:
   `char2 _66;`
   `_66.x=((signed char)(_67.x));`
   `_66.y=((signed char)(_67.y)); `
   `((signed char*)T_cast)[_1.x] = _66.x;`
   `((signed char*)T_cast)[_1.y] = _66.y;`
   
   
   @vinx13 , could you please help review? Thanks!



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] mbaret commented on pull request #5409: [BYOC] Don't annotate constants

2020-04-24 Thread GitBox


mbaret commented on pull request #5409:
URL: https://github.com/apache/incubator-tvm/pull/5409#issuecomment-618895831


   I'm concerned that if we enforce annotation of individual constant nodes, 
MergeCompilerRegions will become a necessary pass to run. Otherwise we'll 
generate partitions just containing a ConstantNode.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] mbaret commented on pull request #5345: [RELAY] Move frontend utils

2020-04-24 Thread GitBox


mbaret commented on pull request #5345:
URL: https://github.com/apache/incubator-tvm/pull/5345#issuecomment-618893040


   I couldn't find an appropriate folder to move this to, so I've instead 
inlined this function as it's only used in two places.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] MarisaKirisame commented on issue #5427: [Relay] Lack complex tests for parser

2020-04-24 Thread GitBox


MarisaKirisame commented on issue #5427:
URL: https://github.com/apache/incubator-tvm/issues/5427#issuecomment-618890273


   Hi, in the parser test file, you can see that we use roundtrip to do test - 
in particular, we test that parsing/pretty printing or prettyprinting/parsing 
give the same result. It is very easy to add new model there. I am trying to 
submit to NeurIps rn, so I cant work on it. Maybe other ppl (or perhap you) can 
take a look?



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [incubator-tvm] antinucleon opened a new issue #5427: [Relay] Lack complex tests for fromtext

2020-04-24 Thread GitBox


antinucleon opened a new issue #5427:
URL: https://github.com/apache/incubator-tvm/issues/5427


   Complex tests such as full models should be added to relay parser tests. As 
today, I tested MobileNet / Bert and a few more models, none is able to be 
successfully loaded. 
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org