[incubator-tvm] branch master updated (b7364b4 -> 902e21b)

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

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


from b7364b4  reverse changes in pr #4849 (#4853)
 add 902e21b  [TFLite] Using real image for QNN testing. (#4816)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 21 +++--
 tests/python/frontend/tflite/test_forward.py | 70 +---
 2 files changed, 72 insertions(+), 19 deletions(-)



[incubator-tvm] branch master updated (51af454 -> 1c8e5b9)

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

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


from 51af454  [Relay][FastMath] Relay pass to use fast exp/tanh (#4873)
 add 1c8e5b9  [TFLITE]FLOOR_MOD & FLOOR_DIV support (#4971)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 16 
 tests/python/frontend/tflite/test_forward.py | 19 +++
 2 files changed, 35 insertions(+)



[incubator-tvm] branch master updated: [FRONTEND][KERAS]GaussianDropout/Noise parsing support (#4928)

2020-02-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 13cf1da  [FRONTEND][KERAS]GaussianDropout/Noise parsing support (#4928)
13cf1da is described below

commit 13cf1da3946c7be828b189276e3dd5a14b3e720d
Author: Samuel 
AuthorDate: Tue Feb 25 09:09:10 2020 +0530

[FRONTEND][KERAS]GaussianDropout/Noise parsing support (#4928)

GaussianDropout & GaussianNoise are active only during training time. This 
can be skipped during inference.
---
 python/tvm/relay/frontend/keras.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/python/tvm/relay/frontend/keras.py 
b/python/tvm/relay/frontend/keras.py
index caf4176..adb28c4 100644
--- a/python/tvm/relay/frontend/keras.py
+++ b/python/tvm/relay/frontend/keras.py
@@ -762,6 +762,8 @@ _convert_map = {
 'Dropout'  : _default_skip,
 'SpatialDropout2D' : _default_skip,
 'SpatialDropout1D' : _default_skip,
+'GaussianDropout'  : _default_skip,
+'GaussianNoise': _default_skip,
 }
 
 



[incubator-tvm] branch master updated (a2429c1 -> 588523d)

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

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


from a2429c1  [Relay][External Codegen] Support data types for 
CSourceModuleCodegen args and output (#4934)
 add 588523d  [LLVM] Fix build breaks from StringRef changes (#4923)

No new revisions were added by this update.

Summary of changes:
 src/target/llvm/codegen_amdgpu.cc | 2 +-
 src/target/llvm/codegen_nvptx.cc  | 2 +-
 src/target/llvm/llvm_module.cc| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)



[incubator-tvm] branch master updated (5ea4f0d -> 19d0d15)

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

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


from 5ea4f0d  [Relay] Conv2D padding representation (#4787)
 add 19d0d15  [CONTRIB][CC] Enhance cc.cross_compiler (#4817)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/cc.py  | 69 +++
 tests/python/unittest/test_module_load.py |  7 ++--
 2 files changed, 46 insertions(+), 30 deletions(-)



[incubator-tvm] branch master updated (6914963 -> 24126b4)

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

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


from 6914963  [Relay][Frontend][TFlite] Add add parser support for 
relational ops (#4695)
 add 24126b4  Fix parsing of different exception string formats (#4785)

No new revisions were added by this update.

Summary of changes:
 python/tvm/_ffi/base.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)



[incubator-tvm] branch master updated (4c961dd -> 5a13575)

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

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


from 4c961dd  [Doc] ConvertLayout - Call RemoveUnunsedFunctions.
 add 5a13575  [Relay][Frontend][TFlite] Add support for quantized LOGISTIC 
(#4696)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 26 ++
 tests/python/frontend/tflite/test_forward.py | 18 +-
 2 files changed, 39 insertions(+), 5 deletions(-)



[incubator-tvm] branch master updated (5a13575 -> 30b7d83)

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

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


from 5a13575  [Relay][Frontend][TFlite] Add support for quantized LOGISTIC 
(#4696)
 add 30b7d83  [Frontend][TFLite] Add MIRROR_PAD operator (#4822)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 43 ++--
 tests/python/frontend/tflite/test_forward.py |  8 --
 2 files changed, 47 insertions(+), 4 deletions(-)



[incubator-tvm] branch master updated (9963cf3 -> 00097b1)

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

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


from 9963cf3  [QNN] Doc fix on convolution and dequantize (#4799)
 add 00097b1  [QNN] Conv2D with dilation support. (#4796)

No new revisions were added by this update.

Summary of changes:
 src/relay/qnn/op/convolution.cc  | 18 +++---
 tests/python/relay/test_op_qnn_conv2d.py | 25 -
 2 files changed, 35 insertions(+), 8 deletions(-)



[incubator-tvm] branch master updated: [Relay][Frontend][TFlite] Add add parser support for relational ops (#4695)

2020-01-30 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 6914963  [Relay][Frontend][TFlite] Add add parser support for 
relational ops (#4695)
6914963 is described below

commit 6914963545a10c3c031c154f89a51a587e154743
Author: Ina Dobreva <55383260+ina...@users.noreply.github.com>
AuthorDate: Thu Jan 30 14:10:52 2020 +

[Relay][Frontend][TFlite] Add add parser support for relational ops (#4695)

Add support for: greater_equal, less, less_equal, equal, not_equal
Add tests for the elemwise relational ops
---
 python/tvm/relay/frontend/tflite.py  | 57 +---
 tests/python/frontend/tflite/test_forward.py | 39 +++
 2 files changed, 90 insertions(+), 6 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index 5902b92..791c056 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -89,6 +89,11 @@ class OperatorConverter(object):
 'MAXIMUM': self.convert_maximum,
 'MINIMUM': self.convert_minimum,
 'GREATER': self.convert_greater,
+'GREATER_EQUAL': self.convert_greater_equal,
+'LESS': self.convert_less,
+'LESS_EQUAL': self.convert_less_equal,
+'EQUAL': self.convert_equal,
+'NOT_EQUAL': self.convert_not_equal,
 'ZEROS_LIKE': self.convert_zeros_like,
 'REDUCE_MIN': self._convert_reduce_min,
 'REDUCE_MAX': self._convert_reduce_max,
@@ -690,7 +695,7 @@ class OperatorConverter(object):
 # Check if the input tensor is quantized, call QNN op
 if self.is_quantized(op):
 raise tvm.error.OpNotImplemented(
-'TFlite quantized sub operator is not supported yet.')
+'TFlite quantized SUB operator is not supported yet.')
 return self._convert_elemwise(_op.subtract, op)
 
 def convert_mul(self, op):
@@ -705,38 +710,43 @@ class OperatorConverter(object):
 # Check if the input tensor is quantized, call QNN op
 if self.is_quantized(op):
 raise tvm.error.OpNotImplemented(
-'TFlite quantized div operator is not supported yet.')
+'TFlite quantized DIV operator is not supported yet.')
 return self._convert_elemwise(_op.divide, op)
 
 def convert_pow(self, op):
+"""Convert TFLite POW"""
 # Check if the input tensor is quantized, call QNN op
 if self.is_quantized(op):
 raise tvm.error.OpNotImplemented(
-'TFlite quantized pow operator is not supported yet.')
+'TFlite quantized POW operator is not supported yet.')
 return self._convert_elemwise(_op.power, op)
 
 def convert_maximum(self, op):
+"""Convert TFLite MAXIMUM"""
 # Check if the input tensor is quantized, call QNN op
 if self.is_quantized(op):
 raise tvm.error.OpNotImplemented(
-'TFlite quantized maximum operator is not supported yet.')
+'TFlite quantized MAXIMUM operator is not supported yet.')
 return self._convert_elemwise(_op.maximum, op)
 
 def convert_minimum(self, op):
+"""Convert TFLite MINIMUM"""
 # Check if the input tensor is quantized, call QNN op
 if self.is_quantized(op):
 raise tvm.error.OpNotImplemented(
-'TFlite quantized minimum operator is not supported yet.')
+'TFlite quantized MINIMUM operator is not supported yet.')
 return self._convert_elemwise(_op.minimum, op)
 
 def convert_greater(self, op):
+"""Convert TFLite GREATER"""
 # Check if the input tensor is quantized, call QNN op
 if self.is_quantized(op):
 raise tvm.error.OpNotImplemented(
-'TFlite quantized greater operator is not supported yet.')
+'TFlite quantized GREATER operator is not supported yet.')
 return self._convert_elemwise(_op.greater, op)
 
 def convert_squared_difference(self, op):
+"""Convert TFLite SQUARED DIFFERENCE"""
 # Check if the input tensor is quantized, call QNN op
 if self.is_quantized(op):
 raise tvm.error.OpNotImplemented(
@@ -747,6 +757,41 @@ class OperatorConverter(object):
 out = _op.power(difference, relay.const(2, exp_type))
 return out
 
+def convert_greater_equal(self, op):
+"""Convert TFLite GREATER_EQUAL"""
+if self.is_quantized(op):
+raise tvm.error.OpNotImpl

[incubator-tvm] branch master updated: Fix tests for tflite unary elemwise operations (#4913)

2020-02-20 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 0e189f0  Fix tests for tflite unary elemwise operations (#4913)
0e189f0 is described below

commit 0e189f01146c004f8a55840bb6c36d4449a25c34
Author: Ina Dobreva <55383260+ina...@users.noreply.github.com>
AuthorDate: Fri Feb 21 04:10:45 2020 +

Fix tests for tflite unary elemwise operations (#4913)

* add TFLite version check for 'ceil' and 'cos'
* fix name check of test_op for positive inputs
* add error message for operator not found in the installed fbs schema
---
 python/tvm/relay/frontend/tflite.py  |  6 +-
 tests/python/frontend/tflite/test_forward.py | 15 ---
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index e92e4ce..dd35871 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -166,7 +166,11 @@ class OperatorConverter(object):
 
 op_code_list_idx = op.OpcodeIndex()
 op_code_id = self.model.OperatorCodes(op_code_list_idx).BuiltinCode()
-op_code_str = self.builtin_op_code[op_code_id]
+try:
+op_code_str = self.builtin_op_code[op_code_id]
+except KeyError:
+raise NotImplementedError('TFLite operator with code ' + 
str(op_code_id) + \
+  ' is not supported by this version of 
the fbs schema.')
 if op_code_id == BuiltinOperator.CUSTOM:
 # Custom operator
 custom_op_code_str = 
self.model.OperatorCodes(op_code_list_idx).CustomCode()
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index e88226c..427d4bf 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -669,7 +669,7 @@ def _test_unary_elemwise(math_op, data):
 with tf.Graph().as_default():
 in_data = array_ops.placeholder(shape=data.shape, dtype=data.dtype, 
name='in')
 out = math_op(in_data)
-compare_tflite_with_tvm(data, ['in:0'], in_data, [out])
+compare_tflite_with_tvm(data, ['in:0'], [in_data], [out])
 
 ###
 # Abs
@@ -745,23 +745,24 @@ def _test_neg(data):
 
 def _test_forward_unary_elemwise(test_op):
 # functions that need positive input
-if test_op in {'_test_log', '_test_sqrt', '_test_rsqrt'}:
-test_op(np.arange(6.0, dtype=np.float32).reshape((2, 1, 3)))
-test_op(np.arange(6.0, dtype=np.int32).reshape((2, 1, 3)))
+if test_op.__name__ in {'_test_log', '_test_sqrt', '_test_rsqrt'}:
+test_op(np.arange(1.0, 7.0, dtype=np.float32).reshape((2, 1, 3)))
 else:
-np.array(np.random.uniform(-5, 5, (3, 1)), dtype=np.int32)
+test_op(np.random.uniform(-10, 10, (3, 2)).astype(np.float32))
 
 def test_all_unary_elemwise():
 _test_forward_unary_elemwise(_test_abs)
-_test_forward_unary_elemwise(_test_ceil)
 _test_forward_unary_elemwise(_test_floor)
 _test_forward_unary_elemwise(_test_exp)
 _test_forward_unary_elemwise(_test_log)
 _test_forward_unary_elemwise(_test_sin)
-_test_forward_unary_elemwise(_test_cos)
 _test_forward_unary_elemwise(_test_sqrt)
 _test_forward_unary_elemwise(_test_rsqrt)
 _test_forward_unary_elemwise(_test_neg)
+# ceil and cos come with TFLite 1.14.0.post1 fbs schema
+if package_version.parse(tf.VERSION) >= package_version.parse('1.14.0'):
+_test_forward_unary_elemwise(_test_ceil)
+_test_forward_unary_elemwise(_test_cos)
 
 ###
 # Element-wise



[incubator-tvm] branch master updated (51a265a -> 70c6382)

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

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


from 51a265a  [REFACTOR][PY][API-CHANGE] Establish tvm.target
 add 70c6382  [FRONTEND][TFLITE] Add support for 
TFLite_Detection_PostProcess (#4543)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 197 +++
 tests/python/frontend/tflite/test_forward.py |  48 +++
 2 files changed, 245 insertions(+)



[incubator-tvm] branch master updated (e301637 -> b1d93ec)

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

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


from e301637  [COMMUNITY] @FrozenGene -> committer (#4719)
 add b1d93ec  [Relay][Frontend][TFLite] Add parser support for squared 
difference (#4652)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 12 
 tests/python/frontend/tflite/test_forward.py |  9 +
 2 files changed, 21 insertions(+)



[incubator-tvm] branch master updated: [TFLITE]Activation functions support (#4978)

2020-03-10 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 ab83993  [TFLITE]Activation functions support (#4978)
ab83993 is described below

commit ab839933093b37e4ee455e49a31e6a57b6156c5d
Author: Samuel 
AuthorDate: Wed Mar 11 08:38:48 2020 +0530

[TFLITE]Activation functions support (#4978)

* [TFLITE]elu, leaky_relu, lrn, log_softmax activation functions

* removed ops present in pr 4805

* review_comments updated
---
 python/tvm/relay/frontend/tflite.py  | 162 ++-
 tests/python/frontend/tflite/test_forward.py |  54 +++--
 2 files changed, 154 insertions(+), 62 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index c2ec4d4..c820713 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -62,70 +62,72 @@ class OperatorConverter(object):
 # Add more operators
 self.convert_map = {
 'ABS': self.convert_abs,
+'ADD': self.convert_add,
+'AVERAGE_POOL_2D': self.convert_average_pool2d,
+'BATCH_TO_SPACE_ND': self.convert_batch_to_space_nd,
+'CAST': self.convert_cast,
+'CEIL': self.convert_ceil,
+'CONCATENATION': self.convert_concatenation,
+'CONV_2D': self.convert_conv2d,
+'COS': self.convert_cos,
+'DEPTHWISE_CONV_2D': self.convert_depthwise_conv2d,
+'DETECTION_POSTPROCESS': self.convert_detection_postprocess,
+'DIV': self.convert_div,
+'ELU': self.convert_elu,
+'EQUAL': self.convert_equal,
 'EXP': self.convert_exp,
+'FLOOR_DIV': self.convert_floor_div,
+'FLOOR_MOD': self.convert_floor_mod,
 'FLOOR': self.convert_floor,
-'CEIL': self.convert_ceil,
+'FULLY_CONNECTED': self.convert_fully_connected,
+'GREATER_EQUAL': self.convert_greater_equal,
+'GREATER': self.convert_greater,
+'L2_NORMALIZATION': self.convert_l2_normalization,
+'LESS_EQUAL': self.convert_less_equal,
+'LESS': self.convert_less,
+'LOCAL_RESPONSE_NORMALIZATION': self.convert_lrn,
 'LOG': self.convert_log,
-'SIN': self.convert_sin,
-'COS': self.convert_cos,
-'TAN': self.convert_tan,
-'SQRT': self.convert_sqrt,
-'RSQRT': self.convert_rsqrt,
+'LOGICAL_AND': self.convert_logical_and,
+'LOGICAL_OR': self.convert_logical_or,
+'LOGISTIC': self.convert_logistic,
+'MAX_POOL_2D': self.convert_max_pool2d,
+'MAXIMUM': self.convert_maximum,
+'MEAN': self._convert_reduce_mean,
+'MINIMUM': self.convert_minimum,
+'MIRROR_PAD': self.convert_mirror_pad,
+'MUL': self.convert_mul,
 'NEG': self.convert_neg,
-'CONV_2D': self.convert_conv2d,
-'DEPTHWISE_CONV_2D': self.convert_depthwise_conv2d,
-'AVERAGE_POOL_2D': self.convert_average_pool2d,
+'NOT_EQUAL': self.convert_not_equal,
+'PACK': self.convert_pack,
+'PAD': self.convert_pad,
+'POW': self.convert_pow,
+'PRELU': self.convert_prelu,
+'REDUCE_MAX': self._convert_reduce_max,
+'REDUCE_MIN': self._convert_reduce_min,
+'REDUCE_PROD': self._convert_reduce_prod,
+'RELU':self.convert_relu,
 'RESHAPE': self.convert_reshape,
 'RESIZE_BILINEAR': self.convert_resize_bilinear,
 'RESIZE_NEAREST_NEIGHBOR': self.convert_resize_nearest_neighbor,
+'RSQRT': self.convert_rsqrt,
+'SIN': self.convert_sin,
+'SLICE': self.convert_slice,
 'SOFTMAX': self.convert_softmax,
+'SPACE_TO_BATCH_ND': self.convert_space_to_batch_nd,
+'SPLIT': self.convert_split,
+'SQRT': self.convert_sqrt,
+'SQUARE': self.convert_square,
+'SQUARED_DIFFERENCE': self.convert_squared_difference,
 'SQUEEZE': self.convert_squeeze,
-'MAX_POOL_2D': self.convert_max_pool2d,
-'CONCATENATION': self.convert_concatenation,
-'ADD': self.convert_add,
 'SUB': self.convert_sub,
-'MUL': self.convert_mul,
-'DIV': self.convert_div,
-'POW': self.convert_pow,
-'MAXIMUM': self.convert_maximum,
-'MINIMUM': self.convert_minimum,
-'GREATER': self.convert_greater,
-'GREATER_EQUAL': self.convert_greater_equal,
-'LESS': self.convert_less,
-'LESS_EQUAL': self.convert_less_equal

[incubator-tvm] branch master updated (95e7e34 -> 5e7fbae)

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

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


from 95e7e34  Support for AddV2 in Relay Tensorflow frontend converter. 
(#5046)
 add 5e7fbae  [TFLITE]Round op parsing support added (#5022)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  |  8 
 tests/python/frontend/tflite/test_forward.py | 10 ++
 2 files changed, 18 insertions(+)



[incubator-tvm] branch master updated: [TFLITE][FRONTEND]Reduce_any op parsing support (#4926)

2020-03-12 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 a950536  [TFLITE][FRONTEND]Reduce_any op parsing support (#4926)
a950536 is described below

commit a9505365fc128000ff11cba349147f7eeefcb067
Author: Samuel 
AuthorDate: Thu Mar 12 12:41:37 2020 +0530

[TFLITE][FRONTEND]Reduce_any op parsing support (#4926)

* [TFLITE][FRONTEND]Reduce_any op parsing support

* Testcase check added to run in tf version above 1.14.0 & review comments

* Review comment, checked updated to 1.15
---
 python/tvm/relay/frontend/tflite.py  |  4 
 tests/python/frontend/tflite/test_forward.py | 21 ++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index 6faf8d9..b4891c3 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -102,6 +102,7 @@ class OperatorConverter(object):
 'PAD': self.convert_pad,
 'POW': self.convert_pow,
 'PRELU': self.convert_prelu,
+'REDUCE_ANY': self._convert_reduce_any,
 'REDUCE_MAX': self._convert_reduce_max,
 'REDUCE_MIN': self._convert_reduce_min,
 'REDUCE_PROD': self._convert_reduce_prod,
@@ -1088,6 +1089,9 @@ class OperatorConverter(object):
 def _convert_reduce_sum(self, op):
 return self._convert_reduce(_op.reduce.sum, op)
 
+def _convert_reduce_any(self, op):
+return self._convert_reduce(_op.reduce.any, op)
+
 def convert_fully_connected(self, op):
 """Convert TFLite fully connected"""
 try:
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index cde8a74..0d76cf2 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -1154,11 +1154,24 @@ def _test_reduce_sum(data, keep_dims=None):
 """ One iteration of reduce_sum """
 return _test_reduce(math_ops.reduce_sum, data, keep_dims)
 
+###
+# Reduce_any
+# --
+
+def _test_reduce_any(data, keep_dims=None):
+""" One iteration of reduce_any """
+return _test_reduce(math_ops.reduce_any, data, keep_dims)
 
-def _test_forward_reduce(testop):
+def _test_forward_reduce(testop, dtype="float32"):
 """ Reduce """
-data0 = [np.random.rand(16, 16, 16, 16).astype("float32"), None]
-data1 = [np.random.rand(16, 16, 16, 16).astype("float32"), np.array([1, 
2], dtype=np.int32)]
+if dtype == 'bool':
+data0 = [np.random.choice(a=[False, True], size=(16, 16, 16, 
16)).astype(dtype),
+ None]
+data1 = [np.random.choice(a=[False, True], size=(16, 16, 16, 
16)).astype(dtype),
+ np.array([1, 2], dtype=np.int32)]
+else:
+data0 = [np.random.rand(16, 16, 16, 16).astype(dtype), None]
+data1 = [np.random.rand(16, 16, 16, 16).astype(dtype), np.array([1, 
2], dtype=np.int32)]
 testop(data0)
 testop(data0, keep_dims=False)
 testop(data0, keep_dims=True)
@@ -1179,6 +1192,8 @@ def test_all_reduce():
 _test_forward_reduce_quantized(_test_reduce_mean)
 _test_forward_reduce(_test_reduce_prod)
 _test_forward_reduce(_test_reduce_sum)
+if package_version.parse(tf.VERSION) >= package_version.parse('1.15.0'):
+_test_forward_reduce(_test_reduce_any, dtype="bool")
 
 
 ###



[incubator-tvm] branch master updated: [QNN] Support 4D padding. (#5036)

2020-03-11 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 0755e4a  [QNN] Support 4D padding. (#5036)
0755e4a is described below

commit 0755e4a58897c64d6a7ffc86bab3df45554bac7e
Author: Animesh Jain 
AuthorDate: Wed Mar 11 08:30:13 2020 -0700

[QNN] Support 4D padding. (#5036)

* [QNN] Support 4D padding.

* Empty commit.

Co-authored-by: Ubuntu 
---
 python/tvm/relay/qnn/op/qnn.py   |  4 
 src/relay/qnn/op/convolution.cc  | 17 ++---
 tests/python/relay/test_op_qnn_conv2d.py | 24 
 3 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/python/tvm/relay/qnn/op/qnn.py b/python/tvm/relay/qnn/op/qnn.py
index a7529f6..c94a419 100644
--- a/python/tvm/relay/qnn/op/qnn.py
+++ b/python/tvm/relay/qnn/op/qnn.py
@@ -19,6 +19,7 @@
 
 from __future__ import absolute_import as _abs
 from tvm.relay.expr import Tuple
+from tvm.relay.op.nn.util import get_pad_tuple2d
 from . import _make
 
 def requantize(data,
@@ -280,6 +281,9 @@ def conv2d(data,
 The computed result.
 """
 
+# TODO enforce 4-way padding in topi/nn/conv2d after #4644 merged
+# convert 2-way padding to 4-way padding
+padding = get_pad_tuple2d(padding)
 return _make.conv2d(data, kernel,
 input_zero_point, kernel_zero_point,
 input_scale, kernel_scale,
diff --git a/src/relay/qnn/op/convolution.cc b/src/relay/qnn/op/convolution.cc
index 91739e6..6626ce2 100644
--- a/src/relay/qnn/op/convolution.cc
+++ b/src/relay/qnn/op/convolution.cc
@@ -177,13 +177,17 @@ Expr Conv2DFallBack(const Expr& data, const Expr& weight, 
const Expr& input_zero
 Expr Conv2DPadInput(const Expr& data, const Expr& input_zero_point, const 
Conv2DAttrs* param) {
   // 1) Pad the input data
   auto padded_data = data;
-  auto pad_h_value = get_const_int(param->padding[0]);
-  auto pad_w_value = get_const_int(param->padding[1]);
-  if (pad_h_value != 0 || pad_w_value != 0) {
+  auto pad_top_value = get_const_int(param->padding[0]);
+  auto pad_left_value = get_const_int(param->padding[1]);
+  auto pad_bottom_value = get_const_int(param->padding[2]);
+  auto pad_right_value = get_const_int(param->padding[3]);
+  bool do_pad = pad_top_value != 0 || pad_left_value != 0 ||
+pad_bottom_value != 0 || pad_right_value != 0;
+  if (do_pad) {
 Array pad_n({0, 0});
 Array pad_c({0, 0});
-Array pad_h({param->padding[0], param->padding[0]});
-Array pad_w({param->padding[1], param->padding[1]});
+Array pad_h({param->padding[0], param->padding[2]});
+Array pad_w({param->padding[1], param->padding[3]});
 
 Array> pad_width;
 if (param->data_layout == "NCHW") {
@@ -336,7 +340,7 @@ Expr DepthwiseConv2DFourthTerm(int input_zero_point_int, 
int kernel_zero_point_i
  */
 Expr Conv2DFirstTerm(const Expr& padded_data, const Expr& weight, const 
Conv2DAttrs* param) {
   // Lowering for Term 1
-  Array padding({0, 0});
+  Array padding({0, 0, 0, 0});
   return Conv2D(padded_data, weight, param->strides, padding, param->dilation, 
param->groups,
 param->channels, param->kernel_size, param->data_layout, 
param->kernel_layout,
 param->out_layout, param->out_dtype);
@@ -583,7 +587,6 @@ Expr QnnConv2DCanonicalize(const Attrs& attrs, const 
Array& new_args,
   const auto* param = attrs.as();
   CHECK(param != nullptr);
   // Assertion checks for exisiing support.
-  CHECK_EQ(param->padding.size(), 2) << "qnn.conv2d only supports 2D padding";
   CHECK(param->data_layout == "NCHW" || param->data_layout == "NHWC")
   << "qnn.conv2d supports only NCHW/NHWC input data layout.";
   CHECK(param->kernel_layout == "OIHW" || param->kernel_layout == "HWIO" ||
diff --git a/tests/python/relay/test_op_qnn_conv2d.py 
b/tests/python/relay/test_op_qnn_conv2d.py
index 66acda8..6911c52 100644
--- a/tests/python/relay/test_op_qnn_conv2d.py
+++ b/tests/python/relay/test_op_qnn_conv2d.py
@@ -496,6 +496,30 @@ def test_padding():
 verify(ref_func, qnn_func, data_shape, data_dtype,
 kernel_shape, kernel_dtype)
 
+# Try asymmetric padding
+data_shape = (2, 2, 4, 4) # NHWC
+data_dtype = 'uint8'
+kernel_shape = (2, 2, 4, 3) # HWIO
+kernel_dtype = 'uint8'
+ref_func, qnn_func = get_funcs(data_shape=data_shape,
+   data_dtype=data_dtype,
+   kernel_shape=kernel_shape,
+   kernel_dtype=kernel_dtype,
+  

[incubator-tvm] branch master updated: Windows Support for cpp_rpc (#4857)

2020-04-15 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 afcf939  Windows Support for cpp_rpc (#4857)
afcf939 is described below

commit afcf9397b60ae7ccf46601cf29828992ca9d5f57
Author: jmorrill 
AuthorDate: Wed Apr 15 01:49:15 2020 -0700

Windows Support for cpp_rpc (#4857)

* Windows Support for cpp_rpc

* Add missing patches that fix crashes under Windows

* On Windows, use python to untar vs wsl

* remove some CMakeLists.txt stuff

* more minor CMakeLists.txt changes

* Remove items from CMakeLists.txt

* Minor CMakeLists.txt changes

* More minor CMakeLists.txt changes

* Even more minor CMakeLists.txt changes

* Modify readme
---
 CMakeLists.txt |   8 +
 apps/cpp_rpc/CMakeLists.txt|  27 
 apps/cpp_rpc/README.md |  10 +-
 apps/cpp_rpc/main.cc   |  95 
 apps/cpp_rpc/rpc_env.cc| 305 -
 apps/cpp_rpc/rpc_env.h |   6 +-
 apps/cpp_rpc/rpc_server.cc | 250 +++---
 apps/cpp_rpc/rpc_server.h  |  23 ++-
 apps/cpp_rpc/win32_process.cc  | 273 +
 apps/cpp_rpc/win32_process.h   |  43 ++
 src/runtime/rpc/rpc_socket_impl.cc |  11 +-
 src/support/ring_buffer.h  |   2 +-
 12 files changed, 751 insertions(+), 302 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf334ff..8a559b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,9 +66,14 @@ tvm_option(USE_NNPACK "Build with nnpack support" OFF)
 tvm_option(USE_RANDOM "Build with random support" OFF)
 tvm_option(USE_MICRO_STANDALONE_RUNTIME "Build with micro.standalone_runtime 
support" OFF)
 tvm_option(USE_ANTLR "Build with ANTLR for Relay parsing" OFF)
+tvm_option(USE_CPP_RPC "Build CPP RPC" OFF)
 tvm_option(USE_TFLITE "Build with tflite support" OFF)
 tvm_option(USE_TENSORFLOW_PATH "TensorFlow root path when use TFLite" none)
 
+if(USE_CPP_RPC AND UNIX)
+  message(FATAL_ERROR "USE_CPP_RPC is only supported with WIN32. Use the 
Makefile for non-Windows.")
+endif()
+
 # include directories
 include_directories(${CMAKE_INCLUDE_PATH})
 include_directories("include")
@@ -309,6 +314,9 @@ add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
 add_library(tvm_topi SHARED ${TOPI_SRCS})
 add_library(tvm_runtime SHARED ${RUNTIME_SRCS})
 
+if(USE_CPP_RPC)
+  add_subdirectory("apps/cpp_rpc")
+endif()
 
 if(USE_RELAY_DEBUG)
   message(STATUS "Building Relay in debug mode...")
diff --git a/apps/cpp_rpc/CMakeLists.txt b/apps/cpp_rpc/CMakeLists.txt
new file mode 100644
index 000..9888738
--- /dev/null
+++ b/apps/cpp_rpc/CMakeLists.txt
@@ -0,0 +1,27 @@
+set(TVM_RPC_SOURCES 
+  main.cc
+  rpc_env.cc
+  rpc_server.cc
+)
+
+if(WIN32)
+  list(APPEND TVM_RPC_SOURCES win32_process.cc)
+endif()
+
+# Set output to same directory as the other TVM libs
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+add_executable(tvm_rpc ${TVM_RPC_SOURCES})
+set_property(TARGET tvm_rpc PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
+
+if(WIN32)
+  target_compile_definitions(tvm_rpc PUBLIC -DNOMINMAX)
+endif()
+
+target_include_directories(
+  tvm_rpc
+  PUBLIC "../../include"
+  PUBLIC DLPACK_PATH
+  PUBLIC DMLC_PATH
+)
+ 
+target_link_libraries(tvm_rpc tvm_runtime)
\ No newline at end of file
diff --git a/apps/cpp_rpc/README.md b/apps/cpp_rpc/README.md
index 4baecaf..c826dae 100644
--- a/apps/cpp_rpc/README.md
+++ b/apps/cpp_rpc/README.md
@@ -18,7 +18,7 @@
 # TVM RPC Server
 This folder contains a simple recipe to make RPC server in c++.
 
-## Usage
+## Usage (Non-Windows)
 - Build tvm runtime
 - Make the rpc executable [Makefile](Makefile).
   `make CXX=/path/to/cross compiler g++/ TVM_RUNTIME_DIR=/path/to/tvm runtime 
library directory/ OS=Linux`
@@ -35,6 +35,12 @@ This folder contains a simple recipe to make RPC server in 
c++.
 ```
 - Use `./tvm_rpc server` to start the RPC server
 
+## Usage (Windows)
+- Build tvm with the argument -DUSE_CPP_RPC
+- Install [LLVM pre-build binaries](https://releases.llvm.org/download.html), 
making sure to select the option to add it to the PATH.
+- Verify Python 3.6 or newer is installed and in the PATH.
+- Use `\tvm_rpc.exe` to start the RPC server
+
 ## How it works
 - The tvm runtime dll is linked along with this executable and when the RPC 
server starts it will load the tvm runtime library.
 
@@ -53,4 +59,4 @@ Command line usage
 ```
 
 ## Note
-Currently support is only there for Linux / Android environment and proxy mode 
doesn't be supported currently.
\ No newline at end of file
+Currently support is only the

[incubator-tvm] branch master updated (3db8880 -> fbcf61a)

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

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


from 3db8880  fix fuse over functions that are handled by external codegen 
(#5365)
 add fbcf61a  [RUNTIME] FastRPC interface for Hexagon runtime (#5353)

No new revisions were added by this update.

Summary of changes:
 src/runtime/hexagon/target/fastrpc/CMakeLists.txt  | 179 +++
 src/runtime/hexagon/target/fastrpc/README.md   |  56 
 .../hexagon/target/fastrpc/include/tvm_remote.idl  |  51 
 .../target/fastrpc/include/tvm_remote_nd.idl   |  49 +++
 src/runtime/hexagon/target/fastrpc/src/tvm_hvx.cc  | 208 +
 src/runtime/hexagon/target/fastrpc/src/tvm_hvx.h   | 153 ++
 .../hexagon/target/fastrpc/src/tvm_remote_imp.cc   | 255 
 .../target/fastrpc/src/tvm_remote_nd_imp.cc| 335 +
 .../hexagon/target/fastrpc/src/tvm_wrap_pthread.cc |  79 +
 .../hexagon/target/fastrpc/tvm_hexagon_remote.h| 129 
 .../hexagon/target/fastrpc/tvm_hexagon_remote_nd.h |  88 --
 .../hexagon/target/hexagon_device_target.cc|  71 +++--
 src/runtime/hexagon/target/hexagon_stubapi.cc  |  34 +--
 src/runtime/hexagon/target/hexagon_stubapi.h   | 130 
 tests/lint/check_file_type.py  |   4 +-
 15 files changed, 1484 insertions(+), 337 deletions(-)
 create mode 100644 src/runtime/hexagon/target/fastrpc/CMakeLists.txt
 create mode 100644 src/runtime/hexagon/target/fastrpc/README.md
 create mode 100644 src/runtime/hexagon/target/fastrpc/include/tvm_remote.idl
 create mode 100644 src/runtime/hexagon/target/fastrpc/include/tvm_remote_nd.idl
 create mode 100644 src/runtime/hexagon/target/fastrpc/src/tvm_hvx.cc
 create mode 100644 src/runtime/hexagon/target/fastrpc/src/tvm_hvx.h
 create mode 100644 src/runtime/hexagon/target/fastrpc/src/tvm_remote_imp.cc
 create mode 100644 src/runtime/hexagon/target/fastrpc/src/tvm_remote_nd_imp.cc
 create mode 100644 src/runtime/hexagon/target/fastrpc/src/tvm_wrap_pthread.cc
 delete mode 100644 src/runtime/hexagon/target/fastrpc/tvm_hexagon_remote.h
 delete mode 100644 src/runtime/hexagon/target/fastrpc/tvm_hexagon_remote_nd.h



[incubator-tvm] branch master updated (6dfcd37 -> 49d304f)

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

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


from 6dfcd37  [Hexagon] Add hexagon_posix.cc to TVM/RT sources in the right 
place (#5346)
 add 49d304f  [TOPI-ARM] Do not alter layout if layout is NHWC (#5350)

No new revisions were added by this update.

Summary of changes:
 tests/python/relay/test_pass_alter_op_layout.py | 29 -
 topi/python/topi/arm_cpu/conv2d_alter_op.py |  4 
 2 files changed, 8 insertions(+), 25 deletions(-)



[incubator-tvm] branch master updated (9bbee96 -> 6dfcd37)

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

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


from 9bbee96  [PYTORCH]Tensor creation ops support (#5347)
 add 6dfcd37  [Hexagon] Add hexagon_posix.cc to TVM/RT sources in the right 
place (#5346)

No new revisions were added by this update.

Summary of changes:
 CMakeLists.txt | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)



[incubator-tvm] branch master updated (00a8481 -> 608e945)

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

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


from 00a8481  [TE] Minor bugfix in message_passing.cc (#5254)
 add 608e945  [TFLITE]Hard Swish & MobilnetV3 model testing (#5239)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 37 
 tests/python/frontend/tflite/test_forward.py | 51 
 2 files changed, 88 insertions(+)



[incubator-tvm] branch master updated: [Strategy][ARM CPU] Remove contrib spatial pack schedule of depthwise convolution (#5148)

2020-03-25 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 314f31b  [Strategy][ARM CPU] Remove contrib spatial pack schedule of 
depthwise convolution (#5148)
314f31b is described below

commit 314f31b0b4e2dbc934d74afe90bff1ef3ac40b17
Author: Zhao Wu 
AuthorDate: Thu Mar 26 13:10:00 2020 +0800

[Strategy][ARM CPU] Remove contrib spatial pack schedule of depthwise 
convolution (#5148)

* [Strategy][ARM CPU] Low the plevel of contrib spatial pack of depthwise 
convolution

* address comments
---
 python/tvm/relay/op/strategy/arm_cpu.py  | 15 ++-
 topi/python/topi/arm_cpu/depthwise_conv2d.py |  5 +
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/python/tvm/relay/op/strategy/arm_cpu.py 
b/python/tvm/relay/op/strategy/arm_cpu.py
index 87e48dc..a803bb6 100644
--- a/python/tvm/relay/op/strategy/arm_cpu.py
+++ b/python/tvm/relay/op/strategy/arm_cpu.py
@@ -105,11 +105,16 @@ def conv2d_strategy_arm_cpu(attrs, inputs, out_type, 
target):
 wrap_compute_conv2d(topi.arm_cpu.depthwise_conv2d_nchw),
 
wrap_topi_schedule(topi.arm_cpu.schedule_depthwise_conv2d_nchw),
 name="depthwise_conv2d_nchw.arm_cpu")
-strategy.add_implementation(
-
wrap_compute_conv2d(topi.arm_cpu.depthwise_conv2d_nchw_spatial_pack),
-
wrap_topi_schedule(topi.arm_cpu.schedule_depthwise_conv2d_nchw_spatial_pack),
-name="depthwise_conv2d_nchw_spatial_pack.arm_cpu",
-plevel=15)
+# TODO:
+# This schedule has incorrect result on some hardware platforms 
(like NV Jetson TX2)
+# Let us comment it out but not remove.
+# see discussion:
+# 
https://discuss.tvm.ai/t/autotuner-incorrect-result-after-tuning-mobilenetv2-on-arm-cpu/6088
+# strategy.add_implementation(
+# 
wrap_compute_conv2d(topi.arm_cpu.depthwise_conv2d_nchw_spatial_pack),
+# 
wrap_topi_schedule(topi.arm_cpu.schedule_depthwise_conv2d_nchw_spatial_pack),
+# name="depthwise_conv2d_nchw_spatial_pack.arm_cpu",
+# plevel=15)
 elif layout == "NHWC":
 assert kernel_layout == "HWOI"
 logger.warning("depthwise_conv2d with layout NHWC is not optimized 
for arm cpu.")
diff --git a/topi/python/topi/arm_cpu/depthwise_conv2d.py 
b/topi/python/topi/arm_cpu/depthwise_conv2d.py
index 5214972..802b3df 100644
--- a/topi/python/topi/arm_cpu/depthwise_conv2d.py
+++ b/topi/python/topi/arm_cpu/depthwise_conv2d.py
@@ -139,6 +139,11 @@ def schedule_depthwise_conv2d_nchw(cfg, outs):
 return s
 
 
+# TODO:
+# This schedule has incorrect result on some hardware platforms (like NV 
Jetson TX2)
+# Let us comment it out but not remove.
+# see discussion:
+# 
https://discuss.tvm.ai/t/autotuner-incorrect-result-after-tuning-mobilenetv2-on-arm-cpu/6088
 @autotvm.register_topi_compute("depthwise_conv2d_nchw_spatial_pack.arm_cpu")
 def depthwise_conv2d_nchw_spatial_pack(cfg, data, kernel, strides, padding, 
dilation, out_dtype):
 """TOPI compute callback for depthwise_conv2d nchw



[incubator-tvm] branch master updated: Handle empty LLVMModule in GetFunction (#5146)

2020-03-25 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 08b38be  Handle empty LLVMModule in GetFunction (#5146)
08b38be is described below

commit 08b38be95f4eb4e9c6c1c4d41a5219b9ba689bf1
Author: Ruizhe Zhao 
AuthorDate: Thu Mar 26 02:11:29 2020 +

Handle empty LLVMModule in GetFunction (#5146)
---
 src/target/llvm/llvm_module.cc | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc
index 6cf9f11..3f508a5 100644
--- a/src/target/llvm/llvm_module.cc
+++ b/src/target/llvm/llvm_module.cc
@@ -71,6 +71,10 @@ class LLVMModuleNode final : public runtime::ModuleNode {
   });
 }
 if (ee_ == nullptr) LazyInitJIT();
+
+// This LLVMModule is empty and no function can be retrieved.
+if (entry_func_.empty()) return nullptr;
+
 std::lock_guard lock(mutex_);
 const std::string& fname = (name == runtime::symbol::tvm_module_main ?
 entry_func_ : name);
@@ -318,6 +322,10 @@ class LLVMModuleNode final : public runtime::ModuleNode {
 << "Failed to initialize jit engine for " << mptr_->getTargetTriple();
 ee_->runStaticConstructorsDestructors(false);
 // setup context address.
+// we will skip context setup if this LLVMModule is empty.
+if (GetGlobalAddr(runtime::symbol::tvm_module_main) == 0)
+  return;
+
 entry_func_ =
 reinterpret_cast(GetGlobalAddr(runtime::symbol::tvm_module_main));
 if (void** ctx_addr = reinterpret_cast(
@@ -329,7 +337,7 @@ class LLVMModuleNode final : public runtime::ModuleNode {
   });
   }
   // Get global address from execution engine.
-  uint64_t GetGlobalAddr(const std::string& name) {
+  uint64_t GetGlobalAddr(const std::string& name) const {
 // first verifies if GV exists.
 if (mptr_->getGlobalVariable(name) != nullptr) {
   return ee_->getGlobalValueAddress(name);
@@ -337,7 +345,7 @@ class LLVMModuleNode final : public runtime::ModuleNode {
   return 0;
 }
   }
-  uint64_t GetFunctionAddr(const std::string& name) {
+  uint64_t GetFunctionAddr(const std::string& name) const {
 // first verifies if GV exists.
 if (mptr_->getFunction(name) != nullptr) {
   return ee_->getFunctionAddress(name);



[incubator-tvm] branch master updated: [DOCSTRING]missing function parameters updated (#5228)

2020-04-03 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 3c2aa1a  [DOCSTRING]missing function parameters updated (#5228)
3c2aa1a is described below

commit 3c2aa1aa830c8c889a77ba56105b06243648d843
Author: Samuel 
AuthorDate: Fri Apr 3 19:11:28 2020 +0530

[DOCSTRING]missing function parameters updated (#5228)
---
 python/tvm/relay/op/nn/nn.py | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/python/tvm/relay/op/nn/nn.py b/python/tvm/relay/op/nn/nn.py
index c62b1cf..64148bb 100644
--- a/python/tvm/relay/op/nn/nn.py
+++ b/python/tvm/relay/op/nn/nn.py
@@ -475,8 +475,8 @@ def log_softmax(data, axis=-1):
 data: tvm.relay.Expr
 The input data to the operator.
 
-axis: int
-The axis to sum over when computing softmax
+axis: int, optional
+The axis to sum over when computing log softmax
 
 Returns
 ---
@@ -510,6 +510,9 @@ def max_pool1d(data,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : int or tuple of int, optional
 The strides of pooling.
 
@@ -567,6 +570,9 @@ def max_pool2d(data,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : tuple of int, optional
 The strides of pooling.
 
@@ -612,6 +618,9 @@ def max_pool3d(data,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : tuple of int, optional
 The strides of pooling.
 
@@ -658,6 +667,9 @@ def avg_pool1d(data,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : int or tuple of int, optional
 The strides of pooling.
 
@@ -720,6 +732,9 @@ def avg_pool2d(data,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : tuple of int, optional
 The strides of pooling.
 
@@ -769,6 +784,9 @@ def avg_pool3d(data,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : tuple of int, optional
 The strides of pooling.
 
@@ -811,6 +829,9 @@ def max_pool2d_grad(out_grad,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : tuple of int, optional
 The strides of pooling.
 
@@ -851,6 +872,9 @@ def avg_pool2d_grad(out_grad,
 data : tvm.relay.Expr
 The input data to the operator.
 
+pool_size : int or tuple of int, optional
+The size of window for pooling.
+
 strides : tuple of int, optional
 The strides of pooling.
 



[incubator-tvm] branch master updated (ff6fa39 -> ff7bab8)

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

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


from ff6fa39  [TEST] Various CI fixes for the VTA and Relay  (#5181)
 add ff7bab8  [TOPI] Setting workload correctly for Depthwise conv ARM. 
(#5182)

No new revisions were added by this update.

Summary of changes:
 topi/python/topi/arm_cpu/conv2d_alter_op.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



[incubator-tvm] branch master updated: [FRONTEND][KERAS]Max_pool3d and Averagepool3d operator support (#5085)

2020-03-31 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 c97e41b  [FRONTEND][KERAS]Max_pool3d and Averagepool3d operator 
support  (#5085)
c97e41b is described below

commit c97e41b0c079c1181541501b14151be7499eccb9
Author: Samuel 
AuthorDate: Tue Mar 31 14:11:41 2020 +0530

[FRONTEND][KERAS]Max_pool3d and Averagepool3d operator support  (#5085)

* [KERAS]Pool3d support added

* Keras pool3d testcase added
---
 python/tvm/relay/frontend/keras.py  | 41 +++--
 tests/python/frontend/keras/test_forward.py | 23 
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/python/tvm/relay/frontend/keras.py 
b/python/tvm/relay/frontend/keras.py
index f5f9ad5..7c189f2 100644
--- a/python/tvm/relay/frontend/keras.py
+++ b/python/tvm/relay/frontend/keras.py
@@ -510,6 +510,43 @@ def _convert_pooling(inexpr, keras_layer, etab):
 raise tvm.error.OpNotImplemented(
 'Operator {} is not supported for frontend Keras.'.format(keras_layer))
 
+def _convert_pooling3d(inexpr, keras_layer, etab):
+_check_data_format(keras_layer)
+pool_type = type(keras_layer).__name__
+
+if pool_type not in ['MaxPooling3D', 'AveragePooling3D']:
+raise tvm.error.OpNotImplemented(
+'Operator {} is not supported for frontend 
Keras.'.format(keras_layer))
+
+pool_d1, pool_d2, pool_d3 = keras_layer.pool_size
+stride_d1, stride_d2, stride_d3 = keras_layer.strides
+params = {'pool_size': [pool_d1, pool_d2, pool_d3],
+  'strides': [stride_d1, stride_d2, stride_d3],
+  'padding': [0, 0, 0],
+  'layout': etab.data_layout}
+
+if keras_layer.padding == 'valid':
+pass
+elif keras_layer.padding == 'same':
+in_d1 = keras_layer.input_shape[1]
+in_d2 = keras_layer.input_shape[2]
+in_d3 = keras_layer.input_shape[3]
+pad_d1 = _get_pad_pair(in_d1, pool_d1, stride_d1)
+pad_d2 = _get_pad_pair(in_d2, pool_d2, stride_d2)
+pad_d3 = _get_pad_pair(in_d3, pool_d3, stride_d3)
+params['padding'] = [pad_d1[0], pad_d2[0], pad_d3[0], pad_d1[1], 
pad_d2[1], pad_d3[1]]
+else:
+raise tvm.error.OpAttributeUnImplemented(
+'Padding with {} is not supported in operator 
Pooling3D.'.format(keras_layer.padding))
+
+out = _op.transpose(inexpr, axes=(0, 4, 1, 2, 3))
+params['layout'] = "NCDHW"
+if pool_type == 'MaxPooling3D':
+out = _op.nn.max_pool3d(out, **params)
+elif pool_type == 'AveragePooling3D':
+out = _op.nn.avg_pool3d(out, **params)
+
+return _op.transpose(out, axes=(0, 2, 3, 4, 1))
 
 def _convert_upsample(inexpr, keras_layer, etab):
 _check_data_format(keras_layer)
@@ -817,8 +854,8 @@ _convert_map = {
 'Conv3D'   : _convert_convolution3d,
 # 'Conv3DTranspose': _convert_convolution3d,
 # 'SeparableConv3D': _convert_convolution3d,
-# 'MaxPooling3D'   : _convert_pooling3d,
-# 'AveragePooling3D'   : _convert_pooling3d,
+'MaxPooling3D' : _convert_pooling3d,
+'AveragePooling3D' : _convert_pooling3d,
 # 'GlobalMaxPooling3D' : _convert_pooling3d,
 # 'GlobalAveragePooling3D' : _convert_pooling3d,
 # 'UpSampling3D'   : _convert_upsample3d,
diff --git a/tests/python/frontend/keras/test_forward.py 
b/tests/python/frontend/keras/test_forward.py
index 57f6401..5f4bcb1 100644
--- a/tests/python/frontend/keras/test_forward.py
+++ b/tests/python/frontend/keras/test_forward.py
@@ -421,6 +421,28 @@ class TestKeras:
 keras_model = keras.models.Model(data, x)
 verify_keras_frontend(keras_model, layout='NDHWC')
 
+def test_forward_pool3d(self, keras):
+data = keras.layers.Input(shape=(32, 32, 32, 1))
+pool_funcs = [# maxpool
+  keras.layers.MaxPooling3D(pool_size=(2, 2, 2),
+strides=(1, 1, 1),
+padding='same'),
+  keras.layers.MaxPooling3D(pool_size=(3, 3, 3),
+strides=(2, 2, 2),
+padding='valid'),
+  # avgpool
+  keras.layers.AveragePooling3D(pool_size=(3, 3, 3),
+strides=(2, 2, 2),
+padding='same'),
+  keras.layers.AveragePooling3D(pool_size=(2, 2, 2),
+strides=(1, 1, 1),
+padding='valid'),
+ ]
+for pool_func in 

[incubator-tvm] branch master updated: Add support for sharing params of operators in tensorflow frontend (#5042)

2020-03-30 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 c38f2f3  Add support for sharing params of operators in tensorflow 
frontend (#5042)
c38f2f3 is described below

commit c38f2f39e2af9880df466f9f8f130f960edaac74
Author: lfengad 
AuthorDate: Mon Mar 30 15:23:26 2020 +0800

Add support for sharing params of operators in tensorflow frontend (#5042)
---
 python/tvm/relay/frontend/tensorflow.py  |  2 +-
 tests/python/frontend/tensorflow/test_forward.py | 18 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/python/tvm/relay/frontend/tensorflow.py 
b/python/tvm/relay/frontend/tensorflow.py
index 56aa1d6..f79b637 100644
--- a/python/tvm/relay/frontend/tensorflow.py
+++ b/python/tvm/relay/frontend/tensorflow.py
@@ -81,7 +81,7 @@ def _dimension_constraint():
 def _get_param(params, input_node):
 if isinstance(input_node, _expr.Constant):
 return np.atleast_1d(input_node.data.asnumpy())
-return params.pop(input_node.name_hint).asnumpy()
+return params[input_node.name_hint].asnumpy()
 
 def _get_num_param(params, input_node):
 return _get_param(params, input_node).item()
diff --git a/tests/python/frontend/tensorflow/test_forward.py 
b/tests/python/frontend/tensorflow/test_forward.py
index b1efe4a..13db8fd 100644
--- a/tests/python/frontend/tensorflow/test_forward.py
+++ b/tests/python/frontend/tensorflow/test_forward.py
@@ -3058,6 +3058,21 @@ def test_forward_add_n():
 _test_forward_add_n(in4)
 _test_forward_add_n(in5)
 
+###
+# Sharing params case
+# --
+
+
+def test_sharing_node():
+"""Test the sharing params case."""
+np_data = np.random.uniform(size=(2,2,2)).astype('float32')
+with tf.Graph().as_default():
+in_data = tf.placeholder(tf.float32, shape=(2, 2, 2), name='in_data')
+axis = tf.constant([-1], dtype=tf.int32, name='axis')
+mean0 = tf.reduce_mean(in_data, axis=axis, keepdims=False, 
name='mean0')
+mean1 = tf.reduce_mean(in_data, axis=axis, keepdims=False, 
name='mean1')
+out = tf.add(mean0, mean1, name='out')
+compare_tf_with_tvm([np_data], ['in_data:0'], 'out:0')
 
 ###
 # Unravel Index
@@ -3311,3 +3326,6 @@ if __name__ == '__main__':
 
 # Internal misc. ops
 test_read_variable_op()
+
+# Sharing params case using Mean ops
+test_sharing_node()



[incubator-tvm] branch master updated: [Frontend][TFLite] L2_POOL_2D operator (#5452)

2020-04-28 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 a38f61a  [Frontend][TFLite] L2_POOL_2D operator (#5452)
a38f61a is described below

commit a38f61af45139f4e9651e33b6f124aa54b08d442
Author: Mahesh Ambule <15611578+maheshamb...@users.noreply.github.com>
AuthorDate: Wed Apr 29 11:05:54 2020 +0530

[Frontend][TFLite] L2_POOL_2D operator (#5452)

* TFLITE fill and splitv ops

* l2_pool_2d op changes in comment

* TFLite l2_pool_2d op added test case in main

* TFLite L2_POOL_2D added check for quantized input
---
 python/tvm/relay/frontend/tflite.py  | 15 +++
 tests/python/frontend/tflite/test_forward.py | 26 ++
 2 files changed, 41 insertions(+)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index bba7d3b..2065d60 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -87,6 +87,7 @@ class OperatorConverter(object):
 'GREATER': self.convert_greater,
 'HARD_SWISH': self.convert_hard_swish,
 'L2_NORMALIZATION': self.convert_l2_normalization,
+'L2_POOL_2D': self.convert_l2_pool2d,
 'LESS_EQUAL': self.convert_less_equal,
 'LESS': self.convert_less,
 'LOCAL_RESPONSE_NORMALIZATION': self.convert_lrn,
@@ -332,6 +333,10 @@ class OperatorConverter(object):
 """Convert TFLite max pool2d"""
 return self.convert_pool2d(op, "max")
 
+def convert_l2_pool2d(self, op):
+"""Convert TFLite l2 pool2d"""
+return self.convert_pool2d(op, "l2")
+
 def convert_reshape(self, op):
 """Convert TFLite reshape"""
 try:
@@ -1770,6 +1775,16 @@ class OperatorConverter(object):
 assert self.has_same_qnn_params(input_tensor, output_tensor), \
 "qnn.op.max_pool2d requires input and output qnn 
params to be same"
 out = _op.nn.max_pool2d(in_expr, **params)
+elif pool_type == "l2":
+# L2_POOL_2D is equivalent to 
square_root(avg_pool(square(in_data)))
+# TFLite does not have support for quantised L2_POOL_2D op.
+assert not input_tensor.qnn_params, \
+"As TFLite does not have support for quantized L2_POOL_2D, \
+Quantized input is not expected."
+exp_type = self.get_tensor_type_str(output_tensor.tensor.Type())
+square_exp = _op.power(in_expr, relay.const(2, exp_type))
+avg_pool_exp = _op.nn.avg_pool2d(square_exp, **params)
+out = _op.sqrt(avg_pool_exp)
 else:
 raise tvm.error.OpNotImplemented(
 'Operator {} is not supported for frontend 
TFLite.'.format(pool_type + ' pool'))
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index b9602a5..eb65d82 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -561,6 +561,31 @@ def test_forward_pooling():
   strides=[2, 1])
 
 
+def _test_l2_pool2d(input_shape, ksize, strides, padding, data_format, 
fused_func_name=None):
+x = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) 
- 1
+
+with tf.Graph().as_default():
+in_data = tf.placeholder(
+dtype=tf.float32, name="input", shape=input_shape)
+out = tf.sqrt(tf.nn.avg_pool(
+tf.square(in_data), ksize=ksize, strides=strides,
+padding=padding, data_format=data_format))
+out = with_fused_activation_function(out, fused_func_name)
+
+compare_tflite_with_tvm(x, 'input', [in_data], [out])
+
+
+def test_forward_l2_pool2d():
+_test_l2_pool2d([1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], 'SAME', "NHWC", 
"RELU6")
+_test_l2_pool2d([2, 9, 10, 2], [1, 1, 1, 1], [1, 1, 1, 1], 'SAME', "NHWC", 
"RELU6")
+_test_l2_pool2d([2, 9, 10, 2], [1, 2, 1, 1], [1, 1, 1, 1], 'SAME', "NHWC")
+_test_l2_pool2d([2, 9, 10, 2], [1, 2, 1, 1], [1, 1, 2, 1], 'SAME', "NHWC")
+_test_l2_pool2d([1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], 'VALID', "NHWC", 
"RELU")
+_test_l2_pool2d([2, 9, 10, 2], [1, 1, 1, 1], [1, 1, 1, 1], 'VALID', "NHWC")
+_test_l2_pool2d([2, 9, 10, 2], [1, 2, 1, 1], [1, 1, 1, 1], 'VALID', "NHWC")
+_test_l2_pool2d([2, 9, 10, 2], [1, 2, 1, 1], [1, 1, 2, 1], 'VALID', 
"NHWC", "RELU6")
+
+
 ###

[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.
+ou

[incubator-tvm] branch master updated (ef61fd5 -> 24f6865)

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

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


from ef61fd5  [LLVM] Use ArrayRef in calls to CreateShuffleVector 
(#5399)
 add 24f6865  [KERAS]Minimum & AlphaDropout op support (#5380)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/keras.py  | 9 +++--
 tests/python/frontend/keras/test_forward.py | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)



[incubator-tvm] branch master updated: Factor out import of common tflite.Operator in tflite frontend. (#5355)

2020-04-22 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 3e3ccce  Factor out import of common tflite.Operator in tflite 
frontend. (#5355)
3e3ccce is described below

commit 3e3ccce1135c25dd1d99dc7c2b8ff589c93ee7ea
Author: Ramana Radhakrishnan 
AuthorDate: Wed Apr 22 07:09:11 2020 +0100

Factor out import of common tflite.Operator in tflite frontend. (#5355)

* Restructure imports in tflite frontend.

These python modules are needed for every tflite file parsed.
Factorize out imports of the common most ones.

Now that the import of operator is common, asserts can be commonized.

Loses 473 lines of duplication.

* Only restrict to tflite.Operator
---
 python/tvm/relay/frontend/tflite.py | 156 ++--
 1 file changed, 5 insertions(+), 151 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index d489bd3..a2e0904 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -159,7 +159,12 @@ class OperatorConverter(object):
 op = self.subgraph.Operators(op_idx)
 op_code_str = self.get_op_code_str(op)
 output_tensors = self.get_output_tensors(op)
+try:
+from tflite.Operator import Operator
+except ImportError:
+raise ImportError("The tflite package must be installed")
 
+assert isinstance(op, Operator)
 ret = self.convert_map[op_code_str](op)
 
 if len(output_tensors) == 1:
@@ -288,12 +293,6 @@ class OperatorConverter(object):
 
 def is_quantized(self, op):
 """Check if an input tensor is quantized."""
-try:
-from tflite.Operator import Operator
-except ImportError:
-raise ImportError("The tflite package must be installed")
-
-assert isinstance(op, Operator)
 input_tensors = self.get_input_tensors(op)
 first_tensor = input_tensors[0]
 return first_tensor.qnn_params is not None
@@ -335,12 +334,10 @@ class OperatorConverter(object):
 """Convert TFLite reshape"""
 try:
 from tflite.BuiltinOptions import BuiltinOptions
-from tflite.Operator import Operator
 from tflite.ReshapeOptions import ReshapeOptions
 except ImportError:
 raise ImportError("The tflite package must be installed")
 
-assert isinstance(op, Operator)
 input_tensors = self.get_input_tensors(op)
 assert input_tensors, "input tensors should not be empty"
 input_tensor = input_tensors[0]
@@ -368,7 +365,6 @@ class OperatorConverter(object):
 """Generic method to Convert TFLite RESIZE operators"""
 try:
 from tflite.BuiltinOptions import BuiltinOptions
-from tflite.Operator import Operator
 from tflite.ResizeBilinearOptions import ResizeBilinearOptions
 # ResizeNearestNeighborOptions was added in tflite v1.13
 tflite_ver = 1120
@@ -378,7 +374,6 @@ class OperatorConverter(object):
 except ImportError:
 raise ImportError("The tflite package must be installed")
 
-assert isinstance(op, Operator)
 input_tensors = self.get_input_tensors(op)
 assert len(input_tensors) == 2, "input tensors length should be 2"
 
@@ -421,14 +416,12 @@ class OperatorConverter(object):
 def convert_l2_normalization(self, op):
 """Convert TFLite L2_NORMALIZATION """
 try:
-from tflite.Operator import Operator
 from tflite.BuiltinOptions import BuiltinOptions
 from tflite.L2NormOptions import L2NormOptions
 from tflite.ActivationFunctionType import ActivationFunctionType
 except ImportError:
 raise ImportError("The tflite package must be installed")
 
-assert isinstance(op, Operator)
 input_tensors = self.get_input_tensors(op)
 assert len(input_tensors) == 1, "input tensors length should be 1"
 input_tensor = input_tensors[0]
@@ -467,13 +460,11 @@ class OperatorConverter(object):
 def convert_lrn(self, op):
 """Convert TFLite LOCAL_RESPONSE_NORMALIZATION """
 try:
-from tflite.Operator import Operator
 from tflite.BuiltinOptions import BuiltinOptions
 from tflite.LocalResponseNormalizationOptions import 
LocalResponseNormalizationOptions
 except ImportError:
 raise ImportError(&qu

[incubator-tvm] branch master updated: [RUNTIME][CONTRIB] CoreML Runtime (#5283)

2020-04-23 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 1acad98  [RUNTIME][CONTRIB] CoreML Runtime (#5283)
1acad98 is described below

commit 1acad98edc1a74c0f17faf233af3f28918da6acf
Author: MORITA Kazutaka 
AuthorDate: Thu Apr 23 16:35:43 2020 +0900

[RUNTIME][CONTRIB] CoreML Runtime (#5283)

* [RUNTIME][CONTRIB] CoreML Runtime

* fix lint

* fix CI

* use xcrun to compile coreml model
---
 CMakeLists.txt|   2 +
 apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj |   2 +-
 apps/ios_rpc/tvmrpc/TVMRuntime.mm |   2 +
 cmake/modules/contrib/CoreML.cmake|  25 
 python/tvm/contrib/coreml_runtime.py  |  71 +++
 python/tvm/contrib/xcode.py   |  11 ++
 src/runtime/contrib/coreml/coreml_runtime.h   | 116 +
 src/runtime/contrib/coreml/coreml_runtime.mm  | 172 ++
 tests/python/contrib/test_coreml_runtime.py   | 107 
 9 files changed, 507 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 71662bd..2ebf7bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,6 +69,7 @@ tvm_option(USE_ANTLR "Build with ANTLR for Relay parsing" OFF)
 tvm_option(USE_CPP_RPC "Build CPP RPC" OFF)
 tvm_option(USE_TFLITE "Build with tflite support" OFF)
 tvm_option(USE_TENSORFLOW_PATH "TensorFlow root path when use TFLite" none)
+tvm_option(USE_COREML "Build with coreml support" OFF)
 
 if(USE_CPP_RPC AND UNIX)
   message(FATAL_ERROR "USE_CPP_RPC is only supported with WIN32. Use the 
Makefile for non-Windows.")
@@ -301,6 +302,7 @@ include(cmake/modules/contrib/NNPack.cmake)
 include(cmake/modules/contrib/HybridDump.cmake)
 include(cmake/modules/contrib/TFLite.cmake)
 include(cmake/modules/contrib/TF_TVMDSOOP.cmake)
+include(cmake/modules/contrib/CoreML.cmake)
 
 if(NOT MSVC)
   include(CheckCXXCompilerFlag)
diff --git a/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj 
b/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
index f635d2c..0c08490 100644
--- a/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
+++ b/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
@@ -249,7 +249,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
-   shellScript = 
"libpath=${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Frameworks/tvm\nmkdir
 -p ${libpath}\nrm -rf ${libpath}/*\n  \nif [ -f 
${SRCROOT}/rpc_config.txt ]; then\nhead -n 1 ${SRCROOT}/rpc_config.txt > 
${libpath}/rpc_config.txt\ntail -n +2 ${SRCROOT}/rpc_config.txt | xargs -J 
% cp % ${libpath}\nfi\n\n";
+   shellScript = 
"libpath=${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Frameworks/tvm\nmkdir
 -p ${libpath}\nrm -rf ${libpath}/*\n  \nif [ -f 
${SRCROOT}/rpc_config.txt ]; then\nhead -n 1 ${SRCROOT}/rpc_config.txt > 
${libpath}/rpc_config.txt\ntail -n +2 ${SRCROOT}/rpc_config.txt | xargs -J 
% cp -r % ${libpath}\nfi\n\n";
};
 /* End PBXShellScriptBuildPhase section */
 
diff --git a/apps/ios_rpc/tvmrpc/TVMRuntime.mm 
b/apps/ios_rpc/tvmrpc/TVMRuntime.mm
index d593eef..0402e30 100644
--- a/apps/ios_rpc/tvmrpc/TVMRuntime.mm
+++ b/apps/ios_rpc/tvmrpc/TVMRuntime.mm
@@ -46,6 +46,8 @@
 // Metal
 #include "../../../src/runtime/metal/metal_module.mm"
 #include "../../../src/runtime/metal/metal_device_api.mm"
+// CoreML
+#include "../../../src/runtime/contrib/coreml/coreml_runtime.mm"
 
 namespace dmlc {
 // Override logging mechanism
diff --git a/cmake/modules/contrib/CoreML.cmake 
b/cmake/modules/contrib/CoreML.cmake
new file mode 100644
index 000..a61e9f6
--- /dev/null
+++ b/cmake/modules/contrib/CoreML.cmake
@@ -0,0 +1,25 @@
+# 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.
+
+if(USE_COREML)
+  message(STATUS "Build with contrib.core

[incubator-tvm] branch master updated (12e737f -> 3f33b25)

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

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


from 12e737f  Make "none" DataType explicit (#5491)
 add 3f33b25  [Hexagon] Change "scalar" and "stack" in IDL from "inrout" to 
"in" (#5487)

No new revisions were added by this update.

Summary of changes:
 src/runtime/hexagon/target/fastrpc/include/tvm_remote.idl| 4 ++--
 src/runtime/hexagon/target/fastrpc/include/tvm_remote_nd.idl | 4 ++--
 src/runtime/hexagon/target/fastrpc/src/tvm_remote_imp.cc | 4 ++--
 src/runtime/hexagon/target/fastrpc/src/tvm_remote_nd_imp.cc  | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)



[incubator-tvm] branch master updated (3f33b25 -> 967d731)

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

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


from 3f33b25  [Hexagon] Change "scalar" and "stack" in IDL from "inrout" to 
"in" (#5487)
 add 967d731  [MXNET]broadcast and logical op support (#5461)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/mxnet.py  | 37 ++-
 tests/python/frontend/mxnet/test_forward.py | 71 +
 2 files changed, 97 insertions(+), 11 deletions(-)



[incubator-tvm] branch master updated (90b08f5 -> 095f565)

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

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


from 90b08f5  [intrin] a few more math functions (#5468)
 add 095f565  [FRONTEND][TFLITE]Logical not op support (#5475)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 11 +++
 tests/python/frontend/tflite/test_forward.py | 12 +++-
 2 files changed, 22 insertions(+), 1 deletion(-)



[incubator-tvm] branch master updated: [Frontend][TFLite] support for FILL and SPLIT_V operators (#5330)

2020-04-29 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 063ba63  [Frontend][TFLite] support for FILL and SPLIT_V operators 
(#5330)
063ba63 is described below

commit 063ba63a4448432a1e17ec8b793152cd8bba7c2c
Author: Mahesh Ambule <15611578+maheshamb...@users.noreply.github.com>
AuthorDate: Wed Apr 29 16:21:57 2020 +0530

[Frontend][TFLite] support for FILL and SPLIT_V operators (#5330)

* tflite spliv ops

* TFLITE fill and splitv ops

* TFLITE fill and splitv ops

* TFLITE fill and splitv ops

* remove unnecessary operator check
---
 python/tvm/relay/frontend/tflite.py  | 46 ++
 tests/python/frontend/tflite/test_forward.py | 57 
 2 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index 2065d60..b9a1657 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -78,6 +78,7 @@ class OperatorConverter(object):
 'ELU': self.convert_elu,
 'EQUAL': self.convert_equal,
 'EXP': self.convert_exp,
+'FILL': self.convert_fill,
 'FLOOR_DIV': self.convert_floor_div,
 'FLOOR_MOD': self.convert_floor_mod,
 'FLOOR': self.convert_floor,
@@ -123,6 +124,7 @@ class OperatorConverter(object):
 'SPACE_TO_BATCH_ND': self.convert_space_to_batch_nd,
 'SPACE_TO_DEPTH': self.convert_space_to_depth,
 'SPLIT': self.convert_split,
+'SPLIT_V': self.convert_split_v,
 'SQRT': self.convert_sqrt,
 'SQUARE': self.convert_square,
 'SQUARED_DIFFERENCE': self.convert_squared_difference,
@@ -1212,6 +1214,21 @@ class OperatorConverter(object):
 
 return out
 
+def convert_fill(self, op):
+"""Convert TFLite FILL"""
+input_tensors = self.get_input_tensors(op)
+assert len(input_tensors) == 2, "input tensors length should be 2"
+
+if self.has_expr(input_tensors[0].tensor_idx):
+raise tvm.error.OpNotImplemented("For dims parameter of Fill 
operator,"
+ " only constant values are 
supported.")
+
+in_dims = list(self.get_tensor_value(input_tensors[0]))
+in_value_expr = self.get_expr(input_tensors[1].tensor_idx)
+out = _op.full(in_value_expr, in_dims)
+
+return out
+
 def _convert_reduce(self, relay_op, op):
 """Generic method to Convert TFLite MEAN operators"""
 try:
@@ -1617,6 +1634,35 @@ class OperatorConverter(object):
 
 return out
 
+def convert_split_v(self, op):
+"""SPLIT_V implementation."""
+input_tensors = self.get_input_tensors(op)
+
+assert len(input_tensors) == 3, "input tensors length should be 3"
+
+input_tensor = input_tensors[0]
+input_tensor_idx = input_tensor.tensor_idx
+in_expr = self.get_expr(input_tensor_idx)
+
+if self.has_expr(input_tensors[1].tensor_idx):
+raise tvm.error.OpNotImplemented("For size_splits parameter of 
SPLIT_V operator, "
+ "only constant values are 
supported.")
+size_splits = list(self.get_tensor_value(input_tensors[1]))
+size_splits = tuple(np.cumsum(size_splits)[:-1])
+
+axis_tensor = input_tensors[2]
+split_axis = self.get_tensor_value(axis_tensor)
+
+out = _op.split(in_expr, size_splits, axis=int(split_axis))
+# Relay does not like a TupleWrapper of 1 element, further this
+# only shows up with tf1.13 if we use a split with num_splits==1.
+# In tf 1.14 this doesn't appear as it is automatically a reshape
+# operation.
+if isinstance(out, _expr.TupleWrapper) and out.size == 1:
+out = out[0]
+
+return out
+
 def convert_slice(self, op):
 """Convert TFLite SLICE"""
 input_tensors = self.get_input_tensors(op)
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index eb65d82..7ff4c31 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -216,15 +216,19 @@ def with_fused_activation_function(input_tensor, fn_name):
 return math_ops.tanh(input_tensor)
 raise AssertionError("Unknown fused_activation_function 
{}".format(fn_name))
 
-def _test_split(in_shape, axis, num_Splits, dtype):
-'''internal split tester taking as param

[incubator-tvm] branch master updated (900254d -> 149965a)

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

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


from 900254d  Fix an issue with Upsampling and update one test to hit the 
broken usecase (#5530)
 add 149965a  [TFLITE]Select op support for tflite frontend (#5486)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 28 
 tests/python/frontend/tflite/test_forward.py | 22 ++
 2 files changed, 50 insertions(+)



[incubator-tvm] branch master updated: [TOPI][Winograd] Optimization of Conv2d Winograd algorithm on Tensor Core (#5485)

2020-05-07 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 e40b8bc  [TOPI][Winograd] Optimization of Conv2d Winograd algorithm on 
Tensor Core (#5485)
e40b8bc is described below

commit e40b8bc9e1229d8ee9d0228d5dbdc2338fd8677d
Author: wsl-inspur <61525780+wsl-ins...@users.noreply.github.com>
AuthorDate: Thu May 7 18:46:45 2020 +0800

[TOPI][Winograd] Optimization of Conv2d Winograd algorithm on Tensor Core 
(#5485)
---
 python/tvm/relay/op/strategy/cuda.py   |  78 ++-
 topi/python/topi/cuda/__init__.py  |   1 +
 topi/python/topi/cuda/conv2d_alter_op.py   |  36 ++
 topi/python/topi/cuda/conv2d_nhwc_winograd.py  | 639 +
 .../tests/python/test_topi_conv2d_nhwc_winograd.py | 152 +
 5 files changed, 904 insertions(+), 2 deletions(-)

diff --git a/python/tvm/relay/op/strategy/cuda.py 
b/python/tvm/relay/op/strategy/cuda.py
index 9189b5e..83e4e40 100644
--- a/python/tvm/relay/op/strategy/cuda.py
+++ b/python/tvm/relay/op/strategy/cuda.py
@@ -136,8 +136,32 @@ def conv2d_strategy_cuda(attrs, inputs, out_type, target):
 wrap_compute_conv2d(topi.cuda.conv2d_nhwc),
 wrap_topi_schedule(topi.cuda.schedule_conv2d_nhwc),
 name="conv2d_nhwc.cuda")
-N, _, _, _ = get_const_tuple(data.shape)
-_, _, CI, CO = get_const_tuple(kernel.shape)
+N, H, W, _ = get_const_tuple(data.shape)
+KH, KW, CI, CO = get_const_tuple(kernel.shape)
+# Winograd shape related judgment
+judge_winograd_tensorcore, judge_winograd_shape = 
winograd_judge(N, H, W, KH, KW,
+ 
CI, CO, padding,
+ 
stride_h, stride_w,
+ 
dilation_h, dilation_w,
+ 
pre_flag=False)
+if judge_winograd_shape:
+if target.target_name == "cuda" and \
+nvcc.have_tensorcore(tvm.gpu(0).compute_version) and \
+judge_winograd_tensorcore:
+strategy.add_implementation(
+
wrap_compute_conv2d(topi.cuda.conv2d_nhwc_winograd_tensorcore),
+wrap_topi_schedule(
+
topi.cuda.schedule_conv2d_nhwc_winograd_tensorcore),
+name="conv2d_nhwc_winograd_tensorcore.cuda",
+plevel=5)
+else:
+strategy.add_implementation(
+wrap_compute_conv2d(
+topi.cuda.conv2d_nhwc_winograd_direct),
+wrap_topi_schedule(
+topi.cuda.schedule_conv2d_nhwc_winograd_direct),
+name="conv2d_nhwc_winograd_direct.cuda",
+plevel=5)
 if target.target_name == "cuda":
 if nvcc.have_tensorcore(tvm.gpu(0).compute_version):
 if (N % 16 == 0 and CI % 16 == 0 and CO % 16 == 0) or \
@@ -220,6 +244,9 @@ def 
conv2d_winograd_without_weight_transfrom_strategy_cuda(attrs, inputs, out_ty
 dilation = attrs.get_int_tuple("dilation")
 groups = attrs.get_int("groups")
 layout = attrs.data_layout
+data, kernel = inputs
+stride_h, stride_w = attrs.get_int_tuple("strides")
+padding = attrs.get_int_tuple("padding")
 assert dilation == (1, 1), "Do not support dilate now"
 assert groups == 1, "Do not supoort arbitrary group number"
 strategy = _op.OpStrategy()
@@ -229,6 +256,30 @@ def 
conv2d_winograd_without_weight_transfrom_strategy_cuda(attrs, inputs, out_ty
 wrap_topi_schedule(
 
topi.cuda.schedule_conv2d_nchw_winograd_without_weight_transform),
 name="conv2d_nchw_winograd_without_weight_transform.cuda")
+elif layout == "NHWC":
+N, H, W, _ = get_const_tuple(data.shape)
+alpha, _, CI, CO = get_const_tuple(kernel.shape)
+dilation_h, dilation_w = dilation
+judge_winograd_tensorcore, _ = winograd_judge(N, H, W, alpha, alpha, 
CI, CO,
+  padding, stride_h, 
stride_w,
+  dilation_h, dilation_w,
+  pre_flag=True)
+if target.target_name == "cuda" and \
+nvcc.have_tensorcore(tvm.gp

[incubator-tvm] branch master updated: [FRONTEND][TFLite] Fully connected op conversion made in sync with TFLite (#5510)

2020-05-07 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 b3730e5   [FRONTEND][TFLite] Fully connected op conversion made in 
sync with TFLite (#5510)
b3730e5 is described below

commit b3730e575ac0ab4a54fe6984bde35408e93b5e6f
Author: ANSHUMAN TRIPATHY 
AuthorDate: Thu May 7 16:06:20 2020 +0530

 [FRONTEND][TFLite] Fully connected op conversion made in sync with TFLite 
(#5510)

* [FRONTEND][TFLite] Fully connected op conversion made in sync with TFLite

* [1] Test case added

* [2] Review comments handled

* [3] Prints removed
---
 python/tvm/relay/frontend/tflite.py  | 33 
 tests/python/frontend/tflite/test_forward.py | 26 ++
 2 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index a55a57f..bb456f1 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -1331,16 +1331,28 @@ class OperatorConverter(object):
 input_tensor_shape = input_tensor.tensor.ShapeAsNumpy()
 weight_tensor_shape = weight_tensor.tensor.ShapeAsNumpy()
 
-# reshape input tensor from N H W C to N H*W*C
-input_size_per_batch = 1
-for s in range(1, len(input_tensor_shape)):
-input_size_per_batch *= input_tensor_shape[s]
-assert input_size_per_batch == weight_tensor_shape[1], \
-"input size and weight size are mismatched"
-target_shape = tuple((input_tensor_shape[0], input_size_per_batch))
+# Weight should have only 2 dimensions(TFLite convention)
+assert len(weight_tensor_shape) == 2, "Weight should be only 2-dim"
+
+# Input shape: [i_batch_size, ..., n_inputs]
+# Filter shape: [n_inputs, n_units]
+#
+# As we will transform Fully_Connected Input to Dense Op inputs as 
below
+# Dense expected Input shape: [batch_size, n_units]
+# Dense expected Weight shape: [out_dim, n_units]
+# Dense output shape: [batch_size, out_dim]
+# So it is evident that input shape: [batch_size = input_size / 
n_units, n_units]
+input_size = 1
+for _, shape in enumerate(input_tensor_shape):
+input_size *= shape
+
+# First get the batch size
+batch_size = int(input_size / weight_tensor_shape[1])
+target_shape = tuple((batch_size, weight_tensor_shape[1]))
 in_expr = self.get_expr(input_tensor_idx)
 in_expr = _op.reshape(in_expr, target_shape)
 
+#TODO: Change the output shape calculation based on keep_dim option
 assert op.BuiltinOptionsType() == BuiltinOptions.FullyConnectedOptions
 op_options = op.BuiltinOptions()
 fully_connected_options = FullyConnectedOptions()
@@ -1352,8 +1364,11 @@ class OperatorConverter(object):
 assert weight_tensor_type in (TensorType.UINT8, TensorType.FLOAT32)
 weight_tensor_type_str = self.get_tensor_type_str(weight_tensor_type)
 
-weight_value = self.get_tensor_value(weight_tensor)
-weight_expr = self.exp_tab.new_const(weight_value, 
dtype=weight_tensor_type_str)
+if self.has_expr(weight_tensor.tensor_idx):
+weight_expr = self.get_expr(weight_tensor.tensor_idx)
+else:
+weight_value = self.get_tensor_value(weight_tensor)
+weight_expr = self.exp_tab.new_const(weight_value, 
dtype=weight_tensor_type_str)
 weight_shape = _infer_shape(weight_expr)
 
 if input_tensor.qnn_params:
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index 7257748..20a077f 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -420,6 +420,29 @@ def test_forward_cast():
 _test_cast(np.arange(6.0, dtype=np.int32).reshape((1, 6)), 
cast_dtype=tf.int64)
 
 ###
+# Batch Mat Mul
+# 
+def _test_batch_matmul(A_shape, B_shape, dtype, adjoint_a=False, 
adjoint_b=False):
+with tf.Graph().as_default():
+A = array_ops.placeholder(shape=A_shape, dtype=dtype, name='A')
+B = array_ops.placeholder(shape=B_shape, dtype=dtype, name='B')
+result = math_ops.matmul(A, B, adjoint_a=adjoint_a,
+   adjoint_b=adjoint_b, name='batchmatmul')
+
+A_np = np.random.uniform(high=5.0, size=A_shape).astype(dtype)
+B_np = np.random.uniform(high=5.0, size=B_shape).astype(dtype)
+compare_tflite_with_tvm([A_np, B_np], [A.name, B.name], [A, B], 
[result])
+
+
+def test_forward_batch_matmul():
+""" BATCH_MAT_MUL """
+   

[incubator-tvm] branch master updated: [RUNTIME] Hexagon driver for offloading kernels to simulator (#5492)

2020-05-10 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 29ae608  [RUNTIME] Hexagon driver for offloading kernels to simulator 
(#5492)
29ae608 is described below

commit 29ae608baabb673fb0b2d3ced9321f0e1798f72e
Author: Krzysztof Parzyszek 
AuthorDate: Sun May 10 22:05:59 2020 -0500

[RUNTIME] Hexagon driver for offloading kernels to simulator (#5492)

* [RUNTIME] Hexagon driver for offloading kernels to simulator

* Add sim_dev as external project when building with Hexagon/sim support

* Change target CPU for sim_dev to v60
---
 cmake/modules/Hexagon.cmake|   9 +
 src/runtime/hexagon/sim/driver/CMakeLists.txt  |  62 +++
 src/runtime/hexagon/sim/driver/README.md   |  38 ++
 src/runtime/hexagon/sim/driver/fake_pthread.cc | 292 +
 src/runtime/hexagon/sim/driver/pthread.h   |  96 +
 src/runtime/hexagon/sim/driver/sched.h |  31 ++
 src/runtime/hexagon/sim/driver/sim_device.cc   | 573 +
 src/runtime/threading_backend.cc   |  11 +
 8 files changed, 1112 insertions(+)

diff --git a/cmake/modules/Hexagon.cmake b/cmake/modules/Hexagon.cmake
index e70a964..30b4ccb 100644
--- a/cmake/modules/Hexagon.cmake
+++ b/cmake/modules/Hexagon.cmake
@@ -15,6 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
+include(ExternalProject)
+
 set(PICK_SIM  "sim")
 set(PICK_HW   "target")
 set(PICK_NONE "OFF")
@@ -77,6 +79,13 @@ if(USE_HEXAGON_DEVICE STREQUAL "${PICK_SIM}")
   include_directories("${HEXAGON_TOOLCHAIN}/include/iss")
   link_directories("${HEXAGON_TOOLCHAIN}/lib/iss")
   list(APPEND TVM_RUNTIME_LINKER_LIBS "-lwrapper")
+  ExternalProject_Add(sim_dev
+SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/runtime/hexagon/sim/driver"
+CMAKE_ARGS
+  "-DCMAKE_C_COMPILER=${HEXAGON_TOOLCHAIN}/bin/hexagon-clang"
+  "-DCMAKE_CXX_COMPILER=${HEXAGON_TOOLCHAIN}/bin/hexagon-clang++"
+INSTALL_COMMAND "true"
+  )
 elseif(USE_HEXAGON_DEVICE STREQUAL "${PICK_HW}")
   find_hexagon_sdk_root()
   find_hexagon_toolchain()
diff --git a/src/runtime/hexagon/sim/driver/CMakeLists.txt 
b/src/runtime/hexagon/sim/driver/CMakeLists.txt
new file mode 100644
index 000..8632b49
--- /dev/null
+++ b/src/runtime/hexagon/sim/driver/CMakeLists.txt
@@ -0,0 +1,62 @@
+# 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.
+
+project(SIM_DEV C CXX)
+cmake_minimum_required(VERSION 3.0.2)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
+  include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
+endif()
+
+set(EXTRA_CXX_FLAGS
+  "-O2"
+  "-Wno-format"
+  "-mhvx -mhvx-length=128b"
+  "-mv60"
+  "-stdlib=libc++"
+)
+
+set(EXTRA_LINK_FLAGS
+  "-stdlib=libc++"
+  "-G0"
+  "-Wl,--force-dynamic"
+  "-Wl,--export-dynamic"
+  "-Wl,--whole-archive"   # This should link entire libc, libc++ and libc+abi.
+  "-Wl,--defsym=HEAP_SIZE=0x4000"
+)
+
+string(REGEX REPLACE ";" " " EXTRA_CXX_FLAGS_STR "${EXTRA_CXX_FLAGS}")
+string(REGEX REPLACE ";" " " EXTRA_LINK_FLAGS_STR "${EXTRA_LINK_FLAGS}")
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_FLAGS "${EXTRA_CXX_FLAGS_STR} ${CMAKE_CXX_FLAGS}")
+set(CMAKE_EXE_LINKER_FLAGS "${EXTRA_LINK_FLAGS_STR} ${CMAKE_EXE_LINKER_FLAGS}")
+
+# Set project properties.
+
+file(GLOB SOURCE_FILES "*.cc")
+add_executable(sim_dev ${SOURCE_FILES})
+target_include_directories(sim_dev
+  PUBLIC "."
+  PUBLIC ".."
+  PUBLIC "../../../../../include"
+  PUBLIC "../../../../../3rdparty/dlpack/include"
+)
+
+target_link_libraries(sim_dev "-ldl")
diff --git a/src/runtime/hexagon/sim/driver/README.md 
b/src/runtime/hexagon/sim/driver/README.md
ne

[incubator-tvm] branch master updated (c3b89b7 -> c3ec96e)

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

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


from c3b89b7  [CODEGEN][OPENCL] Explicitly cast min/max operands (#5090)
 add c3ec96e  Description updated for pooling attributes (#5091)

No new revisions were added by this update.

Summary of changes:
 include/tvm/relay/attrs/nn.h | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)



[incubator-tvm] branch master updated (36a83c7 -> 050f2bd)

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

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


from 36a83c7  [docs] Update relay docs (#5112)
 add 050f2bd  [KERAS] conv3d frontend operator support (#5080)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/keras.py  | 89 +++--
 tests/python/frontend/keras/test_forward.py | 23 
 2 files changed, 106 insertions(+), 6 deletions(-)



[incubator-tvm] branch master updated: Add BN support with run-time mean and variance calculation (#4990)

2020-03-07 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 ba47786  Add BN support with run-time mean and variance calculation 
(#4990)
ba47786 is described below

commit ba477865c0e52778dcb0a07ba84cbe8488cd0719
Author: lfengad 
AuthorDate: Sun Mar 8 12:46:12 2020 +0800

Add BN support with run-time mean and variance calculation (#4990)
---
 python/tvm/relay/frontend/tensorflow.py| 10 ++-
 .../python/frontend/tensorflow/test_bn_dynamic.py  | 72 ++
 2 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/python/tvm/relay/frontend/tensorflow.py 
b/python/tvm/relay/frontend/tensorflow.py
index 24164a3..f1cb815 100644
--- a/python/tvm/relay/frontend/tensorflow.py
+++ b/python/tvm/relay/frontend/tensorflow.py
@@ -877,6 +877,7 @@ def _fused_batch_norm():
 def _impl(inputs, attr, params):
 # Tensorflow: (data, gamma, beta, moving_mean, moving_variance)
 # Relay:   (data, gamma, beta, moving_mean, moving_varience)
+assert len(inputs) == 5
 axis = 3
 need_cast = False
 
@@ -887,7 +888,14 @@ def _fused_batch_norm():
 if 'U' in attr:
 need_cast = True
 inputs[0] = _op.cast(inputs[0], dtype=attr['U'].name)
-
+# Check if mean and variance are empty
+# If so, replace them with Mean and Variance Ops
+# For run-time calculation
+moving_mean_shape = [int(n) for n in inputs[3].type_annotation.shape]
+moving_variance_shape = [int(n) for n in 
inputs[4].type_annotation.shape]
+if (moving_mean_shape[0] == 0 and moving_variance_shape[0] == 0):
+inputs[3] = _op.mean(inputs[0], axis=axis, keepdims=False, 
exclude=True)
+inputs[4] = _op.variance(inputs[0], axis=axis, keepdims=False, 
exclude=True)
 out = AttrCvt(op_name='batch_norm',
   transforms={'scale_after_normalization':'scale',
   'variance_epsilon':'epsilon'},
diff --git a/tests/python/frontend/tensorflow/test_bn_dynamic.py 
b/tests/python/frontend/tensorflow/test_bn_dynamic.py
new file mode 100644
index 000..4be838e
--- /dev/null
+++ b/tests/python/frontend/tensorflow/test_bn_dynamic.py
@@ -0,0 +1,72 @@
+# 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.
+"""
+BatchNorm without given mean and variance given testcases
+
+This is a test script to test fused_batch_norm operators
+in TensorFlow frontend when mean and variance are not given.
+"""
+import tvm
+import numpy as np
+import tensorflow as tf
+from tvm import relay
+from tensorflow.python.framework import graph_util
+
+def verify_fused_batch_norm(shape):
+g = tf.Graph()
+with g.as_default():
+input_tensor = tf.placeholder(tf.float32, shape=shape, name='input')
+alpha = tf.constant(np.random.rand(shape[-1],), dtype=tf.float32, 
name='alpha')
+beta = tf.constant(np.random.rand(shape[-1],), dtype=tf.float32, 
name='beta')
+bn = tf.nn.fused_batch_norm(x=input_tensor, offset=beta, scale=alpha, 
name='bn')
+out = tf.identity(bn[0], name='output')
+data = np.random.rand(*shape)
+with tf.Session(graph=out.graph) as sess:
+sess.run([tf.global_variables_initializer()])
+tf_out = sess.run(out, feed_dict={input_tensor:data})
+constant_graph = graph_util.convert_variables_to_constants(sess, 
sess.graph_def, ['output'])
+
+for device in ["llvm"]:
+ctx = tvm.context(device, 0)
+if not ctx.exist:
+print("Skip because %s is not enabled" % device)
+continue
+mod, params = relay.frontend.from_tensorflow(constant_graph,
+ outputs=['output'])
+with relay.build_config(opt_level=3):
+graph, lib, params = relay.build(mod,
+ target=device,
+ params=params)
+from tvm.contrib 

[incubator-tvm] branch master updated: Changes to cpp_rpc to make it work on Android (+ Hexagon offloading) (#5535)

2020-05-07 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 1b17b73  Changes to cpp_rpc to make it work on Android (+ Hexagon 
offloading) (#5535)
1b17b73 is described below

commit 1b17b73b9310976fc95e1a6af871c5cdc0c0a346
Author: Krzysztof Parzyszek 
AuthorDate: Thu May 7 22:36:36 2020 -0500

Changes to cpp_rpc to make it work on Android (+ Hexagon offloading) (#5535)

* Changes to cpp_rpc to make it work on Android (+ Hexagon offloading)

- Implement getNextString to break up std::string into words. stringstream
  just doesn't work on Android.
- string::find_last_of doesn't look for the last substring, but the
  last character from a given string.
- Use SIGTERM to terminate processes (this isn't necessary, but using
  SIGKILL is not a good practice).
- Convert "./rpc" to a full path. When a module is uploaded and offloaded
  to Hexagon, the dlopen on Hexagon needs an absolute path (or a path
  without directories).

* Only set the absolute patch on non-Windows platforms

Windows has different macros for the maximum path length.
---
 apps/cpp_rpc/rpc_env.cc| 10 ++
 apps/cpp_rpc/rpc_server.cc | 34 ++
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/apps/cpp_rpc/rpc_env.cc b/apps/cpp_rpc/rpc_env.cc
index b5dc51b..4a363cb 100644
--- a/apps/cpp_rpc/rpc_env.cc
+++ b/apps/cpp_rpc/rpc_env.cc
@@ -67,7 +67,17 @@ namespace {
 namespace tvm {
 namespace runtime {
 RPCEnv::RPCEnv() {
+#ifndef _WIN32
+  char cwd[PATH_MAX];
+  if (char *rc = getcwd(cwd, sizeof(cwd))) {
+base_ = std::string(cwd) + "/rpc";
+  } else {
+base_ = "./rpc";
+  }
+#else
   base_ = "./rpc";
+#endif
+
   mkdir(base_.c_str(), 0777);
   TVM_REGISTER_GLOBAL("tvm.rpc.server.workpath").set_body([](TVMArgs args, 
TVMRetValue* rv) {
 static RPCEnv env;
diff --git a/apps/cpp_rpc/rpc_server.cc b/apps/cpp_rpc/rpc_server.cc
index 57a68f4..2c8bdfa 100644
--- a/apps/cpp_rpc/rpc_server.cc
+++ b/apps/cpp_rpc/rpc_server.cc
@@ -66,6 +66,22 @@ static pid_t waitPidEintr(int* status) {
 }
 #endif
 
+#ifdef __ANDROID__
+static std::string getNextString(std::stringstream* iss) {
+  std::string str = iss->str();
+  size_t start = iss->tellg();
+  size_t len = str.size();
+  // Skip leading spaces.
+  while (start < len && isspace(str[start])) start++;
+
+  size_t end = start;
+  while (end < len && !isspace(str[end])) end++;
+
+  iss->seekg(end);
+  return str.substr(start, end-start);
+}
+#endif
+
 /*!
  * \brief RPCServer RPC Server class.
  * \param host The hostname of the server, Default=0.0.0.0
@@ -164,9 +180,9 @@ class RPCServer {
 int status = 0;
 const pid_t finished_first = waitPidEintr();
 if (finished_first == timer_pid) {
-  kill(worker_pid, SIGKILL);
+  kill(worker_pid, SIGTERM);
 } else if (finished_first == worker_pid) {
-  kill(timer_pid, SIGKILL);
+  kill(timer_pid, SIGTERM);
 } else {
   LOG(INFO) << "Child pid=" << finished_first << " unexpected, but 
still continue.";
 }
@@ -260,7 +276,12 @@ class RPCServer {
 
   std::stringstream ssin(remote_key);
   std::string arg0;
+#ifndef __ANDROID__
   ssin >> arg0;
+#else
+  arg0 = getNextString();
+#endif
+
   if (arg0 != expect_header) {
 code = kRPCMismatch;
 CHECK_EQ(conn.SendAll(, sizeof(code)), sizeof(code));
@@ -274,7 +295,11 @@ class RPCServer {
 CHECK_EQ(conn.SendAll(, sizeof(keylen)), sizeof(keylen));
 CHECK_EQ(conn.SendAll(server_key.c_str(), keylen), keylen);
 LOG(INFO) << "Connection success " << addr->AsString();
+#ifndef __ANDROID__
 ssin >> *opts;
+#else
+*opts = getNextString();
+#endif
 *conn_sock = conn;
 return;
   }
@@ -301,8 +326,9 @@ class RPCServer {
   int GetTimeOutFromOpts(const std::string& opts) const {
 const std::string option = "-timeout=";
 
-if (opts.find(option) == 0) {
-  const std::string cmd = opts.substr(opts.find_last_of(option) + 1);
+size_t pos = opts.rfind(option);
+if (pos != std::string::npos) {
+  const std::string cmd = opts.substr(pos + option.size());
   CHECK(support::IsNumber(cmd)) << "Timeout is not valid";
   return std::stoi(cmd);
 }



[incubator-tvm] branch master updated (2b02d56 -> 786dfb6)

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

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


from 2b02d56  [RUNTIME] Store nullptr PackedFunc as nullptr for better 
error propagation (#5540)
 add 786dfb6  [Relay-TFLite] FP32 and Quantized Object Detection Model 
(#5479)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py| 289 +++--
 python/tvm/relay/frontend/tflite_flexbuffer.py | 152 +
 python/tvm/relay/testing/tf.py |   7 +-
 tests/python/frontend/tflite/test_forward.py   | 144 ++--
 4 files changed, 415 insertions(+), 177 deletions(-)
 create mode 100644 python/tvm/relay/frontend/tflite_flexbuffer.py



[incubator-tvm] branch master updated (82289ea -> 8369adc)

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

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


from 82289ea  [TVMC] fail gracefully in case no subcommand is provided 
(#6625)
 add 8369adc  Add dot product support for quantized convolution. (#6445)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/op/strategy/arm_cpu.py   |  44 +++-
 python/tvm/topi/arm_cpu/arm_utils.py  | 100 
 python/tvm/topi/arm_cpu/conv2d_alter_op.py| 105 +---
 python/tvm/topi/arm_cpu/conv2d_gemm.py| 283 ++--
 python/tvm/topi/arm_cpu/conv2d_int8.py| 120 +++--
 python/tvm/topi/arm_cpu/tensor_intrin.py  | 298 +-
 tests/python/relay/test_pass_alter_op_layout.py   |   2 +-
 tests/python/topi/python/test_topi_conv2d_int8.py | 105 
 8 files changed, 874 insertions(+), 183 deletions(-)
 create mode 100644 python/tvm/topi/arm_cpu/arm_utils.py



[incubator-tvm] branch master updated (883a28d -> 617949d)

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

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


from 883a28d  save (#6338)
 add 617949d  Use auto-tuner to improve conv2d_gemm performance (#6117)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/arm_cpu/conv2d_gemm.py   |  64 --
 python/tvm/topi/arm_cpu/conv2d_int8.py   |   2 +
 python/tvm/topi/arm_cpu/tensor_intrin.py | 379 +++
 3 files changed, 290 insertions(+), 155 deletions(-)



[incubator-tvm] branch master updated: [TEST] use rpc.LocalSession for simple tests (#6294)

2020-08-17 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 d2e15c3  [TEST] use rpc.LocalSession for simple tests (#6294)
d2e15c3 is described below

commit d2e15c320d5e121b1ee42adbb54a691bd4c08078
Author: Tianqi Chen 
AuthorDate: Mon Aug 17 22:50:57 2020 -0700

[TEST] use rpc.LocalSession for simple tests (#6294)

To avoid flaky due to networking.
---
 tests/python/unittest/test_runtime_module_based_interface.py | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tests/python/unittest/test_runtime_module_based_interface.py 
b/tests/python/unittest/test_runtime_module_based_interface.py
index f97a445..56ae250 100644
--- a/tests/python/unittest/test_runtime_module_based_interface.py
+++ b/tests/python/unittest/test_runtime_module_based_interface.py
@@ -206,8 +206,7 @@ def test_mod_export():
 complied_graph_lib.export_library(path_lib)
 
 from tvm import rpc
-server = rpc.Server("localhost", use_popen=True, port=9093)
-remote = rpc.connect(server.host, server.port)
+remote = rpc.LocalSession()
 remote.upload(path_lib)
 loaded_lib = remote.load_module(path_lib)
 data = np.random.uniform(-1, 1, 
size=input_shape(mod)).astype("float32")
@@ -395,8 +394,7 @@ def test_remove_package_params():
 fo.write(relay.save_param_dict(complied_graph_lib.get_params()))
 
 from tvm import rpc
-server = rpc.Server("localhost", use_popen=True, port=9095)
-remote = rpc.connect(server.host, server.port)
+remote = rpc.LocalSession()
 remote.upload(path_lib)
 loaded_lib = remote.load_module(path_lib)
 data = np.random.uniform(-1, 1, 
size=input_shape(mod)).astype("float32")
@@ -447,8 +445,7 @@ def test_remove_package_params():
 fo.write(relay.save_param_dict(complied_graph_lib.get_params()))
 
 from tvm import rpc
-server = rpc.Server("localhost", use_popen=True, port=9092)
-remote = rpc.connect(server.host, server.port)
+remote = rpc.LocalSession()
 remote.upload(path_lib)
 loaded_lib = remote.load_module(path_lib)
 data = np.random.uniform(-1, 1, 
size=input_shape(mod)).astype("float32")



[incubator-tvm] branch master updated: [Hexagon] Initial support for Hexagon codegen (#6261)

2020-08-19 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 7aa2de3  [Hexagon] Initial support for Hexagon codegen (#6261)
7aa2de3 is described below

commit 7aa2de31157ef11b43c38ccba5bf9c9539406abf
Author: Krzysztof Parzyszek 
AuthorDate: Wed Aug 19 04:17:07 2020 -0500

[Hexagon] Initial support for Hexagon codegen (#6261)

* [Hexagon] Initial support for Hexagon codegen

This commit does not support parallel execution or prefetch.
LLVM 7 or later is required.

* Set native_vector_bits_ based on target features

* Initialize hvx_bytes

* Remove commented out line
---
 python/tvm/contrib/hexagon.py  | 211 ++
 python/tvm/target/target.py|  22 +-
 src/runtime/hexagon/hexagon_module.cc  |  22 +-
 src/runtime/module.cc  |   2 +
 src/target/llvm/codegen_hexagon.cc | 812 +
 src/target/llvm/intrin_rule_hexagon.cc |  65 ++
 src/target/target_kind.cc  |   4 +
 .../python/unittest/test_target_codegen_hexagon.py |  95 +++
 8 files changed, 1225 insertions(+), 8 deletions(-)

diff --git a/python/tvm/contrib/hexagon.py b/python/tvm/contrib/hexagon.py
new file mode 100644
index 000..6870e2a
--- /dev/null
+++ b/python/tvm/contrib/hexagon.py
@@ -0,0 +1,211 @@
+# 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.
+
+'''Utility for Hexagon backend'''
+
+import functools as ft
+import os
+import tvm
+import tvm.ir
+import tvm.contrib.cc as cc
+from .._ffi.registry import register_func
+
+
+# Linking Hexagon shared libraries.
+#
+#   link_shared(name-of-shared-library, list-of-objects, kw-args)
+#
+# To use a custom linker, define a function that returns the path to the
+# linker, and pass it to 'register_linker':
+#
+#   def custom_linker_path():
+#   return '/path/to/hexagon/linker'
+#
+#   register_linker(custom_linker_path)
+#
+# Subsequent calls to 'link_shared' will use the newly registered linker.
+
+hexagon_toolchain_root = os.environ.get('HEXAGON_TOOLCHAIN') or ''  # pylint: 
disable=invalid-name
+hexagon_link_master = os.path.join( # pylint: 
disable=invalid-name
+hexagon_toolchain_root, 'bin', 'hexagon-link')
+
+def register_linker(f):
+"""Register a function that will return the path to the Hexagon linker."""
+return register_func('tvm.contrib.hexagon.hexagon_link', f, True)
+
+@register_func('tvm.contrib.hexagon.hexagon_link')
+def hexagon_link():
+"""Return path to the Hexagon linker."""
+return hexagon_link_master
+
+@register_func('tvm.contrib.hexagon.link_shared')
+def link_shared(so_name, objs, **kwargs):
+"""Link shared library on Hexagon using the registered Hexagon linker.
+
+Parameters
+--
+so_name : str
+Name of the shared library file.
+objs : list[str,StringImm]
+kwargs : additional arguments:
+'verbose' - print additional information
+
+Returns
+---
+ret_val : int
+This function returns 0 at the moment.
+"""
+# The list of object files can be passed as built-in Python strings,
+# or as tvm.tir.StringImm's.
+def to_str(s):
+if isinstance(s, tvm.tir.StringImm):
+return s.value
+assert isinstance(s, str), 'argument "' + str(s) + '" should be a 
string or StrImm'
+return s
+objs = [to_str(s) for s in objs]
+
+linker = tvm.get_global_func('tvm.contrib.hexagon.hexagon_link')()
+if kwargs.get('verbose'):
+print('tvm.contrib.hexagon.link_shared:')
+print('  Using linker:', linker)
+print('  Library name:', so_name)
+print('  Object files:', objs)
+if not os.access(linker, os.X_OK):
+message = 'The linker "' + linker + '" does not exist or is not 
executable.'
+if not 

[incubator-tvm] branch master updated: [Caffe Frontend] introduce caffe frontend for tvm (#6206)

2020-08-26 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 44d97ad  [Caffe Frontend] introduce caffe frontend for tvm (#6206)
44d97ad is described below

commit 44d97ad08002a6e89c6aed6cd9ae242a3e15b222
Author: FernChen 
AuthorDate: Thu Aug 27 11:26:58 2020 +0800

[Caffe Frontend] introduce caffe frontend for tvm (#6206)

* [Caffe Frontend] introduce caffe frontend for tvm.

* [Caffe Frontend] fix bugs for generating caption in tutorial.

* [Caffe Frontend] delete statement for python2 and modify the function 
name.

* [Caffe Frontend] change the directory which will hold the tmp files
when testing the caffe frondend.

* [Caffe Frontend] delete tutorial about caffe frontend.

* [Caffe Frontend] delete some print statements

Co-authored-by: fernchen 
---
 python/tvm/relay/frontend/__init__.py   |   1 +
 python/tvm/relay/frontend/caffe.py  | 848 
 tests/python/frontend/caffe/test_forward.py | 968 
 tests/scripts/task_python_frontend_cpu.sh   |   3 +
 4 files changed, 1820 insertions(+)

diff --git a/python/tvm/relay/frontend/__init__.py 
b/python/tvm/relay/frontend/__init__.py
index aba9eea..7154f5a 100644
--- a/python/tvm/relay/frontend/__init__.py
+++ b/python/tvm/relay/frontend/__init__.py
@@ -33,3 +33,4 @@ from .caffe2 import from_caffe2
 from .tensorflow import from_tensorflow
 from .darknet import from_darknet
 from .pytorch import from_pytorch
+from .caffe import from_caffe
diff --git a/python/tvm/relay/frontend/caffe.py 
b/python/tvm/relay/frontend/caffe.py
new file mode 100644
index 000..b7bcbde
--- /dev/null
+++ b/python/tvm/relay/frontend/caffe.py
@@ -0,0 +1,848 @@
+# 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, unused-argument, too-many-lines, 
import-outside-toplevel
+# pylint: disable=no-else-return, no-else-continue
+"""Caffe frontend."""
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from ... import nd as _nd
+from .common import ExprTable
+from .common import infer_shape as _infer_shape
+
+__all__ = ['from_caffe']
+
+
+class OperatorConverter(object):
+""" Operator Converted for converting Caffe ops to Relay ops """
+def __init__(self, init_layer_dict, predict_layer, exp_tab):
+self.init_layer_dict = init_layer_dict
+self.predict_layer = predict_layer
+self.exp_tab = exp_tab
+self.new_bn = {}
+self.changed_layers = None
+
+self.convert_map = {
+'BatchNorm': self.convert_batch_norm,
+'Concat': self.convert_concat,
+'Convolution': self.convert_conv,
+'Crop': self.convert_crop,
+'Deconvolution': self.convert_deconv,
+'Dropout': self.convert_dropout,
+'Eltwise': self.convert_eltwise,
+'Flatten': self.convert_flatten,
+'InnerProduct': self.convert_innerproduct,
+'Input': None,
+'LRN': self.convert_lrn,
+'Pooling': self.convert_pooling,
+'PReLU': self.convert_prelu,
+'ReLU': self.convert_relu,
+'Reshape': self.convert_reshape,
+'Scale': self.convert_scale,
+'Sigmoid': self.convert_sigmoid,
+'Slice': self.convert_slice,
+'Softmax': self.convert_softmax,
+'TanH': self.convert_tanh,
+}
+
+def convert_flatten(self, op):
+""" Convert Flatten layer """
+inputs = op.bottom
+in_expr = self.exp_tab.get_expr(inputs[0])
+
+flatten_params = op.flatten_param.axis
+assert flatten_params == 1, "flatten axis should be 1"
+out = _op.nn.batch_flatten(in_expr)
+
+return out
+
+def convert_eltwise(self, 

[incubator-tvm] branch master updated: [Relay/TOPI][TFLite] Implemented MATRIX_SET_DIAG Operator for Relay/TOPI and TFLite Frontend. (#6303)

2020-08-26 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 082f27e  [Relay/TOPI][TFLite] Implemented MATRIX_SET_DIAG Operator for 
Relay/TOPI and TFLite Frontend. (#6303)
082f27e is described below

commit 082f27ebf8b14f537f0d7686e8161db1684f3110
Author: Rishabh Jain <56974688+jain...@users.noreply.github.com>
AuthorDate: Thu Aug 27 08:51:45 2020 +0530

[Relay/TOPI][TFLite] Implemented MATRIX_SET_DIAG Operator for Relay/TOPI 
and TFLite Frontend. (#6303)

* Corrected docstring error.

* Minor changes.

* Changed MATRIX_SET_DIAG registration from broadcast to injective.
---
 include/tvm/topi/transform.h| 29 ++
 python/tvm/relay/frontend/tflite.py | 28 ++
 python/tvm/relay/op/_transform.py   |  1 +
 python/tvm/relay/op/transform.py| 41 ++
 python/tvm/topi/testing/__init__.py |  1 +
 python/tvm/topi/testing/matrix_set_diag.py  | 47 
 python/tvm/topi/transform.py| 40 ++
 src/relay/op/tensor/transform.cc| 50 +
 src/topi/transform.cc   |  4 ++
 tests/python/frontend/tflite/test_forward.py| 72 +
 tests/python/relay/test_op_level10.py   | 28 ++
 tests/python/topi/python/test_topi_transform.py | 36 +
 12 files changed, 377 insertions(+)

diff --git a/include/tvm/topi/transform.h b/include/tvm/topi/transform.h
index 19b2ef4..eb69fc5 100644
--- a/include/tvm/topi/transform.h
+++ b/include/tvm/topi/transform.h
@@ -1511,6 +1511,35 @@ inline Tensor sparse_to_dense(const Tensor& 
sparse_indices, const Array
   name, tag);
 }
 
+/*!
+ * \brief Returns a tensor with the diagonal of input tensor replaced with the 
provided diagonal.
+ * \param input input tensor.
+ * \param diagonal values to be filled in the diagonal.
+ * \param name output tensor name.
+ * \param tag output tensor tag.
+ * \return new tensor with given diagonal values.
+ */
+inline Tensor matrix_set_diag(const Tensor& input, const Tensor& diagonal,
+  const std::string name = "T_matrix_set_diag",
+  const std::string tag = kInjective) {
+  size_t ndim = input->shape.size() - 1;
+
+  return compute(
+  input->shape,
+  [&](const Array& iter_vars) {
+auto get_diag = [&]() {
+  Array diagonal_indices;
+  for (size_t i = 0; i < ndim; i++) {
+diagonal_indices.push_back(iter_vars[i]);
+  }
+  return diagonal(diagonal_indices);
+};
+return if_then_else((PrimExpr)iter_vars[ndim] == iter_vars[ndim - 1], 
get_diag(),
+input(iter_vars));
+  },
+  name, tag);
+}
+
 }  // namespace topi
 }  // namespace tvm
 #endif  // TVM_TOPI_TRANSFORM_H_
diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index 200352c..31ff871 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -107,6 +107,7 @@ class OperatorConverter(object):
 'LOGICAL_NOT': self.convert_logical_not,
 'LOGICAL_OR': self.convert_logical_or,
 'LOGISTIC': self.convert_logistic,
+'MATRIX_SET_DIAG': self.convert_matrix_set_diag,
 'MAX_POOL_2D': self.convert_max_pool2d,
 'MAXIMUM': self.convert_maximum,
 'MEAN': self.convert_reduce_mean,
@@ -2989,6 +2990,33 @@ class OperatorConverter(object):
 out = _op.reverse(input_expr, axis)
 return out
 
+def convert_matrix_set_diag(self, op):
+"""Convert TFLite MATRIX_SET_DIAG"""
+
+input_tensors = self.get_input_tensors(op)
+assert len(input_tensors) == 2, "input tensor's length should be 2"
+
+assert input_tensors[0].tensor.Type() == 
input_tensors[1].tensor.Type(), \
+"input and diagonal should be the same type of tensors"
+
+if input_tensors[0].qnn_params:
+# Check that input and output tensor have same qnn params.
+output_tensors = self.get_output_tensors(op)
+assert self.has_same_qnn_params(input_tensors[0], 
output_tensors[0]), \
+"TFLite MATRIX_SET_DIAG requires input and output tensors' \
+scale and zero points to be equal"
+
+# Check that input and diagonal tensor have same qnn params.
+assert self.has_same_qnn_params(input_tensors[0], 
input_tensors[1]), \
+"TFLite MATRIX_SET_DIAG requires input and diagonal tensors' \
+scale 

[incubator-tvm] branch master updated (f34e3a8 -> b1f8f15)

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

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


from f34e3a8  [RUNTIME][FFI] Fix cython FFI compact with np.int64 (#6321)
 add b1f8f15  [Ansor][AutoTVM v2.0] Phase 2: Basic GPU Sketch Search Policy 
(#6269)

No new revisions were added by this update.

Summary of changes:
 include/tvm/auto_scheduler/search_policy.h |  35 ++
 python/tvm/auto_scheduler/__init__.py  |   3 +-
 python/tvm/auto_scheduler/auto_schedule.py | 122 +--
 python/tvm/auto_scheduler/loop_state.py|   9 +-
 python/tvm/auto_scheduler/search_policy.py | 180 ++
 src/auto_scheduler/auto_schedule.cc|  13 +-
 src/auto_scheduler/search_policy/search_policy.cc  |  63 
 src/auto_scheduler/search_policy/sketch_policy.cc  |  72 +++-
 src/auto_scheduler/search_policy/sketch_policy.h   |   2 +
 .../search_policy/sketch_policy_rules.cc   | 378 +++--
 .../search_policy/sketch_policy_rules.h| 123 +++
 src/auto_scheduler/search_policy/utils.cc  |  55 +++
 src/auto_scheduler/search_policy/utils.h   | 184 ++
 src/auto_scheduler/search_task.cc  |  28 +-
 src/auto_scheduler/transform_step.cc   | 100 +++---
 src/auto_scheduler/utils.h |  21 --
 .../unittest/test_auto_scheduler_search_policy.py  |  29 +-
 .../test_auto_scheduler_sketch_generation.py   | 286 +++-
 18 files changed, 1387 insertions(+), 316 deletions(-)
 create mode 100644 python/tvm/auto_scheduler/search_policy.py



[incubator-tvm] branch master updated: tvmc: solve a linting error on onnx command line driver frontend (#6536)

2020-09-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 22b8121  tvmc: solve a linting error on onnx command line driver 
frontend (#6536)
22b8121 is described below

commit 22b8121ba77e2bad5e580b5ca7ce9a816f65a193
Author: Leandro Nunes 
AuthorDate: Thu Sep 24 07:48:10 2020 +0100

tvmc: solve a linting error on onnx command line driver frontend (#6536)

* Updates onnx load function from "load" (a compatibility attribute)
   to "load_model" (the actual function)

 * Add a pylint command, that we don't see currently on upstream CI,
   but it reproduces when linting it locally.
---
 python/tvm/driver/tvmc/frontends.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/python/tvm/driver/tvmc/frontends.py 
b/python/tvm/driver/tvmc/frontends.py
index 6275f77..0ed8821 100644
--- a/python/tvm/driver/tvmc/frontends.py
+++ b/python/tvm/driver/tvmc/frontends.py
@@ -154,6 +154,7 @@ class OnnxFrontend(Frontend):
 # pylint: disable=C0415
 import onnx
 
+# pylint: disable=E1101
 model = onnx.load(path)
 
 # pylint: disable=E1101



[incubator-tvm] branch master updated (2bacf36 -> 4cad71d)

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

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


from 2bacf36  [BYODT] fix CMAKE flag name + update documentation (#6567)
 add 4cad71d  [AutoScheduler] Improve the rule of mutating parallel 
granularity (#6568)

No new revisions were added by this update.

Summary of changes:
 .../search_policy/sketch_policy_rules.cc   | 108 +++-
 src/auto_scheduler/search_policy/utils.cc  |   4 +-
 src/auto_scheduler/search_policy/utils.h   |  26 ++---
 .../test_auto_scheduler_evolutionary_search.py | 111 +++--
 tutorials/auto_scheduler/tune_conv2d_layer_cuda.py |   4 +-
 tutorials/auto_scheduler/tune_matmul_x86.py|   4 +-
 6 files changed, 154 insertions(+), 103 deletions(-)



[incubator-tvm] branch master updated (1d5504b -> 2bacf36)

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

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


from 1d5504b  [APP] Fix misprint in demo.cc during initializing of picture 
tensor data (#6566)
 add 2bacf36  [BYODT] fix CMAKE flag name + update documentation (#6567)

No new revisions were added by this update.

Summary of changes:
 CMakeLists.txt |  2 +-
 cmake/config.cmake | 10 --
 cmake/modules/LibInfo.cmake|  2 +-
 cmake/modules/contrib/Posit.cmake  |  4 ++--
 python/tvm/target/datatype.py  | 18 +-
 src/support/libinfo.cc |  6 +++---
 src/target/datatype/posit/posit-wrapper.cc |  8 ++--
 tests/python/unittest/test_custom_datatypes.py |  4 ++--
 8 files changed, 32 insertions(+), 22 deletions(-)



[incubator-tvm] branch master updated: [TFLITE]Quantize & Dequantize op (#5394)

2020-05-27 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 162a29e  [TFLITE]Quantize & Dequantize op (#5394)
162a29e is described below

commit 162a29e0b82aef9c3013e360a43a4b14c3c652d9
Author: Samuel 
AuthorDate: Thu May 28 08:40:58 2020 +0530

[TFLITE]Quantize & Dequantize op (#5394)

* [TFLITE]Quantize & Dequantize op

* Testcases added

* Review comment fixed
---
 python/tvm/relay/frontend/tflite.py  | 38 
 tests/python/frontend/tflite/test_forward.py | 43 
 2 files changed, 81 insertions(+)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index cb10ce5..9414314 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -75,6 +75,7 @@ class OperatorConverter(object):
 'COS': self.convert_cos,
 'DEPTH_TO_SPACE': self.convert_depth_to_space,
 'DEPTHWISE_CONV_2D': self.convert_depthwise_conv2d,
+'DEQUANTIZE': self.convert_dequantize,
 'DETECTION_POSTPROCESS': self.convert_detection_postprocess,
 'DIV': self.convert_div,
 'ELU': self.convert_elu,
@@ -112,6 +113,7 @@ class OperatorConverter(object):
 'PAD': self.convert_pad,
 'POW': self.convert_pow,
 'PRELU': self.convert_prelu,
+'QUANTIZE': self.convert_quantize,
 'REDUCE_ANY': self.convert_reduce_any,
 'REDUCE_MAX': self.convert_reduce_max,
 'REDUCE_MIN': self.convert_reduce_min,
@@ -277,6 +279,8 @@ class OperatorConverter(object):
 except ImportError:
 raise ImportError("The tflite package must be installed")
 
+if tensor_type == TensorType.INT8:
+return "int8"
 if tensor_type == TensorType.UINT8:
 return "uint8"
 if tensor_type == TensorType.FLOAT32:
@@ -2355,6 +2359,40 @@ class OperatorConverter(object):
 
 return out
 
+def convert_quantize(self, op):
+"""Convert TFLite Quantize"""
+
+input_tensors = self.get_input_tensors(op)
+assert len(input_tensors) == 1, "input tensors length should be 1"
+input_tensor = input_tensors[0]
+in_expr = self.get_expr(input_tensor.tensor_idx)
+
+output_tensors = self.get_output_tensors(op)
+assert len(output_tensors) == 1, "output tensors length should be 1"
+output_tensor = output_tensors[0]
+
+# The output must be quantized
+assert output_tensor.qnn_params
+# Quantize the input
+out = self.quantize(in_expr, output_tensor)
+
+return out
+
+def convert_dequantize(self, op):
+"""Convert TFLite Dequantize"""
+
+input_tensors = self.get_input_tensors(op)
+assert len(input_tensors) == 1, "input tensors length should be 1"
+input_tensor = input_tensors[0]
+in_expr = self.get_expr(input_tensor.tensor_idx)
+
+# The input must be quantized
+assert input_tensor.qnn_params
+# Dequantize the input.
+out = self.dequantize(in_expr, input_tensor)
+
+return out
+
 def convert_detection_postprocess(self, op):
 """Convert TFLite_Detection_PostProcess"""
 flexbuffer = op.CustomOptionsAsNumpy().tobytes()
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index 7a8437a..a68fd90 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -1565,6 +1565,48 @@ def test_forward_squeeze():
 
 
 ###
+# Quantize/DeQuantize
+# ---
+
+def _test_quantize_dequantize(data):
+""" One iteration of quantize and dequantize """
+
+# Define a dummy model
+data_in = tf.keras.layers.Input(shape=data.shape[1:])
+act_func =  tf.keras.layers.Activation('linear')
+keras_model = tf.keras.models.Model(data_in, act_func(data_in))
+
+# Load the model
+converter = 
interpreter_wrapper.TFLiteConverter.from_keras_model(keras_model)
+
+# To create quantized values with dynamic range of activations, needs 
representative dataset
+def representative_data_gen():
+for i in range(100):
+yield [data]
+
+converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
+converter.representative_dataset = representative_data_gen
+converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
+converter.inferen

[incubator-tvm] branch master updated: [C++ RPC] fix typo to keep same with source code (#6220)

2020-08-06 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 3d8ad7a  [C++ RPC] fix typo to keep same with source code (#6220)
3d8ad7a is described below

commit 3d8ad7a124265b0844c61b40d712443cca038d47
Author: windclarion 
AuthorDate: Fri Aug 7 12:23:39 2020 +0800

[C++ RPC] fix typo to keep same with source code (#6220)

Signed-off-by: windclarion 
---
 apps/cpp_rpc/main.cc   | 4 ++--
 apps/cpp_rpc/rpc_server.cc | 4 ++--
 apps/cpp_rpc/rpc_server.h  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/apps/cpp_rpc/main.cc b/apps/cpp_rpc/main.cc
index ae2636d..777fffa 100644
--- a/apps/cpp_rpc/main.cc
+++ b/apps/cpp_rpc/main.cc
@@ -51,7 +51,7 @@ static const string kUsage =
 " server   - Start the server\n"
 "--host- The hostname of the server, Default=0.0.0.0\n"
 "--port- The port of the RPC, Default=9090\n"
-"--port-end- The end search port of the RPC, Default=9199\n"
+"--port-end- The end search port of the RPC, Default=9099\n"
 "--tracker - The RPC tracker address in host:port format e.g. 
10.1.1.2:9190 Default=\"\"\n"
 "--key - The key used to identify the device type in tracker. 
Default=\"\"\n"
 "--custom-addr - Custom IP Address to Report to RPC Tracker. 
Default=\"\"\n"
@@ -66,7 +66,7 @@ static const string kUsage =
  * \brief RpcServerArgs.
  * \arg host The hostname of the server, Default=0.0.0.0
  * \arg port The port of the RPC, Default=9090
- * \arg port_end The end search port of the RPC, Default=9199
+ * \arg port_end The end search port of the RPC, Default=9099
  * \arg tracker The address of RPC tracker in host:port format e.g. 
10.77.1.234:9190 Default=""
  * \arg key The key used to identify the device type in tracker. Default=""
  * \arg custom_addr Custom IP Address to Report to RPC Tracker. Default=""
diff --git a/apps/cpp_rpc/rpc_server.cc b/apps/cpp_rpc/rpc_server.cc
index 2628ff7..592a6db 100644
--- a/apps/cpp_rpc/rpc_server.cc
+++ b/apps/cpp_rpc/rpc_server.cc
@@ -86,7 +86,7 @@ static std::string getNextString(std::stringstream* iss) {
  * \brief RPCServer RPC Server class.
  * \param host The hostname of the server, Default=0.0.0.0
  * \param port The port of the RPC, Default=9090
- * \param port_end The end search port of the RPC, Default=9199
+ * \param port_end The end search port of the RPC, Default=9099
  * \param tracker The address of RPC tracker in host:port format e.g. 
10.77.1.234:9190 Default=""
  * \param key The key used to identify the device type in tracker. Default=""
  * \param custom_addr Custom IP Address to Report to RPC Tracker. Default=""
@@ -362,7 +362,7 @@ void ServerLoopFromChild(SOCKET socket) {
  * \brief RPCServerCreate Creates the RPC Server.
  * \param host The hostname of the server, Default=0.0.0.0
  * \param port The port of the RPC, Default=9090
- * \param port_end The end search port of the RPC, Default=9199
+ * \param port_end The end search port of the RPC, Default=9099
  * \param tracker_addr The address of RPC tracker in host:port format e.g. 
10.77.1.234:9190
  * Default="" \param key The key used to identify the device type in tracker. 
Default="" \param
  * custom_addr Custom IP Address to Report to RPC Tracker. Default="" \param 
silent Whether run in
diff --git a/apps/cpp_rpc/rpc_server.h b/apps/cpp_rpc/rpc_server.h
index 0936c51..7a4bda5 100644
--- a/apps/cpp_rpc/rpc_server.h
+++ b/apps/cpp_rpc/rpc_server.h
@@ -44,7 +44,7 @@ void ServerLoopFromChild(SOCKET socket);
  * \brief RPCServerCreate Creates the RPC Server.
  * \param host The hostname of the server, Default=0.0.0.0
  * \param port The port of the RPC, Default=9090
- * \param port_end The end search port of the RPC, Default=9199
+ * \param port_end The end search port of the RPC, Default=9099
  * \param tracker The address of RPC tracker in host:port format e.g. 
10.77.1.234:9190 Default=""
  * \param key The key used to identify the device type in tracker. Default=""
  * \param custom_addr Custom IP Address to Report to RPC Tracker. Default=""



[incubator-tvm] branch master updated (87f9010 -> da27e6d)

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

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


from 87f9010  [ONNX]Mod operator, bug fix (#6160)
 add da27e6d  Reshape with dynamic shape arg (#6208)

No new revisions were added by this update.

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



[incubator-tvm] branch master updated: [runtime][cublas] fix typo (#6230)

2020-08-07 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 bfd46ab  [runtime][cublas] fix typo (#6230)
bfd46ab is described below

commit bfd46abf11b972c451a1d6085a8090a599121743
Author: cloud-mxd 
AuthorDate: Fri Aug 7 19:38:11 2020 +0800

[runtime][cublas] fix typo (#6230)
---
 src/runtime/contrib/cublas/cublas.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/runtime/contrib/cublas/cublas.cc 
b/src/runtime/contrib/cublas/cublas.cc
index 467ae5f..24468a7 100644
--- a/src/runtime/contrib/cublas/cublas.cc
+++ b/src/runtime/contrib/cublas/cublas.cc
@@ -174,7 +174,7 @@ inline void CallLtIgemm(TVMArgs args, TVMRetValue* ret, 
cublasLtHandle_t hdl) {
   cublasLtMatmulDesc_t operationDesc = nullptr;
 #if CUDART_VERSION >= 11000
   CHECK_CUBLAS_ERROR(cublasLtMatmulDescCreate(, 
CUBLAS_COMPUTE_32I, CUDA_R_32I));
-#elif
+#else
   CHECK_CUBLAS_ERROR(cublasLtMatmulDescCreate(, CUDA_R_32I));
 #endif
   CHECK_CUBLAS_ERROR(cublasLtMatmulDescSetAttribute(operationDesc, 
CUBLASLT_MATMUL_DESC_TRANSB,



[incubator-tvm] branch master updated (5ed7d31 -> 8bb99fb)

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

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


from 5ed7d31  [COMMUNITY] jcf94 -> Reviewer (#6241)
 add 8bb99fb  [TFLite] Implemented ONE_HOT Operator for TFLite (#6223)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 51 
 tests/python/frontend/tflite/test_forward.py | 29 
 2 files changed, 80 insertions(+)



[incubator-tvm] branch master updated (abfa79d -> b6b5ace)

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

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


from abfa79d  update tutorial to new TARGET as micro_dev is no more (#6262)
 add b6b5ace  Improve NHWC depthwise convolution for AArch64 (#6095)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/op/strategy/arm_cpu.py|   7 +-
 python/tvm/relay/qnn/op/legalizations.py   |   8 +-
 python/tvm/topi/arm_cpu/depthwise_conv2d.py| 167 -
 .../topi/python/test_topi_depthwise_conv2d.py  |   1 +
 4 files changed, 177 insertions(+), 6 deletions(-)



[incubator-tvm] branch master updated (5721387 -> 7ef89ad)

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

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


from 5721387  [DOCS] Update pass infra tutorial (#6193)
 add 7ef89ad  [Ansor][AutoTVM v2.0] Phase 1: The base class for cost models 
(#6187)

No new revisions were added by this update.

Summary of changes:
 include/tvm/auto_scheduler/cost_model.h| 160 +
 python/tvm/auto_scheduler/__init__.py  |   3 +-
 .../cost_model}/__init__.py|   6 +-
 python/tvm/auto_scheduler/cost_model/cost_model.py | 150 +++
 src/auto_scheduler/cost_model.cc   | 156 
 ...ofiler.py => test_auto_scheduler_cost_model.py} |  38 ++---
 6 files changed, 491 insertions(+), 22 deletions(-)
 create mode 100644 include/tvm/auto_scheduler/cost_model.h
 copy python/tvm/{contrib/tf_op => auto_scheduler/cost_model}/__init__.py (84%)
 create mode 100644 python/tvm/auto_scheduler/cost_model/cost_model.py
 create mode 100644 src/auto_scheduler/cost_model.cc
 copy tests/python/unittest/{test_runtime_vm_profiler.py => 
test_auto_scheduler_cost_model.py} (57%)



[incubator-tvm] branch master updated: [TFLite] Implemented EXPAND_DIMS Operator for TFLite. (#6243)

2020-08-11 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 2845329  [TFLite] Implemented EXPAND_DIMS Operator for TFLite. (#6243)
2845329 is described below

commit 2845329009a42dcfbb3ac6d6dda7b578b8f8c585
Author: Rishabh Jain <56974688+jain...@users.noreply.github.com>
AuthorDate: Tue Aug 11 13:35:55 2020 +0530

[TFLite] Implemented EXPAND_DIMS Operator for TFLite. (#6243)
---
 python/tvm/relay/frontend/tflite.py  | 26 +
 tests/python/frontend/tflite/test_forward.py | 56 
 2 files changed, 82 insertions(+)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index f168f1b..11d6576 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -84,6 +84,7 @@ class OperatorConverter(object):
 'ELU': self.convert_elu,
 'EQUAL': self.convert_equal,
 'EXP': self.convert_exp,
+'EXPAND_DIMS': self.convert_expand_dims,
 'FILL': self.convert_fill,
 'FLOOR_DIV': self.convert_floor_div,
 'FLOOR_MOD': self.convert_floor_mod,
@@ -2904,6 +2905,31 @@ class OperatorConverter(object):
 ret = _expr.TupleWrapper(_expr.Tuple([boxes, cls_ids, scores, 
valid_count]), size=4)
 return ret
 
+def convert_expand_dims(self, op):
+"""Convert TFLite EXPAND_DIMS"""
+input_tensors = self.get_input_tensors(op)
+assert len(input_tensors) == 2, "input tensors length should be 2"
+
+if input_tensors[0].qnn_params:
+# Check that input and output tensor have same qnn params.
+output_tensors = self.get_output_tensors(op)
+assert self.has_same_qnn_params(input_tensors[0], 
output_tensors[0]), \
+"TFLite EXPAND_DIMS requires input and output tensors' \
+scale and zero points to be equal"
+
+input_expr = self.get_tensor_expr(input_tensors[0])
+axis = self.get_tensor_value(input_tensors[1])
+if isinstance(axis, np.ndarray):
+assert len(axis) == 1, "only one value is expected."
+axis = int(axis)
+
+ndims = len(input_tensors[0].tensor.ShapeAsNumpy())
+assert (-1-ndims <= axis <= ndims), "axis out of range"
+
+out = _op.expand_dims(input_expr, axis, 1)
+
+return out
+
 def convert_one_hot(self, op):
 """Convert TFLite ONE_HOT"""
 try:
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index 2e57175..33ac6d4 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -2031,6 +2031,61 @@ def test_forward_padv2():
 
 
 ###
+# EXPAND_DIMS
+# ---
+
+def _test_expand_dims(input_shape, input_type, axis, quantized=False):
+""" One iteration of EXPAND_DIMS """
+with tf.Graph().as_default():
+axis= ops.convert_to_tensor(axis, dtype=axis.dtype)
+
+if quantized:
+# ignoring input_type as quantized requires uint8
+input = np.random.uniform(0, 256, input_shape).astype('uint8')
+in_input = tf.placeholder(dtype='float32', shape=input.shape, 
name="input")
+
+input_range = {'q_input': (-100, 100)}
+inq_input = tf.quantization.fake_quant_with_min_max_args(
+in_input,
+min=-100,
+max=100,
+name="q_input")
+
+out = array_ops.expand_dims(inq_input, axis=axis)
+out = tf.quantization.fake_quant_with_min_max_args(
+out,
+min=-100,
+max=100,
+name="out")
+
+compare_tflite_with_tvm(
+[input],
+["q_input"],
+[inq_input],
+[out],
+quantized=True,
+input_range=input_range)
+else:
+input = np.random.uniform(-100, 100, 
input_shape).astype(input_type)
+in_input = tf.placeholder(dtype=input.dtype, shape=input.shape, 
name="input")
+
+out = array_ops.expand_dims(in_input, axis=axis)
+
+compare_tflite_with_tvm(
+[input],
+["input"],
+[in_input],
+[out])
+
+def test_forward_expand_dims():
+""" EXPAND_DIMS """
+for quantized in [False, True]:
+_test_expand_dims((6, 2, 7, 5

[incubator-tvm] branch master updated (ee33056 -> 14f4efe)

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

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


from ee33056  [Topi,x86] Split MKL from BLAS. (#6182)
 add 14f4efe  [RPC] Update build support for cross compiling apps/cpp_rpc 
with OpenCL (#6229)

No new revisions were added by this update.

Summary of changes:
 CMakeLists.txt  |  4 +--
 apps/cpp_rpc/CMakeLists.txt | 12 
 apps/cpp_rpc/Makefile   | 53 --
 apps/cpp_rpc/README.md  | 44 ++--
 cmake/config.cmake  |  8 ++
 cmake/modules/OpenCL.cmake  |  6 ++--
 cmake/util/FindOpenCL.cmake | 70 +
 7 files changed, 124 insertions(+), 73 deletions(-)
 delete mode 100644 apps/cpp_rpc/Makefile
 create mode 100644 cmake/util/FindOpenCL.cmake



[incubator-tvm] branch master updated (7926a5d -> 5ed7d31)

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

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


from 7926a5d  [Relay][Op] Add unbiased variance op and corresponding 
support in pytorch frontend (#6232)
 add 5ed7d31  [COMMUNITY] jcf94 -> Reviewer (#6241)

No new revisions were added by this update.

Summary of changes:
 CONTRIBUTORS.md | 1 +
 1 file changed, 1 insertion(+)



[incubator-tvm] branch master updated (b6db7e3 -> f11abf2)

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

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


from b6db7e3  [RELAY] Basic block normal form (#6152)
 add f11abf2  [COREML]Unary ops support added in frontend (#6196)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/coreml.py  |  30 -
 tests/python/frontend/coreml/test_forward.py | 189 +++
 2 files changed, 218 insertions(+), 1 deletion(-)



[incubator-tvm] branch master updated (712c82f -> 99c52f3)

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

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


from 712c82f  Add support for tflite arg_min and arg_max (#5992)
 add 99c52f3  [Frontend][TFLite] Fix fully_connected converter when batch 
size is not 1 (#6038)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 10 +-
 tests/python/frontend/tflite/test_forward.py | 21 +++--
 2 files changed, 20 insertions(+), 11 deletions(-)



[incubator-tvm] branch master updated: [RFC] Improve quantized convolution performance for armv8 architectures (#5754)

2020-06-22 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 b94e8b7  [RFC] Improve quantized convolution performance for armv8 
architectures (#5754)
b94e8b7 is described below

commit b94e8b7290c5ced98728e730634ec73727c53c51
Author: Giuseppe Rossini 
AuthorDate: Tue Jun 23 06:20:05 2020 +0100

[RFC] Improve quantized convolution performance for armv8 architectures 
(#5754)

* Improve quantized conv2d performance for armv8

Signed-off-by: Giuseppe Rossini 
Change-Id: I3a3d29f5332dd9b3354e8e0dfb24677a521f9c8f

* Add ASF header to conv2d_gemm.py

Change-Id: I33853279e39c849ae1b555a9c91d7557985a0a35

* Run clang-format-10 on c++ files

Change-Id: Ieee22f032e595dabfc1616ab33466fcbf8d94365

* Fix pylint errors/warnings

Change-Id: I435d4d7bca7500db99547f4401fdc0d0995a1ff4

* Fix pylint errors/warnings in topi

Change-Id: I2fc1ad8453e9020072ab967c849df5390c2967b5

* Fix legalizations tests for aarch64

Change-Id: I0a67a49a7849f52ef7d57b9292ce9125bbb7cb2c

* Reintroduce conv2d_nhwc_spatial_pack.arm_cpu and int16 cast

Change-Id: I91b67fabd475e90a9b75f2dd5ecfee851265e0bb

* Switch type of legalization depending on the strategy used

Change-Id: I9a03040a8c40a6cd2658ed14c3751e05a8e19f2b

* Revert last commit

Change-Id: Ice34101e358e3ce8ebfb12c58f73e910ba5de8e8

* Fix the auto-tuner by registering the correct schedules

Change-Id: Id9273688b2620e1ea849ab01b4c46af8fbf37fd0

* Address review comments

Change-Id: Ia1755a0af7b6d159072d9f0c93c932c481101e48

* Improve usability and readability of conv2d_gemm_weight_transform

Change-Id: I186bbc2fe4054b58ce15d910e3be7b315482

* Change variable name to weight in Conv2DGemmWeightTransformRel

Change-Id: Ifb5f1f33af7512fe67c6b049b20a42a0bb2d26c9

* Fix clang-10 linting errors

Change-Id: I25ccc844d9cee23766096e1daddb6180abc413a6

* Trigger tests

Change-Id: Id37706fb7cf77a87a3cc817ecf8046297d9ca95a
---
 include/tvm/relay/attrs/nn.h|  11 +
 python/tvm/relay/op/nn/_nn.py   |  17 ++
 python/tvm/relay/op/nn/nn.py|  91 
 python/tvm/relay/op/strategy/arm_cpu.py |  42 
 python/tvm/relay/op/strategy/generic.py |  13 ++
 python/tvm/relay/qnn/op/legalizations.py|   8 +-
 src/relay/op/nn/convolution.cc  |  82 +++
 src/relay/op/nn/convolution.h   | 131 +++
 topi/python/topi/arm_cpu/conv2d_alter_op.py |  65 +-
 topi/python/topi/arm_cpu/conv2d_gemm.py | 174 ++
 topi/python/topi/arm_cpu/conv2d_int8.py |  38 +++-
 topi/python/topi/arm_cpu/tensor_intrin.py   | 339 
 topi/python/topi/generic/nn.py  |  19 ++
 topi/python/topi/nn/conv2d.py   |  49 
 14 files changed, 1065 insertions(+), 14 deletions(-)

diff --git a/include/tvm/relay/attrs/nn.h b/include/tvm/relay/attrs/nn.h
index abe63e5..5f1ee2f 100644
--- a/include/tvm/relay/attrs/nn.h
+++ b/include/tvm/relay/attrs/nn.h
@@ -187,6 +187,17 @@ struct ConvWinogradWeightTransformAttrs : public 
tvm::AttrsNode {
+  int tile_rows;
+  int tile_cols;
+
+  TVM_DECLARE_ATTRS(ConvGemmWeightTransformAttrs, 
"relay.attrs.ConvGemmWeightTransformAttrs") {
+TVM_ATTR_FIELD(tile_rows).describe("Tile rows of the weight transformation 
for ConvGemm.");
+TVM_ATTR_FIELD(tile_cols).describe("Tile columns of the weight 
transformation for ConvGemm.");
+  }
+};
+
 /*! \brief Attributes used in convolution operators with winograd algorithm */
 struct Conv2DWinogradAttrs : public tvm::AttrsNode {
   int tile_size;
diff --git a/python/tvm/relay/op/nn/_nn.py b/python/tvm/relay/op/nn/_nn.py
index 1c76f57..564d6f7 100644
--- a/python/tvm/relay/op/nn/_nn.py
+++ b/python/tvm/relay/op/nn/_nn.py
@@ -446,6 +446,23 @@ 
reg.register_strategy("nn.contrib_conv2d_winograd_without_weight_transform",
 reg.register_pattern("nn.contrib_conv2d_winograd_without_weight_transform",
  OpPattern.OUT_ELEMWISE_FUSABLE)
 
+# conv2d_gemm related operators
+reg.register_strategy("nn.contrib_conv2d_gemm_without_weight_transform",
+  strategy.conv2d_gemm_without_weight_transform_strategy)
+reg.register_pattern("nn.contrib_conv2d_gemm_without_weight_transform",
+ OpPattern.OUT_ELEMWISE_FUSABLE)
+
+@reg.register_compute("nn.contrib_conv2d_gemm_weight_transform")
+def compute_contrib_conv2d_gemm_weight_transform(attrs, inputs, out_dtype):
+"""Compute definition of contrib_conv2d_gemm_weight_transform"&quo

[incubator-tvm] branch master updated (c8b7d6d -> d97dcd7)

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

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


from c8b7d6d  [MXNET]conv3d and conv3d_transpose addedx (#5814)
 add d97dcd7  Pin hand landmark network to version 0.7.4. (#5813)

No new revisions were added by this update.

Summary of changes:
 tests/python/frontend/tflite/test_forward.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)



[incubator-tvm] branch master updated (c8b7d6d -> d97dcd7)

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

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


from c8b7d6d  [MXNET]conv3d and conv3d_transpose addedx (#5814)
 add d97dcd7  Pin hand landmark network to version 0.7.4. (#5813)

No new revisions were added by this update.

Summary of changes:
 tests/python/frontend/tflite/test_forward.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)



[tvm] branch main updated: [Auto Scheduler] Add target host to measure record (#7046)

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

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


The following commit(s) were added to refs/heads/main by this push:
 new a867bcb  [Auto Scheduler] Add target host to measure record (#7046)
a867bcb is described below

commit a867bcbf1ecf537cfb061a2ca4790b16a9cc9748
Author: Zhao Wu 
AuthorDate: Tue Dec 8 14:46:29 2020 +0800

[Auto Scheduler] Add target host to measure record (#7046)

* [Auto Scheduler] Add target host to measure record

* Fix PyLint

* Fix lint

* Solve the serialization logic when we don't have hardware params

* update auto scheduler log
---
 src/auto_scheduler/measure_record.cc   | 12 --
 .../python/unittest/test_auto_scheduler_measure.py | 26 ++
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/auto_scheduler/measure_record.cc 
b/src/auto_scheduler/measure_record.cc
index d57e2f2..aad0abe 100644
--- a/src/auto_scheduler/measure_record.cc
+++ b/src/auto_scheduler/measure_record.cc
@@ -163,6 +163,9 @@ struct Handler<::tvm::auto_scheduler::SearchTaskNode> {
 writer->WriteArrayItem(std::string(data.workload_key));
 writer->WriteArrayItem(data.target->str());
 writer->WriteArrayItem(*data.hardware_params.get());
+if (data.target_host.defined()) {
+  writer->WriteArrayItem(data.target_host->str());
+}
 writer->EndArray();
   }
   inline static void Read(dmlc::JSONReader* reader, 
::tvm::auto_scheduler::SearchTaskNode* data) {
@@ -183,7 +186,12 @@ struct Handler<::tvm::auto_scheduler::SearchTaskNode> {
   reader->Read(hardware_params_node.get());
   s = reader->NextArrayItem();
   data->hardware_params = 
::tvm::auto_scheduler::HardwareParams(hardware_params_node);
-  ICHECK(!s);
+  if (s) {
+reader->Read(_value);
+data->target_host = ::tvm::Target(str_value);
+s = reader->NextArrayItem();
+ICHECK(!s);
+  }
 }
   }
 };
@@ -271,7 +279,7 @@ namespace auto_scheduler {
 TVM_REGISTER_OBJECT_TYPE(RecordToFileNode);
 TVM_REGISTER_OBJECT_TYPE(RecordReaderNode);
 
-const std::string AUTO_SCHEDULER_LOG_VERSION = "v0.3";  // NOLINT(*)
+const std::string AUTO_SCHEDULER_LOG_VERSION = "v0.4";  // NOLINT(*)
 
 RecordToFile::RecordToFile(String filename) {
   auto node = make_object();
diff --git a/tests/python/unittest/test_auto_scheduler_measure.py 
b/tests/python/unittest/test_auto_scheduler_measure.py
index b214d9c..10bb0b4 100644
--- a/tests/python/unittest/test_auto_scheduler_measure.py
+++ b/tests/python/unittest/test_auto_scheduler_measure.py
@@ -250,6 +250,31 @@ def test_measure_local_builder_rpc_runner_spawn():
 p.join()
 
 
+@tvm.testing.requires_llvm
+def test_measure_target_host():
+task = auto_scheduler.SearchTask(
+func=matmul_auto_scheduler_test,
+args=(512, 512, 512),
+target="llvm",
+target_host="llvm -mtriple=aarch64-linux-gnu",
+)
+
+inp = auto_scheduler.measure.MeasureInput(task, 
task.compute_dag.init_state)
+res = auto_scheduler.measure.MeasureResult([0.1], 0, "", 0.2, 1)
+
+with tempfile.NamedTemporaryFile() as fp:
+auto_scheduler.save_records(fp.name, [inp], [res])
+
+log_reader = auto_scheduler.RecordReader(fp.name)
+inputs, results = log_reader.read_lines()
+assert len(inputs) == 1
+
+raw_inp = inputs[0]
+
+recovered_inp = auto_scheduler.measure.recover_measure_input(raw_inp)
+assert str(recovered_inp.task.target_host) == str(inp.task.target_host)
+
+
 if __name__ == "__main__":
 test_record_split_reorder_fuse_annotation()
 test_record_compute_at_root_inline_cache_read_write()
@@ -258,3 +283,4 @@ if __name__ == "__main__":
 test_recover_measure_input()
 test_measure_local_builder_runner()
 test_measure_local_builder_rpc_runner()
+test_measure_target_host()



[tvm] branch main updated (db8edc1 -> 1ccf2c2)

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

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


from db8edc1  [TFLite] added scalar axis value handling in reduce (#6970)
 add 1ccf2c2  [AutoScheduler] Delete deprecated file auto_schedule.py 
(#7071)

No new revisions were added by this update.

Summary of changes:
 python/tvm/auto_scheduler/auto_schedule.py | 215 -
 1 file changed, 215 deletions(-)
 delete mode 100644 python/tvm/auto_scheduler/auto_schedule.py



[tvm] branch main updated (053347c -> d5eb1da)

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

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


from 053347c  [metal] Remove support of `double` type (#7118)
 add d5eb1da  [TF frontend] add support for StridedSlice to input a single 
constant (#6949)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tensorflow.py  |  3 +
 tests/python/frontend/tensorflow/test_forward.py | 71 +---
 2 files changed, 43 insertions(+), 31 deletions(-)



[tvm] branch main updated (24cd869 -> 98ca771)

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

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


from 24cd869  [COMMUNITY] @jcf94 -> Committer (#7141)
 add 98ca771  [Auto Scheduler] Mali Support (#7132)

No new revisions were added by this update.

Summary of changes:
 python/tvm/auto_scheduler/relay_integration.py |   8 +-
 python/tvm/relay/op/strategy/mali.py   |  55 
 python/tvm/topi/mali/conv2d.py |  75 ---
 python/tvm/topi/nn/conv2d.py   |  13 +-
 src/auto_scheduler/search_policy/sketch_policy.cc  |  65 ++
 src/auto_scheduler/search_task.cc  |  16 +++
 src/relay/backend/build_module.cc  |   5 +-
 .../{tune_network_x86.py => tune_network_mali.py}  | 138 +
 8 files changed, 278 insertions(+), 97 deletions(-)
 copy tutorials/auto_scheduler/{tune_network_x86.py => tune_network_mali.py} 
(76%)



[incubator-tvm] branch main updated (6c01998 -> 7e90e7d)

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

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


from 6c01998  Make AutoScheduler handling of errors during measure 
consistent with AutoTvm (#6909)
 add 7e90e7d  [Relay] Add space_to_batch_nd and batch_to_space_nd operators 
(#6477)

No new revisions were added by this update.

Summary of changes:
 include/tvm/relay/attrs/nn.h   |  28 +++
 include/tvm/topi/nn.h  | 178 +
 python/tvm/relay/frontend/tensorflow.py|  88 ++---
 python/tvm/relay/frontend/tflite.py|  85 +---
 python/tvm/relay/op/nn/_nn.py  |   5 +
 python/tvm/relay/op/nn/nn.py   |  61 ++
 python/tvm/relay/op/op_attrs.py|  10 +
 python/tvm/topi/nn/__init__.py |   2 +
 .../topi/nn/{flatten.py => batch_to_space_nd.py}   |  46 ++---
 ...local_response_norm.py => space_to_batch_nd.py} |  45 ++---
 python/tvm/topi/testing/__init__.py|   2 +
 python/tvm/topi/testing/batch_to_space_nd.py   |  97 +
 python/tvm/topi/testing/space_to_batch_nd.py   |  93 +
 src/relay/op/nn/nn.cc  | 218 +
 src/topi/nn.cc |   8 +
 tests/python/relay/test_op_level5.py   |  56 ++
 .../topi/python/test_topi_batch_to_space_nd.py |  70 +++
 .../topi/python/test_topi_space_to_batch_nd.py |  72 +++
 18 files changed, 957 insertions(+), 207 deletions(-)
 copy python/tvm/topi/nn/{flatten.py => batch_to_space_nd.py} (51%)
 copy python/tvm/topi/nn/{local_response_norm.py => space_to_batch_nd.py} (51%)
 create mode 100644 python/tvm/topi/testing/batch_to_space_nd.py
 create mode 100644 python/tvm/topi/testing/space_to_batch_nd.py
 create mode 100644 tests/python/topi/python/test_topi_batch_to_space_nd.py
 create mode 100644 tests/python/topi/python/test_topi_space_to_batch_nd.py



[incubator-tvm] branch main updated (6dc8e22 -> 01b98c1)

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

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


from 6dc8e22  [rust][tvm-graph-rt]: maintain error sources when propagating 
errors, swap Mutex for RwLock (#6815)
 add 01b98c1  Improve AArch64 depthwise convolution through smlal/smlal2 
intrinsic (#6711)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/arm_cpu/depthwise_conv2d.py| 65 +---
 python/tvm/topi/arm_cpu/tensor_intrin.py   | 90 ++
 .../topi/python/test_topi_depthwise_conv2d.py  | 54 +
 3 files changed, 200 insertions(+), 9 deletions(-)



[incubator-tvm] branch main updated (6dc8e22 -> 01b98c1)

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

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


from 6dc8e22  [rust][tvm-graph-rt]: maintain error sources when propagating 
errors, swap Mutex for RwLock (#6815)
 add 01b98c1  Improve AArch64 depthwise convolution through smlal/smlal2 
intrinsic (#6711)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/arm_cpu/depthwise_conv2d.py| 65 +---
 python/tvm/topi/arm_cpu/tensor_intrin.py   | 90 ++
 .../topi/python/test_topi_depthwise_conv2d.py  | 54 +
 3 files changed, 200 insertions(+), 9 deletions(-)



[incubator-tvm] branch main updated (3ea0686 -> 83b75f8)

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

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


from 3ea0686  [FIX,RPC] Skip RPC tests when using multiprocessing's spawn 
method (#6858)
 add 83b75f8  Add smmla/ummla support in quantized Conv2d (#6802)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/arm_cpu/arm_utils.py  |  27 +++-
 python/tvm/topi/arm_cpu/conv2d_gemm.py| 179 +++---
 python/tvm/topi/arm_cpu/tensor_intrin.py  | 106 -
 tests/python/topi/python/test_topi_conv2d_int8.py |   6 +
 4 files changed, 252 insertions(+), 66 deletions(-)



[tvm] branch main updated: [Auto Scheduler][fix] Add dense strategy for mali (#7181)

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

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


The following commit(s) were added to refs/heads/main by this push:
 new 712b4a5  [Auto Scheduler][fix] Add dense strategy for mali (#7181)
712b4a5 is described below

commit 712b4a553fb417b743407be9194c0c4a545978d9
Author: leowang1225 <810916...@qq.com>
AuthorDate: Wed Dec 30 20:32:43 2020 +0800

[Auto Scheduler][fix] Add dense strategy for mali (#7181)

Signed-off-by: leowang1225 <810916...@qq.com>
---
 python/tvm/relay/op/strategy/mali.py | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/python/tvm/relay/op/strategy/mali.py 
b/python/tvm/relay/op/strategy/mali.py
index c4cb4a1..fc47bd6 100644
--- a/python/tvm/relay/op/strategy/mali.py
+++ b/python/tvm/relay/op/strategy/mali.py
@@ -171,9 +171,16 @@ def 
conv2d_winograd_without_weight_transfrom_strategy_mali(attrs, inputs, out_ty
 def dense_strategy_mali(attrs, inputs, out_type, target):
 """dense mali strategy"""
 strategy = _op.OpStrategy()
-strategy.add_implementation(
-wrap_compute_dense(topi.mali.dense),
-wrap_topi_schedule(topi.mali.schedule_dense),
-name="dense.mali",
-)
+if not is_auto_scheduler_enabled():
+strategy.add_implementation(
+wrap_compute_dense(topi.mali.dense),
+wrap_topi_schedule(topi.mali.schedule_dense),
+name="dense.mali",
+)
+else:
+strategy.add_implementation(
+wrap_compute_dense(topi.nn.dense, need_auto_scheduler_layout=True),
+naive_schedule,
+name="dense.mali",
+)
 return strategy



[tvm] branch main updated (d052752 -> 23bd825)

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

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


from d052752  [ConvertLayout] slice_like support (#7184)
 add 23bd825  [AutoScheduler] Add custom build function (#7185)

No new revisions were added by this update.

Summary of changes:
 python/tvm/auto_scheduler/measure.py | 44 
 1 file changed, 35 insertions(+), 9 deletions(-)



[tvm] branch main updated (727345e -> e8ab607)

2021-01-20 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


from 727345e  [COMMUNITY] tkonolige -> Reviewer (#7311)
 add e8ab607  [TFLite] Strided slice handling of shrink_axis_mask improved 
(#6998)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  |  7 ++-
 python/tvm/testing.py|  3 +++
 tests/python/frontend/tflite/test_forward.py | 18 ++
 tests/python/integration/test_dot.py |  4 ++--
 tests/python/integration/test_reduce.py  | 14 +++---
 5 files changed, 36 insertions(+), 10 deletions(-)



[tvm] branch main updated: [AutoScheduler] Separate shapes from DAG hash and enable schedule sharing (#7317)

2021-01-25 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new e6d5318  [AutoScheduler] Separate shapes from DAG hash and enable 
schedule sharing (#7317)
e6d5318 is described below

commit e6d53185b96cc39f2aaec5e86ae11ca0ac675b8a
Author: Cody Yu 
AuthorDate: Mon Jan 25 03:27:34 2021 -0800

[AutoScheduler] Separate shapes from DAG hash and enable schedule sharing 
(#7317)

* [AutoScheduler] Separate shapes from DAG hash and enable schedule sharing

* Update CI logs

* lint

* fix registry

* add message; fix layout rewrite mismatch

* update message

* support other formats
---
 include/tvm/auto_scheduler/compute_dag.h   |   7 ++
 python/tvm/auto_scheduler/compute_dag.py   |  35 +++---
 python/tvm/auto_scheduler/measure_record.py| 126 +++--
 python/tvm/auto_scheduler/relay_integration.py |   6 +-
 python/tvm/auto_scheduler/search_task.py   |   8 +-
 python/tvm/auto_scheduler/utils.py |  27 +
 python/tvm/auto_scheduler/workload_registry.py |  37 +++---
 src/auto_scheduler/compute_dag.cc  | 109 ++
 .../python/unittest/test_auto_scheduler_measure.py |  33 ++
 .../ci_logs/resnet-18-NHWC-B1-cuda.json|  48 
 .../ci_logs/resnet-50-NHWC-B1-llvm.json|  55 +
 11 files changed, 342 insertions(+), 149 deletions(-)

diff --git a/include/tvm/auto_scheduler/compute_dag.h 
b/include/tvm/auto_scheduler/compute_dag.h
index 1e3f097..a87563e 100755
--- a/include/tvm/auto_scheduler/compute_dag.h
+++ b/include/tvm/auto_scheduler/compute_dag.h
@@ -263,6 +263,13 @@ class ComputeDAG : public ObjectRef {
   String PrintStepsAsPython(const Array& transform_steps) const;
 
   /*!
+   * \brief Print the compute DAG to a string. This is also used to generate 
the ComputeDAG hash.
+   * \param simple_mode Simple mode will only include the op names and brief 
compute.
+   * \return The ComputeDAG in a string.
+   */
+  String PrintDAG(bool simple_mode = false) const;
+
+  /*!
* \brief Fill the correct bound information for a given state by calling 
ir_pass::InferBound.
* The states can lose complete bound information after some transform steps 
(e.g., compute_at).
* We can call this function to infer and fill all the bound information.
diff --git a/python/tvm/auto_scheduler/compute_dag.py 
b/python/tvm/auto_scheduler/compute_dag.py
index a7f200a..948f277 100755
--- a/python/tvm/auto_scheduler/compute_dag.py
+++ b/python/tvm/auto_scheduler/compute_dag.py
@@ -19,11 +19,11 @@
 """ The auto-scheduler's computational graph and related program analyses. """
 
 import hashlib
+import json
 
 import tvm._ffi
 from tvm.runtime import Object
 from tvm.runtime._ffi_node_api import LoadJSON, SaveJSON
-from tvm.te import ComputeOp, PlaceholderOp
 
 from . import _ffi_api
 from .loop_state import State, StateObject
@@ -220,32 +220,23 @@ class ComputeDAG(Object):
 state_obj = state if isinstance(state, StateObject) else 
state.state_object
 return _ffi_api.ComputeDAGRewriteLayoutFromState(self, state_obj)
 
-def hash_key(self):
-"""Return the hash key of this compute DAG.
+def workload_key(self):
+"""Return the workload key of this compute DAG.
+The workload key is a JSON string from a tuple of (hash-key, tensor 
shapes...)
 
 Returns
 ---
 key: str
-The hash key of this compute DAG
+The workload key of this compute DAG
 """
-# TODO(merrymercy): Implement this more carefully and move this to c++ 
as a member function
-# of ComputeDAG
-str_key = ""
-for op in self.ops:
-t = op.output(0)
-if isinstance(op, PlaceholderOp):
-str_key += "placeholder,"
-str_key += str(get_const_tuple(t.shape)) + ","
-str_key += t.dtype + ";"
-elif isinstance(op, ComputeOp):
-str_key += str(t.op.body) + ","
-str_key += str(get_const_tuple(t.shape)) + ","
-str_key += t.dtype + ";"
-else:
-raise ValueError("Invalid op: " + op)
-
-str_key = str_key.encode(encoding="utf-8")
-return hashlib.md5(str_key).hexdigest()
+str_dag = _ffi_api.ComputeDAGPrintDAG(self, True)
+str_dag = str_dag.encode(encoding="utf-8")
+hash_key = hashlib.md5(str_dag).hexdigest()
+
+io_shapes = []
+for tensor in self.tensors:
+io_shapes += get_const_tuple(tensor

[tvm] branch main updated: [Frontend][TFLite] Densify Op added (#7048)

2021-01-13 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 006b9b5  [Frontend][TFLite] Densify Op added (#7048)
006b9b5 is described below

commit 006b9b53ab97e677933011d8b36a98a5a4ac7723
Author: ANSHUMAN TRIPATHY 
AuthorDate: Wed Jan 13 19:50:02 2021 +0530

[Frontend][TFLite] Densify Op added (#7048)

* [Frontend][TFLite] Densify Op added

* [1] Review comments handled

* TODO added for sparse_to_dense Op usage

* stale comments removed
---
 python/tvm/relay/frontend/tflite.py  | 215 +--
 tests/python/frontend/tflite/test_forward.py |  48 ++
 2 files changed, 253 insertions(+), 10 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index 7a2aada..525fb41 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -65,6 +65,7 @@ class OperatorConverter(object):
 self.builtin_op_code = build_str_map(BuiltinOperator())
 self.activation_fn_type = build_str_map(ActivationFunctionType())
 self.builtin_options = build_str_map(BuiltinOptions())
+self.prefetched_nodes = {}
 
 # Add more operators
 self.convert_map = {
@@ -80,6 +81,7 @@ class OperatorConverter(object):
 "CONCATENATION": self.convert_concatenation,
 "CONV_2D": self.convert_conv2d,
 "COS": self.convert_cos,
+"DENSIFY": self.convert_densify,
 "DEPTH_TO_SPACE": self.convert_depth_to_space,
 "DEPTHWISE_CONV_2D": self.convert_depthwise_conv2d,
 "DEQUANTIZE": self.convert_dequantize,
@@ -200,6 +202,10 @@ class OperatorConverter(object):
 assert isinstance(op, Operator)
 ret = self.convert_map[op_code_str](op)
 
+# In case the Op can be prefetched, the output can be optimized out
+if ret is None:
+continue
+
 if len(output_tensors) == 1:
 tensor_idx = output_tensors[0].tensor_idx
 self.exp_tab.set_expr(get_tensor_name(self.subgraph, 
tensor_idx), ret)
@@ -338,7 +344,8 @@ class OperatorConverter(object):
 "Tensor type '{}' currently not 
supported".format(tensor_wrapper.tensor.Type())
 )
 
-def get_tensor_value(self, tensor_wrapper):
+# pylint: disable=no-else-return
+def get_tensor_value(self, tensor_wrapper, is_sparse=False):
 """Get tensor buffer value from given tensor wrapper"""
 assert isinstance(tensor_wrapper, TensorWrapper)
 
@@ -350,7 +357,10 @@ class OperatorConverter(object):
 else:
 shape = []
 
-return np.frombuffer(data, dtype=dtype).reshape(shape)
+if is_sparse:
+return np.frombuffer(data, dtype=dtype)
+else:
+return np.frombuffer(data, dtype=dtype).reshape(shape)
 
 def get_tensor_type_str(self, tensor_type):
 """Get tensor type string representation when given TFLite tensor 
type"""
@@ -1662,11 +1672,15 @@ class OperatorConverter(object):
 axis = tuple(axis_value) if len(axis_value.shape) > 0 else 
tuple((axis_value.item(),))
 
 # Options - keep_dims (bool)
-assert op.BuiltinOptionsType() == BuiltinOptions.ReducerOptions
-reduce_options = ReducerOptions()
-op_options = op.BuiltinOptions()
-reduce_options.Init(op_options.Bytes, op_options.Pos)
-keep_dims = reduce_options.KeepDims()
+# In case Options are not present, set keep_dims to False(default)
+if op.BuiltinOptionsType():
+assert op.BuiltinOptionsType() == BuiltinOptions.ReducerOptions
+reduce_options = ReducerOptions()
+op_options = op.BuiltinOptions()
+reduce_options.Init(op_options.Bytes, op_options.Pos)
+keep_dims = reduce_options.KeepDims()
+else:
+keep_dims = False
 
 if input_tensor.qnn_params:
 in_expr = _op.cast(in_expr, "int32")
@@ -2026,7 +2040,11 @@ class OperatorConverter(object):
 else:
 weight_expr = _op.transpose(weight_expr, axes=(1, 2, 3, 0))
 else:
-weight_value = self.get_tensor_value(weight_tensor)
+if self.is_prefetched(weight_tensor.tensor_idx):
+weight_value = 
self.get_prefetched_node(weight_tensor.tensor_idx)
+else:
+weight_value = self.get_tensor_value(weight_tensor)
+
 # TFLite kernel layout:
 # convolution:
 # OC KH KW IC, we require KH KW IC OC (HWIO)
@@ -3196,22 +3214,199 @@ class OperatorConve

[tvm] branch main updated (618ef9e -> 2e8133d)

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

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


from 618ef9e  [TOPI] Add einsum operator (#6370)
 add 2e8133d  [TFLite] Added check for dynamic range quantization (#7114)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  | 34 +---
 tests/python/frontend/tflite/test_forward.py | 21 +
 2 files changed, 52 insertions(+), 3 deletions(-)



[tvm] branch main updated: [CMake] use wrong flag name (#7341)

2021-01-26 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new c53030f  [CMake] use wrong flag name (#7341)
c53030f is described below

commit c53030f40e6911a10555097230f69809bc5af73f
Author: windclarion 
AuthorDate: Tue Jan 26 21:51:24 2021 +0800

[CMake] use wrong flag name (#7341)

Signed-off-by: windclarion 
---
 CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6929dd6..98dd7de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -375,9 +375,9 @@ add_library(tvm_objs OBJECT ${COMPILER_SRCS} 
${RUNTIME_SRCS})
 add_library(tvm_runtime_objs OBJECT ${RUNTIME_SRCS})
 
 add_library(tvm SHARED $)
-set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAGS}")
+set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
 add_library(tvm_runtime SHARED $)
-set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS 
"${TVM_VISIBILITY_FLAGS}")
+set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS 
"${TVM_VISIBILITY_FLAG}")
 
 if(USE_MICRO)
   # NOTE: cmake doesn't track dependencies at the file level across 
subdirectories. For the



[tvm] branch main updated: [Frontend][Tensorflow] Sparse dense matmul adjoint option added (#7267)

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

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


The following commit(s) were added to refs/heads/main by this push:
 new dda8f5d  [Frontend][Tensorflow] Sparse dense matmul adjoint option 
added (#7267)
dda8f5d is described below

commit dda8f5d944747b9f48b9155e866fd0f746fcd9bb
Author: ANSHUMAN TRIPATHY 
AuthorDate: Thu Jan 28 11:28:13 2021 +0530

[Frontend][Tensorflow] Sparse dense matmul adjoint option added (#7267)

* [Frontend][Tensorflow] Sparse dense matmul adjoint option added

* [1] Review comments handled

* [2] Review comments handled

* [3] Review comments handled
---
 python/tvm/relay/frontend/tensorflow.py  | 69 
 tests/python/frontend/tensorflow/test_forward.py | 12 +++--
 2 files changed, 53 insertions(+), 28 deletions(-)

diff --git a/python/tvm/relay/frontend/tensorflow.py 
b/python/tvm/relay/frontend/tensorflow.py
index 2c7361a..b34e6c7 100644
--- a/python/tvm/relay/frontend/tensorflow.py
+++ b/python/tvm/relay/frontend/tensorflow.py
@@ -926,13 +926,6 @@ def _sparse_tensor_dense_matmul():
 
 data = inputs[3]
 
-# By default, in tensorflow the first input ,i.e., data is sparse
-sparse_lhs = True
-
-# If both are true means First input was dense and second was sparse
-if attr.get("adjoint_a") and attr.get("adjoint_b"):
-sparse_lhs = False
-
 rows = [x[0] for x in indices_tensor]
 cols = [x[1] for x in indices_tensor]
 
@@ -941,9 +934,53 @@ def _sparse_tensor_dense_matmul():
 (values_tensor, (rows, cols)), 
shape=tuple(dense_shape_tensor.tolist())
 )
 
-if sparse_lhs:
+# As per tensorflow implementation, we have 4 possible input 
combination
+# and the first input(A) is always sparse and second input(B) is 
always dense.
+# Case 1: A , B , adjoint_a=False, adjoint_b=False  --> A * B
+# Case 2: A , B , adjoint_a=True,   adjoint_b=False  --> A.T * B
+# Case 3: A , B , adjoint_a=False, adjoint_b=True--> A * B.T
+# Case 4: A , B , adjoint_a=True,   adjoint_b=True--> A.T * B.T
+#
+# Topi implementation for sparse_dense(matmul) has 2 possible input
+# combination where first input(A) is always dense
+# and second input(B) is always sparse.
+# Case 1: A , B, sparse_lhs = False  --> A * B.T
+# Case 2: A , B, sparse_lhs = True--> B * A.T
+#
+# The mapping would be as below:
+# TF Case 1: A , B , adjoint_a=False, adjoint_b=False
+#   --> In TF: A * B   --> In Topi: A * B.T.T
+#   --> sparse_dense(transpose(B), A, sparse_lhs=True)
+#
+# TF Case 2: A , B , adjoint_a=True, adjoint_b=False
+#   --> In TF: A.T * B   --> In Topi: A.T * B.T.T
+#   --> sparse_dense(transpose(B), transpose(A), 
sparse_lhs=True)
+#
+# TF Case 3: A , B , adjoint_a=False, adjoint_b=True
+#   --> In TF: A * B.T   --> In Topi: A * B
+#   --> sparse_dense(B, A, sparse_lhs=True)
+#
+# TF Case 4: A , B , adjoint_a=True, adjoint_b=True
+#   --> In TF: A.T * B.T   --> In Topi: (B * A.T).T
+#   --> transpose(sparse_dense(B, transpose(A), 
sparse_lhs=False))
+
+# By default, in tensorflow the first input ,i.e., data is sparse
+sparse_lhs = True
+
+# TF Case 1:
+if not attr.get("adjoint_a") and not attr.get("adjoint_b"):
+data = _op.transpose(data)
+# TF Case 2:
+elif attr.get("adjoint_a") and not attr.get("adjoint_b"):
 data = _op.transpose(data)
+weight_sp = csr_matrix(weight_sp.transpose())
+# TF Case 3:
+elif not attr.get("adjoint_a") and attr.get("adjoint_b"):
+pass
+# TF Case 4:
+# attr.get("adjoint_a") and attr.get("adjoint_b"):
 else:
+sparse_lhs = False
 weight_sp = csr_matrix(weight_sp.transpose())
 
 weight_data = _expr.const(weight_sp.data, weight_sp.data.dtype)
@@ -953,23 +990,9 @@ def _sparse_tensor_dense_matmul():
 ret = _op.nn.sparse_dense(data, [weight_data, weight_indices, 
weight_indptrs], sparse_lhs)
 
 if not sparse_lhs:
+# TF Case 4
 ret = _op.transpose(ret)
 
-# Case 1. If both are true means first input was dense and second was 
sparse
-# Case 2. If both are false means first input was sparse and second 
was dense
-# TODO(ANSHUMAN87): Support other adjoint option too
-if not (
-(attr.get("adjoint_a") and at

[tvm] branch main updated (5537788 -> c208a1f)

2021-06-20 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


from 5537788  [VM][PooledAllocator] try reallocation once when OOM (#8285)
 add c208a1f  support adb-shell style cpp_rpc (#8223)

No new revisions were added by this update.

Summary of changes:
 apps/cpp_rpc/rpc_env.cc| 12 +++-
 apps/cpp_rpc/rpc_server.cc |  2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)


[tvm] branch main updated (4d9bc9b -> 34e9a4f)

2021-06-09 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


from 4d9bc9b  [RUNTIME] ShapeTuple Container (#8200)
 add 34e9a4f  [Frontend, Tensorflow, Tensorflow2] Tensorflow frontend op 
refactor (#8179)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tensorflow.py| 2974 +---
 python/tvm/relay/frontend/tensorflow2.py   |4 +-
 .../frontend/{tensorflow.py => tensorflow_ops.py}  | 1202 +---
 3 files changed, 9 insertions(+), 4171 deletions(-)
 copy python/tvm/relay/frontend/{tensorflow.py => tensorflow_ops.py} (70%)


[tvm] branch main updated (5a2ded7 -> d789875)

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

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


from 5a2ded7  [BYOC] Remove ext params stored in metadata from params to 
avoid duplication (#7977)
 add d789875  adding Leandro to committers (#7999)

No new revisions were added by this update.

Summary of changes:
 CONTRIBUTORS.md | 1 +
 1 file changed, 1 insertion(+)


[tvm] branch main updated (aba2806 -> e438a73)

2021-05-20 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


from aba2806  [CI][Docker] set environment variables for UTF-8, to prevent 
errors when running `black` (#8089)
 add e438a73  [Relay][PRNG] Add uniform distribution generator wrt threefry 
PRNG (#8041)

No new revisions were added by this update.

Summary of changes:
 include/tvm/relay/attrs/random.h   | 12 ++
 python/tvm/relay/op/op_attrs.py|  5 +++
 python/tvm/relay/op/random/_kernel.py  |  4 ++
 python/tvm/relay/op/random/kernel.py   | 54 +++-
 python/tvm/relay/op/strategy/generic.py| 22 ++
 python/tvm/topi/random/kernel.py   | 66 ++
 src/relay/op/random/kernel.cc  | 47 +
 tests/python/relay/test_prng.py| 15 +++
 tests/python/topi/python/test_topi_prng.py | 34 +++
 9 files changed, 258 insertions(+), 1 deletion(-)


[tvm] branch main updated: [Hexagon] Reenable compilation of TVM runtime for Hexagon (#7784)

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

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


The following commit(s) were added to refs/heads/main by this push:
 new 7b43db1  [Hexagon] Reenable compilation of TVM runtime for Hexagon 
(#7784)
7b43db1 is described below

commit 7b43db1bb83855d53bb8588be1df0fcbdc0a610a
Author: Krzysztof Parzyszek 
AuthorDate: Thu Apr 1 21:47:19 2021 -0500

[Hexagon] Reenable compilation of TVM runtime for Hexagon (#7784)

- Add support for Hexagon SDK 4.x (different directory structure)
- Conditionally disable functions not present on Hexagon (popen, etc.)
- Bump sim_dev architecture target to v65 (older versions can still be
  used with older compilers).

Co-authored-by: Ravishankar Kolachana 

Co-authored-by: Ravishankar Kolachana 
---
 CMakeLists.txt|  6 
 cmake/modules/Hexagon.cmake   | 48 ---
 src/runtime/hexagon/sim/driver/CMakeLists.txt |  2 +-
 src/support/utils.h   | 14 +++-
 4 files changed, 58 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 277fe4a..8279687 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -449,12 +449,6 @@ if(BUILD_FOR_HEXAGON)
   # Wrap pthread_create to allow setting custom stack size.
   set_property(TARGET tvm_runtime APPEND PROPERTY LINK_FLAGS
 "-Wl,--wrap=pthread_create")
-
-  target_include_directories(tvm_runtime SYSTEM
-PUBLIC "${USE_HEXAGON_SDK}/libs/common/qurt/ADSPv62MP/include/posix"
-PUBLIC "${USE_HEXAGON_SDK}/libs/common/qurt/ADSPv62MP/include/qurt"
-PUBLIC "${USE_HEXAGON_SDK}/incs"
-PUBLIC "${USE_HEXAGON_SDK}/incs/stddef")
 endif()
 
 if(USE_THREADS AND NOT BUILD_FOR_HEXAGON)
diff --git a/cmake/modules/Hexagon.cmake b/cmake/modules/Hexagon.cmake
index 9fc806c..80df76b 100644
--- a/cmake/modules/Hexagon.cmake
+++ b/cmake/modules/Hexagon.cmake
@@ -21,8 +21,14 @@ set(PICK_SIM  "sim")
 set(PICK_HW   "target")
 set(PICK_NONE "OFF")
 
+set(FOUND_HEXAGON_SDK_ROOT  FALSE)
+set(FOUND_HEXAGON_TOOLCHAIN FALSE)
+
 function(find_hexagon_toolchain)
-  if (NOT "${USE_HEXAGON_TOOLCHAIN}" STREQUAL "")
+  if(FOUND_HEXAGON_TOOLCHAIN)
+return()
+  endif()
+  if(NOT "${USE_HEXAGON_TOOLCHAIN}" STREQUAL "")
 set(TRY_PATH "${USE_HEXAGON_TOOLCHAIN}")
   else()
 set(TRY_PATH "${USE_HEXAGON_SDK}")
@@ -35,12 +41,16 @@ function(find_hexagon_toolchain)
 get_filename_component(HEXAGON_TMP1 "${HEXAGON_TMP0}" DIRECTORY)
 set(HEXAGON_TOOLCHAIN "${HEXAGON_TMP1}" CACHE PATH
 "Path to the Hexagon toolchain")
+set(FOUND_HEXAGON_TOOLCHAIN TRUE)
   else(HEXAGON_CLANG)
 message(SEND_ERROR "Cannot find Hexagon toolchain in ${TRY_PATH}")
   endif()
 endfunction()
 
 function(find_hexagon_sdk_root)
+  if(FOUND_HEXAGON_SDK_ROOT)
+return()
+  endif()
   message(STATUS "Checking Hexagon SDK root: ${USE_HEXAGON_SDK}")
   file(GLOB_RECURSE HEXAGON_AEESTDDEF "${USE_HEXAGON_SDK}/*/AEEStdDef.h")
   if(HEXAGON_AEESTDDEF)
@@ -50,11 +60,30 @@ function(find_hexagon_sdk_root)
 get_filename_component(HEXAGON_TMP2 "${HEXAGON_TMP1}" DIRECTORY)
 set(HEXAGON_SDK_ROOT "${HEXAGON_TMP2}" CACHE PATH
 "Root directory of Hexagon SDK")
+set(FOUND_HEXAGON_SDK_ROOT TRUE)
   else(HEXAGON_AEESTDDEF)
 message(SEND_ERROR "Cannot validate Hexagon SDK in ${USE_HEXAGON_SDK}")
   endif()
 endfunction()
 
+if(BUILD_FOR_HEXAGON)
+  find_hexagon_sdk_root()
+  if(HEXAGON_SDK_ROOT MATCHES "3.5.1")
+message(SEND_ERROR "Hexagon SDK 3.5.1 is not supported")
+  elseif(HEXAGON_SDK_ROOT MATCHES "3\.[0-9]+\.[0-9]+")
+include_directories(
+  SYSTEM "${USE_HEXAGON_SDK}/libs/common/qurt/ADSPv62MP/include/posix"
+  SYSTEM "${USE_HEXAGON_SDK}/libs/common/qurt/ADSPv62MP/include/qurt")
+  else()
+include_directories(
+  SYSTEM "${HEXAGON_SDK_ROOT}/rtos/qurt/computev65/include/posix"
+  SYSTEM "${HEXAGON_SDK_ROOT}/rtos/qurt/computev65/include/qurt")
+  endif()
+  include_directories(
+SYSTEM "${HEXAGON_SDK_ROOT}/incs"
+SYSTEM "${HEXAGON_SDK_ROOT}/incs/stddef")
+endif()
+
 if(USE_HEXAGON_DEVICE STREQUAL "OFF")
   list(APPEND COMPILER_SRCS src/target/opt/build_hexagon_off.cc)
   return()
@@ -67,7 +96,7 @@ elseif(NOT USE_HEXAGON_DEVICE STREQUAL "${PICK_SIM}" AND
 endif()
 # If USE_HEXAGON_DEVICE is set to a valid value, make sure that USE_HEXAGON_SDK
 # is defined.
-if (NOT USE_HEXAGON_SDK)
+if(NOT USE_HEXAGON_SDK)
   message(SEND_ERROR "Please set USE_HEXAGON_SDK to the Hexagon SDK root&

[tvm] branch main updated (3ba5868 -> 7130e80)

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

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


from 3ba5868  [TensorIR] Fix parser autocompletion mode (#7737)
 add 7130e80  Better grouped convolution for CPU targets (#6137)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/op/strategy/arm_cpu.py |   7 +-
 python/tvm/relay/op/strategy/x86.py |   8 +-
 python/tvm/topi/arm_cpu/__init__.py |   1 +
 python/tvm/topi/arm_cpu/group_conv2d.py | 370 +++
 python/tvm/topi/x86/__init__.py |   1 +
 python/tvm/topi/x86/group_conv2d.py | 371 
 6 files changed, 749 insertions(+), 9 deletions(-)
 create mode 100644 python/tvm/topi/arm_cpu/group_conv2d.py
 create mode 100644 python/tvm/topi/x86/group_conv2d.py


[tvm] branch main updated (431a7d6 -> e467748)

2021-03-18 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


from 431a7d6  Default value for graph_runtime Init lookup_linked_param_func 
(#7676)
 add e467748  [CPP_RPC] allow user supplied work dir (#7670)

No new revisions were added by this update.

Summary of changes:
 apps/cpp_rpc/main.cc   | 10 +-
 apps/cpp_rpc/rpc_env.cc| 35 ---
 apps/cpp_rpc/rpc_env.h |  2 +-
 apps/cpp_rpc/rpc_server.cc | 21 -
 apps/cpp_rpc/rpc_server.h  |  3 ++-
 5 files changed, 44 insertions(+), 27 deletions(-)


[tvm] branch main updated: [Frontend][Tensorflow] Support explicit_paddings for TF 2.x (#7445)

2021-02-19 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 5688068  [Frontend][Tensorflow] Support explicit_paddings for TF 2.x 
(#7445)
5688068 is described below

commit 5688068eb02912a4ec926a88f5cad3f0f370454e
Author: Trevor Morris 
AuthorDate: Fri Feb 19 20:26:55 2021 -0800

[Frontend][Tensorflow] Support explicit_paddings for TF 2.x (#7445)

* Ignore some TF2.0 attributes

* Support explicit padding for conv2d, max_pool, conv3d

* Remove conv3d explicit padding test since TF API doesn't allow it
---
 python/tvm/relay/frontend/tensorflow.py  | 44 +---
 tests/python/frontend/tensorflow/test_forward.py | 40 +
 2 files changed, 79 insertions(+), 5 deletions(-)

diff --git a/python/tvm/relay/frontend/tensorflow.py 
b/python/tvm/relay/frontend/tensorflow.py
index 6a29ce2..ac52ab7 100644
--- a/python/tvm/relay/frontend/tensorflow.py
+++ b/python/tvm/relay/frontend/tensorflow.py
@@ -268,6 +268,13 @@ def _pooling(name):
 pad_h = _get_pad_pair(in_w, kernel_w, stride_w)
 
 attr["padding"] = [pad_v[0], pad_h[0], pad_v[1], pad_h[1]]
+elif attr["padding"] == "EXPLICIT":
+paddings = attr["explicit_paddings"]
+assert len(paddings) == 8
+if flip_layout or attr["data_format"] == "NHWC":
+attr["padding"] = [paddings[2], paddings[4], paddings[3], 
paddings[5]]
+else:
+attr["padding"] = [paddings[4], paddings[6], paddings[5], 
paddings[7]]
 else:
 msg = 'Value {} in attribute "padding" of operator Pooling is ' 
"not valid."
 raise tvm.error.OpAttributeInvalid(msg.format(attr["padding"]))
@@ -278,7 +285,7 @@ def _pooling(name):
 out = AttrCvt(
 op_name=_dimension_picker(name),
 transforms={"kernel_shape": "pool_size", "data_format": "layout"},
-ignores=["ksize"],
+ignores=["ksize", "explicit_paddings"],
 extras={"ceil_mode": False},
 custom_check=_dimension_constraint(),
 )(inputs, attr)
@@ -418,6 +425,13 @@ def _conv(opname):
 pad_h = _get_pad_pair(in_w, dilated_kernel_w, stride_w)
 
 attr["padding"] = [pad_v[0], pad_h[0], pad_v[1], pad_h[1]]
+elif attr["padding"] == "EXPLICIT":
+paddings = attr["explicit_paddings"]
+assert len(paddings) == 8
+if flip_layout or attr["data_format"] == "NHWC":
+attr["padding"] = [paddings[2], paddings[4], paddings[3], 
paddings[5]]
+else:
+attr["padding"] = [paddings[4], paddings[6], paddings[5], 
paddings[7]]
 else:
 msg = 'Value {} in attribute "padding" of operator Conv is not ' 
"valid."
 raise tvm.error.OpAttributeInvalid(msg.format(attr["padding"]))
@@ -626,7 +640,27 @@ def _conv3d(opname):
 pad_h = _get_pad_pair(in_w, dilated_kernel_w, stride_w)
 
 attr["padding"] = [pad_d[0], pad_v[0], pad_h[0], pad_d[1], 
pad_v[1], pad_h[1]]
-
+elif attr["padding"] == "EXPLICIT":
+paddings = attr["explicit_paddings"]
+assert len(paddings) == 10
+if flip_layout or attr["data_format"] == "NDHWC":
+attr["padding"] = [
+paddings[2],
+paddings[4],
+paddings[6],
+paddings[3],
+paddings[5],
+paddings[7],
+]
+else:
+attr["padding"] = [
+paddings[4],
+paddings[6],
+paddings[8],
+paddings[5],
+paddings[7],
+paddings[9],
+]
 else:
 msg = 'Value {} in attribute "padding" of operator Conv is not ' 
"valid."
 raise tvm.error.OpAttributeInvalid(msg.format(attr["padding"]))
@@ -1445,9 +1479,9 @@ def _squeeze():
 def _impl(inputs, attr, params, mod):
 if len(attr["squeeze_dims"]) == 0:
 attr["squeeze_dims"] = None
-return AttrCvt(op_name="squeeze", transforms={"squeeze_dims": "axis"}, 
ignores=["T"])(
-inputs, attr
-)
+return AttrCvt(
+ 

[tvm] branch main updated (d02e50c -> 2008d62)

2021-08-16 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


from d02e50c  [AutoScheduler][FIX] Fix exception handling in measure.py 
(#8754)
 add 2008d62  add support for half_pixel_centers in resize (#8689)

No new revisions were added by this update.

Summary of changes:
 python/tvm/relay/frontend/tflite.py  |  3 ++
 tests/python/frontend/tflite/test_forward.py | 46 
 2 files changed, 43 insertions(+), 6 deletions(-)


[tvm-rfcs] branch main updated: [RFC][Frontend] Add a PaddlePaddle Frontend (#19)

2021-08-12 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new fc5d5ed  [RFC][Frontend] Add a PaddlePaddle Frontend (#19)
fc5d5ed is described below

commit fc5d5ed74558058df3391089ba79bc98fc73246e
Author: Jason <928090...@qq.com>
AuthorDate: Fri Aug 13 09:47:06 2021 +0800

[RFC][Frontend] Add a PaddlePaddle Frontend (#19)

* add rfc for paddlepaddle frontend

* add rfc for paddlepaddle frontend

* Update add_paddlepaddle_frontend.md

* Update add_paddlepaddle_frontend.md

* Update add_paddlepaddle_frontend.md

* Update add_paddlepaddle_frontend.md

* Update add_paddlepaddle_frontend.md

* refinement

* refinement

* add demo code load model from dist

Co-authored-by: root 
Co-authored-by: will-jl944 
---
 rfcs/add_paddlepaddle_frontend.md | 114 ++
 1 file changed, 114 insertions(+)

diff --git a/rfcs/add_paddlepaddle_frontend.md 
b/rfcs/add_paddlepaddle_frontend.md
new file mode 100644
index 000..c757516
--- /dev/null
+++ b/rfcs/add_paddlepaddle_frontend.md
@@ -0,0 +1,114 @@
+- Feature Name: add-paddlepaddle-frontend
+- Start Date: 2021-08-05
+- RFC PR: https://github.com/apache/tvm-rfcs/pull/19
+- GitHub Issue: TODO
+
+# Summary
+[summary]: #summary
+
+Add a paddlepaddle frontend, enhancing TVM's compatibility for deep learning 
frameworks, which supports PaddlePaddle>=2.0
+
+# Motivation
+[motivation]: #motivation
+
+PaddlePaddle, an independent R deep learning platform in China, has been 
officially open-sourced to professional communities since 2016. It has been 
widely adopted by a wide range of sectors including manufacturing, agriculture, 
enterprise service, and so on while serving more than 2.3 million developers. 
With such advantages, PaddlePaddle has helped an increasing number of partners 
commercialize AI.
+
+Currently, PaddlePaddle has built a prosperous technological ecology, there 
are more than 500 models developed by official organization or outside 
developers, covering CV/NLP/OCR/Speech, refer to the following links for more 
details,
+
+- [PaddlePaddle/models](https://github.com/PaddlePaddle/models)
+- [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection)
+- [PaddleClas](https://github.com/PaddlePaddle/PaddleClas)
+- [PaddleSeg](https://github.com/PaddlePaddle/PaddleSeg)
+- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
+- [PaddleNLP](https://github.com/PaddlePaddle/PaddleNLP)
+- [DeepSpeech](https://github.com/PaddlePaddle/DeepSpeech)
+
+As of version 2.0, PaddlePaddle supports imperative programming like PyTorch. 
Furthermore, a mechanism of `Dynamic to Static` is provided to export a 
PaddlePaddle model to graph representation, which is more friendly for 
deployment. The following example code shows how to export a PaddlePaddle model,
+
+```
+import paddle
+import paddlehub
+model = hub.Module(name="resnet50_vd_imagenet_ssld")
+input_spec = paddle.static.InputSpec(
+[1, 3, 224, 224], "float32", "image")
+paddle.jit.save(model, "model/infer", input_spec=[input_spec])
+```
+
+PaddlePaddle's deployment is supported by Paddle Inference/Paddle 
Lite/OpenVINO/Tengine/Adlik now. We noticed that there are lots of developers 
converting models to ONNX format for the compatibility with TVM, but only a 
limited number of models are convertible due to lack of ONNX operators.  
+Based on this background, we proposed this RFC to add a PaddlePaddle frontend 
for TVM, improving usability for PaddlePaddle users and enhancing the 
compatibility between PaddlePaddle and TVM.
+
+
+# Guide-level explanation
+[guide-level-explanation]: #guide-level-explanation
+
+If you dive into the pull request code, there are 2 concepts imported from 
PaddlePaddle that you may want to know,
+- `paddle.jit.load`: Recommended API to load an exported inference model, the 
type of the return value is `TranslatedLayer`, storing `Program`(similar to 
computation graph) and parameters;
+- `paddle.static.load_inference_model`: API compatible with older version 
PaddlePaddle models, the type of the return value is `Program`. All the 
parameters are saved in `Scope` by default, parameters can be extracted from 
the `paddle.fluid.global_scope()`.
+
+Therefore, this RFC will also add a new API to TVM to support PaddlePaddle 
models,
+```
+relay.frontend.from_paddle(program_or_layer, shape_dict=None, scope=None)
+```
+- `program_or_layer`: the return value of `paddle.static.load_inference_model` 
or `paddle.jit.load`
+- `shape_dict`: optional, input shapes of the model
+- `scope`: optional, which is available only if `model` is loaded using 
`paddle.static.load_inference_model`
+
+The following example code shows how to impor

[tvm] branch main updated: [MetaSchedule] Add the missing HasWorkload interface to the Database (#9756)

2021-12-16 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new b08e8e4  [MetaSchedule] Add the missing HasWorkload interface to the 
Database (#9756)
b08e8e4 is described below

commit b08e8e49b5ea0e406c3ca41610a131dd271f0d41
Author: Junru Shao 
AuthorDate: Thu Dec 16 22:16:31 2021 -0800

[MetaSchedule] Add the missing HasWorkload interface to the Database (#9756)
---
 include/tvm/meta_schedule/database.h   | 25 --
 python/tvm/meta_schedule/database/database.py  | 18 
 src/meta_schedule/database/database.cc |  6 +-
 src/meta_schedule/database/json_database.cc|  4 
 .../python/unittest/test_meta_schedule_database.py | 20 -
 .../unittest/test_meta_schedule_task_scheduler.py  |  3 +++
 6 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/include/tvm/meta_schedule/database.h 
b/include/tvm/meta_schedule/database.h
index 60c6898..f07d8e1 100644
--- a/include/tvm/meta_schedule/database.h
+++ b/include/tvm/meta_schedule/database.h
@@ -156,6 +156,12 @@ class DatabaseNode : public runtime::Object {
   /*! \brief Default destructor */
   virtual ~DatabaseNode() = default;
   /*!
+   * \brief Check if the database has the given workload.
+   * \param mod The IRModule to be searched for.
+   * \return Whether the database has the given workload.
+   */
+  virtual bool HasWorkload(const IRModule& mod) = 0;
+  /*!
* \brief Look up or add workload to the database if missing.
* \param mod The IRModule to be searched for or added.
* \return The workload corresponding to the given IRModule.
@@ -187,6 +193,12 @@ class DatabaseNode : public runtime::Object {
 class PyDatabaseNode : public DatabaseNode {
  public:
   /*!
+   * \brief The function type of `HasWorkload` method.
+   * \param mod The IRModule to be searched for.
+   * \return Whether the database has the given workload.
+   */
+  using FHasWorkload = runtime::TypedPackedFunc;
+  /*!
* \brief The function type of `CommitWorkload` method.
* \param mod The IRModule to be searched for or added.
* \return The workload corresponding to the given IRModule.
@@ -210,6 +222,8 @@ class PyDatabaseNode : public DatabaseNode {
*/
   using FSize = runtime::TypedPackedFunc;
 
+  /*! \brief The packed function to the `HasWorkload` function. */
+  FHasWorkload f_has_workload;
   /*! \brief The packed function to the `CommitWorkload` function. */
   FCommitWorkload f_commit_workload;
   /*! \brief The packed function to the `CommitTuningRecord` function. */
@@ -223,13 +237,18 @@ class PyDatabaseNode : public DatabaseNode {
 // PackedFuncs are all not visited, because the reflection system doesn't 
take care of them,
 // so it cannot be accessible on the python side. If there is such need 
from the future,
 // we can then add corresponding accessor methods to help access on python.
-//
+// `f_has_workload` is not visited
 // `f_commit_workload` is not visited
 // `f_commit_tuning_record` is not visited
 // `f_get_top_k` is not visited
 // `f_size` is not visited
   }
 
+  bool HasWorkload(const IRModule& mod) final {
+ICHECK(f_has_workload != nullptr) << "PyDatabase's HasWorkload method not 
implemented!";
+return f_has_workload(mod);
+  }
+
   Workload CommitWorkload(const IRModule& mod) final {
 ICHECK(f_commit_workload != nullptr) << "PyDatabase's CommitWorkload 
method not implemented!";
 return f_commit_workload(mod);
@@ -271,13 +290,15 @@ class Database : public runtime::ObjectRef {
bool allow_missing);
   /*!
* \brief Create a database with customized methods on the python-side.
+   * \param f_has_workload The packed function of `HasWorkload`.
* \param f_commit_workload The packed function of `CommitWorkload`.
* \param f_commit_tuning_record The packed function of `CommitTuningRecord`.
* \param f_get_top_k The packed function of `GetTopK`.
* \param f_size The packed function of `Size`.
* \return The created database.
*/
-  TVM_DLL static Database PyDatabase(PyDatabaseNode::FCommitWorkload 
f_commit_workload,
+  TVM_DLL static Database PyDatabase(PyDatabaseNode::FHasWorkload 
f_has_workload,
+ PyDatabaseNode::FCommitWorkload 
f_commit_workload,
  PyDatabaseNode::FCommitTuningRecord 
f_commit_tuning_record,
  PyDatabaseNode::FGetTopK f_get_top_k,
  PyDatabaseNode::FSize f_size);
diff --git a/python/tvm/meta_schedule/database/database.py 
b/python/tvm/meta_schedule/database/database.py
index fd746e6..31822f0 100644
--- a/python/tvm/meta_schedule/database/databas

[tvm] branch main updated: [Frontend] Add Span filling for frontends to Relay (#9723)

2021-12-27 Thread zhaowu
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new ce108c1  [Frontend] Add Span filling for frontends to Relay (#9723)
ce108c1 is described below

commit ce108c1f53235a483eb11db8770642907642
Author: Chun-I Tsai 
AuthorDate: Tue Dec 28 12:53:18 2021 +0800

[Frontend] Add Span filling for frontends to Relay (#9723)

* [Frontend] Add Span filling for frontends to Relay

* Add a common span filling feature for tf1/2, tflite and pytorch.
* Add test case for Span filling in each frontend.
* Expose Tuple and TupleGetItem to python end

* [Frontend] Add Span filling for frontends to Relay

* Fix lint errors
* Change default string of scope_part in Pytorch
* Reorder the span position for one to many conversion

* [Frontend] Add Span filling for frontends to Relay

 * nit fixed
 * Add a bool flag to control print span
 * refactor pytorch get span to a birefer way

* [Frontend] Add Span filling for frontends to Relay

* Add one more condition for spanFller
* Refine the format for those pytorch node without scopeName

* [Frontend] Add Span filling for frontends to Relay

* Fix lint
---
 python/tvm/relay/expr.py   |  7 ++-
 python/tvm/relay/frontend/common.py| 53 +
 python/tvm/relay/frontend/pytorch.py   | 19 
 python/tvm/relay/frontend/tensorflow.py| 17 +--
 python/tvm/relay/frontend/tensorflow2.py   | 17 +--
 python/tvm/relay/frontend/tflite.py| 16 +--
 src/printer/relay_text_printer.cc  | 23 ++---
 src/printer/text_printer.h |  2 +-
 src/relay/ir/expr.cc   |  4 +-
 tests/python/frontend/pytorch/test_forward.py  | 47 +++
 tests/python/frontend/tensorflow/test_forward.py   | 54 ++
 .../frontend/tensorflow2/test_sequential_models.py | 24 +-
 tests/python/frontend/tflite/test_forward.py   | 54 ++
 13 files changed, 289 insertions(+), 48 deletions(-)

diff --git a/python/tvm/relay/expr.py b/python/tvm/relay/expr.py
index 811e205..598354e 100644
--- a/python/tvm/relay/expr.py
+++ b/python/tvm/relay/expr.py
@@ -316,10 +316,13 @@ class TupleGetItem(ExprWithOp):
 
 index: int
 The index.
+
+span: Optional[tvm.relay.Span]
+Span that points to original source code
 """
 
-def __init__(self, tuple_value, index):
-self.__init_handle_by_constructor__(_ffi_api.TupleGetItem, 
tuple_value, index)
+def __init__(self, tuple_value, index, span=None):
+self.__init_handle_by_constructor__(_ffi_api.TupleGetItem, 
tuple_value, index, span)
 
 
 @tvm._ffi.register_object("relay.RefCreate")
diff --git a/python/tvm/relay/frontend/common.py 
b/python/tvm/relay/frontend/common.py
index 407afc4..be3d5ae 100755
--- a/python/tvm/relay/frontend/common.py
+++ b/python/tvm/relay/frontend/common.py
@@ -25,6 +25,7 @@ from tvm.ir import IRModule
 from tvm.topi.utils import get_const_tuple
 
 from .. import expr as _expr
+from ..expr_functor import ExprMutator
 from .. import function as _function
 from .. import transform as _transform
 from .. import op as _op
@@ -954,3 +955,55 @@ def try_resolve_var_to_const(x, graph_params):
 return _op.const(value, dtype)
 
 return x
+
+
+def set_span(sym, node_name):
+"""Set up the sapn of relay expression(s) while converting OP"""
+
+class SpanFiller(ExprMutator):
+"""SpanFiller"""
+
+def __init__(self, node_name, suffix_str="_PART_"):
+ExprMutator.__init__(self)
+self.node_name = node_name
+self.suffix_str = suffix_str
+self.counter = 0
+self.distance_from_leaf = -1
+
+def _create_span(self):
+if self.distance_from_leaf == 0:
+return tvm.relay.Span(tvm.relay.SourceName(self.node_name), 0, 
0, 0, 0)
+self.distance_from_leaf -= 1
+span_str = "{}{}{}".format(self.node_name, self.suffix_str, 
str(self.counter))
+self.counter += 1
+return tvm.relay.Span(tvm.relay.SourceName(span_str), 0, 0, 0, 0)
+
+def visit_call(self, call):
+if call.span is None:
+self.distance_from_leaf += 1
+new_args = [self.visit(arg) for arg in call.args]
+return _expr.Call(
+call.op, new_args, call.attrs, call.type_args, 
self._create_span()
+)
+return call
+
+def visit_tuple(self, tup):
+if tup.span is 

[tvm] branch main updated (a6e620937b -> ceed331606)

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

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


from a6e620937b [RUNTIME] Api to get number of runtime threads (#10896)
 add ceed331606 [LLVM] Support CodeGenBlob for large >2GB models on x86 
(#10882)

No new revisions were added by this update.

Summary of changes:
 src/target/llvm/codegen_blob.cc | 12 
 1 file changed, 12 insertions(+)



  1   2   >