[tvm] branch main updated: [Target] LLVM helper functions for any target info (#15761)

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

kparzysz 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 cf8521ad5c [Target] LLVM helper functions for any target info (#15761)
cf8521ad5c is described below

commit cf8521ad5c4052e94103ca66dd782c5a4a1bc137
Author: Balint Cristian 
AuthorDate: Wed Sep 27 22:09:53 2023 +0300

[Target] LLVM helper functions for any target info (#15761)
---
 cmake/modules/LLVM.cmake   |   3 +
 python/tvm/target/codegen.py   |  93 --
 python/tvm/target/x86.py   |  28 +--
 python/tvm/topi/x86/batch_matmul.py|   8 +-
 python/tvm/topi/x86/dense.py   |   9 +-
 python/tvm/topi/x86/dense_alter_op.py  |   5 +-
 .../space_generator/space_generator.cc |  19 +-
 src/relay/qnn/op/requantize.cc |   6 +-
 src/relay/qnn/op/requantize_config.h   |   6 +-
 src/target/llvm/codegen_x86_64.cc  |  39 +---
 src/target/llvm/llvm_instance.cc   | 154 +++-
 src/target/llvm/llvm_instance.h|  30 
 src/target/llvm/llvm_module.cc | 197 ++---
 tests/python/relay/test_op_level2.py   |   5 +-
 tests/python/relay/test_op_qnn_conv2_transpose.py  |   2 +-
 tests/python/relay/test_op_qnn_conv2d.py   |   4 +-
 tests/python/relay/test_pass_alter_op_layout.py|   6 +-
 tests/python/relay/test_pass_qnn_legalize.py   |  14 +-
 tests/python/target/test_llvm_features_info.py | 104 +++
 tests/python/target/test_x86_features.py   | 155 
 tests/python/unittest/test_target_codegen_llvm.py  |   2 +-
 21 files changed, 538 insertions(+), 351 deletions(-)

diff --git a/cmake/modules/LLVM.cmake b/cmake/modules/LLVM.cmake
index 6c21356ae8..6fb74fc1ef 100644
--- a/cmake/modules/LLVM.cmake
+++ b/cmake/modules/LLVM.cmake
@@ -29,6 +29,9 @@ add_definitions(-DDMLC_USE_FOPEN64=0 -DNDEBUG=1)
 # It may be a boolean or a string
 if(NOT ${USE_LLVM} MATCHES ${IS_FALSE_PATTERN})
   find_llvm(${USE_LLVM})
+  if (${TVM_LLVM_VERSION} LESS 60)
+message(FATAL_ERROR "LLVM version 6.0 or greater is required.")
+  endif()
   include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
   add_definitions(${LLVM_DEFINITIONS})
   message(STATUS "Build with LLVM " ${LLVM_PACKAGE_VERSION})
diff --git a/python/tvm/target/codegen.py b/python/tvm/target/codegen.py
index 5d43f4ae24..1a2efd4efa 100644
--- a/python/tvm/target/codegen.py
+++ b/python/tvm/target/codegen.py
@@ -17,6 +17,7 @@
 """Code generation related functions."""
 from . import _ffi_api
 from .target import Target
+from ..ir.container import Array
 
 
 def build_module(mod, target):
@@ -39,6 +40,30 @@ def build_module(mod, target):
 return _ffi_api.Build(mod, target)
 
 
+def target_has_features(cpu_features, target=None):
+"""Check CPU features for the target's `-mtriple` and `-mcpu` and `-mattr`.
+
+Parameters
+--
+target : Target
+The TVM target.
+cpu_features : str or Array
+CPU Feature(s) to check.
+
+Returns
+---
+has_features : bool
+True if target has the feature(s).
+"""
+assert isinstance(target, Target) or target is None
+assert isinstance(cpu_features, (Array, list, tuple, str))
+has_feats = True
+cpu_features = [cpu_features] if isinstance(cpu_features, str) else 
cpu_features
+for feat in cpu_features:
+has_feats &= _ffi_api.target_has_feature(feat, target)
+return has_feats
+
+
 def llvm_lookup_intrinsic_id(name):
 """Lookup LLVM intrinsic id by name.
 
@@ -71,36 +96,76 @@ def llvm_get_intrinsic_name(intrin_id: int) -> str:
 return _ffi_api.llvm_get_intrinsic_name(intrin_id)
 
 
-def llvm_x86_get_archlist(only64bit=False):
-"""Get X86 CPU name list.
+def llvm_get_targets():
+"""Get LLVM target list.
+
+Parameters
+--
+
+Returns
+---
+llvm_targets : list[str]
+List of available LLVM targets.
+"""
+return _ffi_api.llvm_get_targets()
+
+
+def llvm_get_cpu_archlist(target=None):
+"""Get CPU architectures for the target's `-mtriple`.
+
+Parameters
+--
+target : Target
+The TVM target.
+
+Returns
+---
+cpu_archlist : list[str]
+List of available CPU architectures.
+"""
+assert isinstance(target, Target) or target is None
+return _ffi_api.llvm_get_cpu_archlist(target)
+
+
+def llvm_get_cpu_features(target=None):
+"""Get CPU features for the target's `-mtriple` and `-mcpu` and 
considering `-mat

[tvm] branch main updated (64ab31ec3e -> 08a6ee520f)

2023-09-15 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 64ab31ec3e [UnitTest][Metal] Parametrize allreduce GPU tests (#15749)
 add 08a6ee520f [Hexagon] F2qi avgpool bug fix (#15599)

No new revisions were added by this update.

Summary of changes:
 .../transform/fake_quantization_to_integer.py  |  31 +++
 python/tvm/topi/hexagon/qnn/avg_pool2d.py  |  22 +-
 .../python/contrib/test_hexagon/infrastructure.py  |  22 ++
 .../test_hexagon/test_pass_fq2i_avg_pool2d.py  | 290 +
 .../test_hexagon/test_relay_simplify_conv_pat.py   |  23 +-
 5 files changed, 354 insertions(+), 34 deletions(-)
 create mode 100644 
tests/python/contrib/test_hexagon/test_pass_fq2i_avg_pool2d.py



[tvm] branch main updated: [IR] Use structural equal for Range equality (#15664)

2023-09-05 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 04ee895d8d [IR] Use structural equal for Range equality (#15664)
04ee895d8d is described below

commit 04ee895d8d102ea5aedd6480e7d5f4093c54d27d
Author: Anirudh Sundar Subramaniam 
AuthorDate: Tue Sep 5 22:59:11 2023 +0530

[IR] Use structural equal for Range equality (#15664)

This PR adds a small change to verify equality of `tvm.ir.Range` as a
structural equal. This assumes that in most cases, comparing two
`Range`s means to compare its `min` and `extent` as opposed to the
actual Range object handle.
---
 python/tvm/ir/expr.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/python/tvm/ir/expr.py b/python/tvm/ir/expr.py
index 5a83d8e5d9..f0f2245e7f 100644
--- a/python/tvm/ir/expr.py
+++ b/python/tvm/ir/expr.py
@@ -177,3 +177,9 @@ class Range(Node, Scriptable):
 The constructed range.
 """
 return _ffi_api.Range_from_min_extent(min_value, extent, span)
+
+def __eq__(self, other):
+return tvm.ir.structural_equal(self, other)
+
+def __ne__(self, other):
+return not self.__eq__(other)



[tvm] branch unity updated (c8494dc004 -> 61c693dc42)

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

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


from c8494dc004 [Unity][ONNX] Support ONNX Symbolic Shape Deduction (#15498)
 add 61c693dc42 [Unity] Recursive pattern match in rewrite_call (#15495)

No new revisions were added by this update.

Summary of changes:
 src/relax/ir/dataflow_matcher.cc| 15 +++--
 tests/python/relax/test_dataflow_pattern.py | 48 +
 2 files changed, 60 insertions(+), 3 deletions(-)



[tvm] branch unity updated: [Unity] Remove unused local function definitions (#15507)

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

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


The following commit(s) were added to refs/heads/unity by this push:
 new bcc9a68b3e [Unity] Remove unused local function definitions (#15507)
bcc9a68b3e is described below

commit bcc9a68b3ef1448049d6c3c9a4be745e8109d834
Author: Eric Lunderberg 
AuthorDate: Thu Aug 10 08:36:19 2023 -0500

[Unity] Remove unused local function definitions (#15507)

Prior to this commit, the `relax.analysis.remove_all_unused` utility
only removed variable bindings that occur within a dataflow block.
This satisfies that the condition that a variable can be removed if is
unused and if its computation has no side effects.  However, it
doesn't include any values from a `BindingBlock`.

This commit updates the `RemoveUnusedVars` pass to also inspect
`BindingBlock` instances for removeable variables.  Currently, this is
limited to unused local function definitions.
---
 src/relax/ir/binding_rewrite.cc | 22 -
 tests/python/relax/test_analysis.py | 47 +
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/src/relax/ir/binding_rewrite.cc b/src/relax/ir/binding_rewrite.cc
index 188ed39560..4eec0310fb 100644
--- a/src/relax/ir/binding_rewrite.cc
+++ b/src/relax/ir/binding_rewrite.cc
@@ -245,7 +245,27 @@ class RemoveUnusedVars : public ExprMutator {
   RemoveUnusedVars(Map> users, Array fn_outputs)
   : RemoveUnusedVars(GetUnusedVars(users, fn_outputs)) {}
 
-  BindingBlock VisitBindingBlock_(const DataflowBlockNode* block) {
+  BindingBlock VisitBindingBlock_(const BindingBlockNode* block) override {
+builder_->BeginBindingBlock();
+for (Binding binding : block->bindings) {
+  bool can_remove = [&]() -> bool {
+if (!unused_vars.count(binding->var)) {
+  return false;
+}
+auto var_binding = binding.as();
+if (!var_binding) {
+  return false;
+}
+return var_binding->value->IsInstance();
+  }();
+  if (!can_remove) {
+VisitBinding(binding);
+  }
+}
+return builder_->EndBlock();
+  }
+
+  BindingBlock VisitBindingBlock_(const DataflowBlockNode* block) override {
 auto prev_dfb = GetRef(block);
 builder_->BeginDataflowBlock();
 for (Binding binding : block->bindings) {
diff --git a/tests/python/relax/test_analysis.py 
b/tests/python/relax/test_analysis.py
index 500a57775e..40bd5146ba 100644
--- a/tests/python/relax/test_analysis.py
+++ b/tests/python/relax/test_analysis.py
@@ -117,6 +117,53 @@ def test_binding_block_remove_all_unused():
 tvm.ir.assert_structural_equal(optimized, GroundTruth["main"])
 
 
+def test_binding_block_remove_all_unused_without_dataflow():
+@tvm.script.ir_module
+class IdentityUnused:
+@R.function
+def main(x: R.Tensor((32, 32), "float32")) -> R.Tensor:
+lv0 = x
+unused0 = R.call_dps_packed("my_sigmoid", (x,), R.Tensor((32, 32), 
dtype="float32"))
+unused1 = R.call_dps_packed(
+"my_dps_func", (unused0,), R.Tensor((32, 32), dtype="float32")
+)
+z = R.call_packed("vm.builtin.copy", lv0, 
sinfo_args=(R.Tensor((32, 32), "float32")))
+return z
+
+optimized = remove_all_unused(IdentityUnused["main"])
+
+GroundTruth = IdentityUnused
+
+tvm.ir.assert_structural_equal(optimized, GroundTruth["main"])
+
+
+def test_binding_block_remove_all_unused_func_without_dataflow():
+@tvm.script.ir_module
+class IdentityUnused:
+@R.function
+def main(x: R.Tensor((32, 32), "float32")) -> R.Tensor:
+lv0 = x
+
+@R.function
+def internal_unused_func(A: R.Tensor((32, 32), "float32")) -> 
R.Tensor:
+return A
+
+z = R.call_packed("vm.builtin.copy", lv0, 
sinfo_args=(R.Tensor((32, 32), "float32")))
+return z
+
+optimized = remove_all_unused(IdentityUnused["main"])
+
+@tvm.script.ir_module
+class GroundTruth:
+@R.function
+def main(x: R.Tensor((32, 32), "float32")) -> R.Tensor:
+lv0 = x
+z = R.call_packed("vm.builtin.copy", lv0, 
sinfo_args=(R.Tensor((32, 32), "float32")))
+return z
+
+tvm.ir.assert_structural_equal(optimized, GroundTruth["main"])
+
+
 def test_binding_block_fake_unused_remove_all_unused():
 @tvm.script.ir_module
 class IdentityUnused:



[tvm] branch unity updated: [Unity][Hot fix] Flash attention offload bug due to typo (#15512)

2023-08-09 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/unity by this push:
 new cd14d4d7e2 [Unity][Hot fix] Flash attention offload bug due to typo 
(#15512)
cd14d4d7e2 is described below

commit cd14d4d7e2eee87e616dd074f6b8a7770fe8854a
Author: masahi 
AuthorDate: Thu Aug 10 02:02:22 2023 +0900

[Unity][Hot fix] Flash attention offload bug due to typo (#15512)

* flash attention hot fix

* also add cuda graph support
---
 python/tvm/contrib/cutlass/attention_operation.py | 14 +++---
 python/tvm/contrib/cutlass/gen_tensor_op.py   |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/python/tvm/contrib/cutlass/attention_operation.py 
b/python/tvm/contrib/cutlass/attention_operation.py
index 9b4fa78127..67a68df442 100644
--- a/python/tvm/contrib/cutlass/attention_operation.py
+++ b/python/tvm/contrib/cutlass/attention_operation.py
@@ -178,6 +178,10 @@ def instantiate_flash_attention_template(attrs):
 int v_batch_stride = v_row_stride * ${num_keys};
 int o_batch_stride = o_row_stride * ${num_queries};
 
+auto func = tvm::runtime::Registry::Get("runtime.get_cuda_stream");
+ICHECK(func != nullptr);
+cudaStream_t stream = static_cast((*func)().operator 
void*());
+
 flash_attn::flash_attention_forward(
 static_cast(${query}->data),
static_cast(${key}->data),
@@ -203,7 +207,7 @@ def instantiate_flash_attention_template(attrs):
o_row_stride,
${scale},
${is_causal},
-   nullptr);
+   stream);
 """
 
 template_stacked = """
@@ -224,8 +228,12 @@ def instantiate_flash_attention_template(attrs):
 int v_batch_stride = v_row_stride * ${num_keys};
 int o_batch_stride = o_row_stride * ${num_queries};
 
+auto func = tvm::runtime::Registry::Get("runtime.get_cuda_stream");
+ICHECK(func != nullptr);
+cudaStream_t stream = static_cast((*func)().operator 
void*());
+
 flash_attn::flash_attention_forward(
-static_cast(${qkv}->data),
+static_cast(${qkv}->data),
static_cast(${qkv}->data) + 
${head_dim} * ${num_heads},
static_cast(${qkv}->data) + 
${head_dim} * ${num_heads} * 2,
static_cast(out0->data),
@@ -249,7 +257,7 @@ def instantiate_flash_attention_template(attrs):
o_row_stride,
${scale},
${is_causal},
-   nullptr);
+   stream);
 """
 
 if "qkv" in attrs:
diff --git a/python/tvm/contrib/cutlass/gen_tensor_op.py 
b/python/tvm/contrib/cutlass/gen_tensor_op.py
index 7133193c1e..317030b6ff 100644
--- a/python/tvm/contrib/cutlass/gen_tensor_op.py
+++ b/python/tvm/contrib/cutlass/gen_tensor_op.py
@@ -760,7 +760,7 @@ def instantiate_template(func_name, annotations, func_args):
 
 if use_flash:
 headers.append("flash.h")
-attrs["is_causal"] = int(annotations["custom_mask_type"]) == 0
+attrs["is_causal"] = int(annotations["custom_mask_type"]) > 0
 code = instantiate_flash_attention_template(attrs)
 else:
 headers.append("kernel_forward.h")



[tvm] branch unity updated: [Unity] Commutative pattern match based on relax.Expr op (#15494)

2023-08-07 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/unity by this push:
 new 9fb191159f [Unity] Commutative pattern match based on relax.Expr op 
(#15494)
9fb191159f is described below

commit 9fb191159ffb8a628e5ca0a02201156d2030edee
Author: Eric Lunderberg 
AuthorDate: Mon Aug 7 08:06:55 2023 -0500

[Unity] Commutative pattern match based on relax.Expr op (#15494)

Prior to this commit, the commutative pattern matching was enabled
based on the operation in the pattern.  As a result,
commutative matches would only be checked if the match checked for a
single operator, but not if the operator was itself a pattern that
resolved to a commutative operator.

```python
pattern_add = ExprPattern(Op.get("relax.add"))
pattern_mul = ExprPattern(Op.get("relax.multiply"))

uses_commutative_matching = pattern_add(lhs, rhs)
no_commutative_matching = OrPattern(pattern_add, pattern_mul)(lhs, rhs)
```

This commit updates the pattern matcher to check against the matched
operator, rather than the pattern, to determine whether to check for
commutative matches.
---
 src/relax/ir/dataflow_matcher.cc|  4 ++--
 tests/python/relax/test_dataflow_pattern.py | 36 +
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/relax/ir/dataflow_matcher.cc b/src/relax/ir/dataflow_matcher.cc
index 2d06ce1fb9..290ee42eff 100644
--- a/src/relax/ir/dataflow_matcher.cc
+++ b/src/relax/ir/dataflow_matcher.cc
@@ -275,8 +275,8 @@ bool DFPatternMatcher::VisitDFPattern_(const 
CallPatternNode* op, const Expr& ex
   // Standard case
   if (match_args(op->args, call_node->args.begin(), 
call_node->args.end())) return true;
 
-  // Commutative Matching
-  if (const OpNode* op_node = get_op_node(op)) {
+  // Commutative Matching.
+  if (const OpNode* op_node = call_node->op.as()) {
 if ((op_node->name == "relax.add") || (op_node->name == 
"relax.multiply")) {
   if (match_args(op->args, call_node->args.rbegin(), 
call_node->args.rend())) {
 return true;
diff --git a/tests/python/relax/test_dataflow_pattern.py 
b/tests/python/relax/test_dataflow_pattern.py
index ea83807bf8..202db9b5b3 100644
--- a/tests/python/relax/test_dataflow_pattern.py
+++ b/tests/python/relax/test_dataflow_pattern.py
@@ -1282,5 +1282,41 @@ def test_combine_transposed_matmul_twice():
 rx.build(mod, target="llvm")
 
 
+def test_commutative_pattern_match():
+@R.function(private=True)
+def before(
+x: R.Tensor((1024,)),
+):
+with R.dataflow():
+out = R.add(R.const(1.0), x)
+R.output(out)
+return out
+
+@R.function(private=True)
+def expected(
+x: R.Tensor((1024,)),
+):
+with R.dataflow():
+out = R.add(x, R.const(2.0))
+R.output(out)
+return out
+
+pattern_add = is_op("relax.add")
+pattern_mul = is_op("relax.multiply")
+pattern_op = pattern_add | pattern_mul
+pattern_arg = wildcard()
+pattern_const = is_const()
+
+pattern = pattern_op(pattern_arg, pattern_const)
+
+def rewriter(_expr, matches):
+op = matches[pattern_op]
+arg = matches[pattern_arg]
+return rx.Call(op, [arg, rx.const(2.0)])
+
+after = rewrite_call(pattern, rewriter, before)
+tvm.ir.assert_structural_equal(after, expected)
+
+
 if __name__ == "__main__":
 tvm.testing.main()



[tvm] branch main updated: [Script] Be more careful when generating ast.ExtSlice for Subscript (#15483)

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

kparzysz 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 18467c95dd [Script] Be more careful when generating ast.ExtSlice for 
Subscript (#15483)
18467c95dd is described below

commit 18467c95dd98b1a9a18a59fdfd3381bbdf40c5fa
Author: Krzysztof Parzyszek 
AuthorDate: Fri Aug 4 19:41:01 2023 -0500

[Script] Be more careful when generating ast.ExtSlice for Subscript (#15483)

* [Script] Be more careful when generating ast.ExtSlice for Subscript

The ast.ExtSlice expects a non-empty list, otherwise evaluation
fails with "error: empty dims on ExtSlice". Also, each element
in "dims" list of ExtSlice must be either Slice or Index.

In python3.8 an expression A[()] is parsed (by ast) as Subscript
with slice being Index(value=Tuple(elts=[])). When we translate a
subscript from doc.AST to ast, we unconditionally convert every
tuple to ast.ExtSlice, which in this case is incorrect.

The fix is to map empty tuple back to the Index(Tuple[])) instead
of ExtSlice. In other cases, ensure that members of ExtSlice are
of correct types.

* Fix lint #1
---
 python/tvm/script/parser/core/doc.py   | 21 ++---
 tests/python/unittest/test_tvmscript_parser_tir.py | 16 
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/python/tvm/script/parser/core/doc.py 
b/python/tvm/script/parser/core/doc.py
index 5ea83749ea..1c5241dc8d 100644
--- a/python/tvm/script/parser/core/doc.py
+++ b/python/tvm/script/parser/core/doc.py
@@ -414,13 +414,20 @@ def _register_subscription_handling():
 ctx=from_doc(x.ctx),
 )
 elif isinstance(x.slice, doc.Tuple):
-result = ast.Subscript(
-value=from_doc(x.value),
-slice=ast.ExtSlice(
-dims=[from_doc(i) for i in x.slice.elts],
-),
-ctx=from_doc(x.ctx),
-)
+
+def remap_dim(doc_item: doc.Expr) -> ast.Expr:
+ast_item = from_doc(doc_item)
+if isinstance(ast_item, (ast.Index, ast.Slice)):
+return ast_item
+return ast.Index(value=ast_item)
+
+# ast.ExtSlice requires a non-empty list of dims, and each dim 
must be either
+# a Slice or an Index.
+if x.slice.elts:
+ast_slice = ast.ExtSlice(dims=[*map(remap_dim, x.slice.elts)])
+else:
+ast_slice = ast.Index(value=ast.Tuple(elts=[], 
ctx=from_doc(x.ctx)))
+result = ast.Subscript(value=from_doc(x.value), slice=ast_slice, 
ctx=from_doc(x.ctx))
 else:
 result = ast.Subscript(
 value=from_doc(x.value),
diff --git a/tests/python/unittest/test_tvmscript_parser_tir.py 
b/tests/python/unittest/test_tvmscript_parser_tir.py
index 210c173141..ef02df497b 100644
--- a/tests/python/unittest/test_tvmscript_parser_tir.py
+++ b/tests/python/unittest/test_tvmscript_parser_tir.py
@@ -292,5 +292,21 @@ def test_tir_starred_for_loop():
 tvm.ir.assert_structural_equal(starred, non_starred)
 
 
+def test_tir_empty_tuple_index():
+@T.macro
+def bar(val):
+T.evaluate(val)
+
+@T.prim_func(private=True)
+def func_with_empty_tuple(A: T.Buffer((), "int32"), B: T.Buffer((), 
"int32")):
+bar(val=A[()])
+
+@T.prim_func(private=True)
+def expected(A: T.Buffer((), "int32"), B: T.Buffer((), "int32")):
+T.evaluate(A[()])
+
+tvm.ir.assert_structural_equal(func_with_empty_tuple, expected)
+
+
 if __name__ == "__main__":
 tvm.testing.main()



[tvm] branch main updated: [Bugfix][CUTLASS] CUTLASS path finding (#15480)

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

kparzysz 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 2f090648d2 [Bugfix][CUTLASS] CUTLASS path finding (#15480)
2f090648d2 is described below

commit 2f090648d29988468d288517a406b96db7b7e03a
Author: Junru Shao 
AuthorDate: Fri Aug 4 11:43:44 2023 -0700

[Bugfix][CUTLASS] CUTLASS path finding (#15480)

[Bugfix][CUTLASS] CUTLASS path finding (#15476)

This PR fixes the path finding for `3rdparty/cutlass` by trying out
different combinations. It is helpful when TVM is packaged differently.
---
 python/tvm/_ffi/libinfo.py  |  9 +++--
 python/tvm/contrib/cutlass/build.py | 15 ---
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/python/tvm/_ffi/libinfo.py b/python/tvm/_ffi/libinfo.py
index 19b8b50bbf..3ec78fe278 100644
--- a/python/tvm/_ffi/libinfo.py
+++ b/python/tvm/_ffi/libinfo.py
@@ -15,8 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 """Library information."""
-import sys
 import os
+import sys
 
 
 def split_env_var(env_var, split):
@@ -169,7 +169,12 @@ def find_include_path(name=None, search_path=None, 
optional=False):
 source_dir = os.environ["TVM_HOME"]
 else:
 ffi_dir = 
os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
-source_dir = os.path.join(ffi_dir, "..", "..", "..")
+for source_dir in ["..", "../..", "../../.."]:
+source_dir = os.path.join(ffi_dir, source_dir)
+if os.path.isdir(os.path.join(source_dir, "include")):
+break
+else:
+raise AssertionError("Cannot find the source directory given 
ffi_dir: {ffi_dir}")
 third_party_dir = os.path.join(source_dir, "3rdparty")
 
 header_path = []
diff --git a/python/tvm/contrib/cutlass/build.py 
b/python/tvm/contrib/cutlass/build.py
index 7b5a6b97b9..cd990d0eea 100644
--- a/python/tvm/contrib/cutlass/build.py
+++ b/python/tvm/contrib/cutlass/build.py
@@ -37,13 +37,14 @@ def has_cutlass():
 
 
 def _get_cutlass_path():
-tvm_root = os.path.join(os.path.dirname(os.path.realpath(__file__)), 
"../../../../")
-cutlass_path = os.path.join(tvm_root, "3rdparty/cutlass")
-assert os.path.exists(cutlass_path), (
-f"The CUTLASS root directory not found in {cutlass_path}. Currently, 
using CUTLASS "
-f"requires building TVM from source."
-)
-return cutlass_path
+invalid_paths = []
+for rel in ["../../../../", "../../../", "../../"]:
+tvm_root = os.path.join(os.path.dirname(os.path.realpath(__file__)), 
rel)
+cutlass_path = os.path.join(tvm_root, "3rdparty/cutlass")
+if os.path.exists(cutlass_path):
+return cutlass_path
+invalid_paths.append(cutlass_path)
+raise AssertionError(f"The CUTLASS root directory not found in: 
{invalid_paths}")
 
 
 def _get_cutlass_compile_options(sm, threads, use_fast_math=False):



[tvm] branch main updated: [TIR] Generalize implementation of T.macro to work with other dialects (#15432)

2023-07-29 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 2d76c9704f [TIR] Generalize implementation of T.macro to work with 
other dialects (#15432)
2d76c9704f is described below

commit 2d76c9704f6f9983b191690aa7ed20170cf69d65
Author: Krzysztof Parzyszek 
AuthorDate: Sat Jul 29 07:31:32 2023 -0500

[TIR] Generalize implementation of T.macro to work with other dialects 
(#15432)

As a background info---the script parser works by visiting a "statement"
(or top-level expression) at a time. The expression parts of the state-
ment are evaluated, and then the IR corresponding to the statement is
constructed if necessary.

In TIR, macro calls can only occur at the statement level, and they don't
produce any values. This means that the statement visitor (visit_expr_stmt)
can see these calls directly in its node parameter. At this point it could
simply visit the body of the macro instead, which is the basis of the
existing implementation.

In other dialects there may be a need for macros to produce values. This
means that macro calls can occur in the middle of complex expressions.
As a result, these calls will not be present at the statement level, and
the TIR approach by intercepting them in visit_expr_stmt will no longer
work. Instead, these macros delay the visiting of the macro body to the
evaluation time. A macro is represented by an ScriptMacro (TIRMacro in
the current implementation) object (created via macro decorator). When the
evaluator evaluates an expression with a macro call, it will call the
macro object (since macro calls use function call syntax). It is in the
macro object's __call__ function where the macro parsing picks up. The
remaining issue was to pass the Parser object to the __call__ function.
This is done by injecting it into the global dictionary under a reserved
name.

It turns out that the same approach also works for TIR, and the macro
processing can be generalized, leaving only language-specific details to
the language-specific language macro objects.
---
 python/tvm/script/parser/_core.py   |   2 +-
 python/tvm/script/parser/core/entry.py  |   6 +-
 python/tvm/script/parser/core/parser.py | 105 
 python/tvm/script/parser/tir/entry.py   |  41 +++--
 python/tvm/script/parser/tir/parser.py  |  59 +-
 5 files changed, 119 insertions(+), 94 deletions(-)

diff --git a/python/tvm/script/parser/_core.py 
b/python/tvm/script/parser/_core.py
index b7ba5ee471..8c29df7e62 100644
--- a/python/tvm/script/parser/_core.py
+++ b/python/tvm/script/parser/_core.py
@@ -18,5 +18,5 @@
 # pylint: disable=unused-import
 from .core import dispatch, doc, utils
 from .core.dispatch import OpMethod, register_op
-from .core.entry import parse, parse_macro
+from .core.entry import parse, scan_macro
 from .core.parser import Parser
diff --git a/python/tvm/script/parser/core/entry.py 
b/python/tvm/script/parser/core/entry.py
index 08a593d5d3..7604a54b45 100644
--- a/python/tvm/script/parser/core/entry.py
+++ b/python/tvm/script/parser/core/entry.py
@@ -34,14 +34,12 @@ def _default_globals() -> Dict[str, Any]:
 return extra_vars
 
 
-def parse_macro(program: Union[Any, str], extra_vars: Dict[str, Any] = None) 
-> Any:
+def scan_macro(program: Union[Any, str], extra_vars: Dict[str, Any] = None) -> 
Any:
 """Generate the AST, and the source code for __repr__."""
 # The AST will be converted into TIR at the time of expansion.
 source = Source(program)
-source_txt = source.source
-source_ast = source.as_ast()
 closure_vars = extra_vars or _default_globals()
-return source_ast, source_txt, closure_vars
+return source, closure_vars
 
 
 def parse(program: Union[doc.AST, Any, str], extra_vars: Dict[str, Any] = 
None) -> Any:
diff --git a/python/tvm/script/parser/core/parser.py 
b/python/tvm/script/parser/core/parser.py
index c253f61c31..7032d194be 100644
--- a/python/tvm/script/parser/core/parser.py
+++ b/python/tvm/script/parser/core/parser.py
@@ -16,6 +16,8 @@
 # under the License.
 """The core parser"""
 
+import abc
+import inspect
 from collections import defaultdict
 from contextlib import contextmanager
 from typing import Any, Callable, Dict, List, Optional, Set, Union
@@ -65,6 +67,108 @@ def _do_nothing(*args, **kwargs):  # pylint: 
disable=unused-argument
 pass
 
 
+class ScriptMacro(abc.ABC):
+"""Representation of a script macro.
+
+This is a callable object, intended to be called from the expression 
evaluator.
+The evaluator is expected to insert the current parser into the environment
+und

[tvm] branch main updated: [TIR] Allow starred expressions in TIR script (#15404)

2023-07-25 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 304aa1e084 [TIR] Allow starred expressions in TIR script (#15404)
304aa1e084 is described below

commit 304aa1e084be8cf294a9f851287a09deed102285
Author: Krzysztof Parzyszek 
AuthorDate: Tue Jul 25 16:14:32 2023 -0500

[TIR] Allow starred expressions in TIR script (#15404)

Small change in the evaluator to allow it to handle starred expressions
(i.e. list/tuple splicing).
---
 python/tvm/script/parser/core/evaluator.py | 11 +++
 tests/python/unittest/test_tvmscript_parser_tir.py | 18 ++
 2 files changed, 29 insertions(+)

diff --git a/python/tvm/script/parser/core/evaluator.py 
b/python/tvm/script/parser/core/evaluator.py
index e2b67341dc..939b7e82ce 100644
--- a/python/tvm/script/parser/core/evaluator.py
+++ b/python/tvm/script/parser/core/evaluator.py
@@ -221,6 +221,17 @@ class ExprEvaluator:
 return node
 if isinstance(node, doc.Lambda):
 return self._eval_lambda(node)
+if isinstance(node, doc.Starred):
+value = self._visit(node.value)
+return doc.Starred(
+value=value,
+ctx=node.ctx,
+lineno=node.lineno,
+col_offset=node.col_offset,
+end_lineno=node.end_lineno,
+end_col_offset=node.end_col_offset,
+)
+
 fields = {}
 for field in node.__class__._FIELDS:  # pylint: 
disable=protected-access
 attr = getattr(node, field)
diff --git a/tests/python/unittest/test_tvmscript_parser_tir.py 
b/tests/python/unittest/test_tvmscript_parser_tir.py
index 36df556108..c04d16008a 100644
--- a/tests/python/unittest/test_tvmscript_parser_tir.py
+++ b/tests/python/unittest/test_tvmscript_parser_tir.py
@@ -212,5 +212,23 @@ def test_tir_macro_non_hygienic():
 tvm.ir.assert_structural_equal(use_non_hygienic, expected_non_hygienic)
 
 
+def test_tir_starred_expression():
+dims = (128, 128)
+
+@T.prim_func(private=True)
+def starred(a: T.handle) -> None:
+A = T.match_buffer(a, [128, *dims], "int32")
+for i, j, k in T.grid(128, *dims):
+A[i, j, k] = T.int32(1)
+
+@T.prim_func(private=True)
+def non_starred(a: T.handle) -> None:
+A = T.match_buffer(a, [128, 128, 128], "int32")
+for i, j, k in T.grid(128, 128, 128):
+A[i, j, k] = T.int32(1)
+
+tvm.ir.assert_structural_equal(starred, non_starred)
+
+
 if __name__ == "__main__":
 tvm.testing.main()



[tvm] branch main updated: [TIR] Implement TIR macros (#15260)

2023-07-11 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 fddbec7079 [TIR] Implement TIR macros (#15260)
fddbec7079 is described below

commit fddbec7079a817d3339b45fedd3c5b8326cfafac
Author: Krzysztof Parzyszek 
AuthorDate: Tue Jul 11 11:37:51 2023 -0500

[TIR] Implement TIR macros (#15260)

* [TIR] Implement TIR macros

This patch introduces two new symbols: `T.macro` and `T.insert`.
`T.macro` is a decorator that, when applied to a function, turns the
body of that function into a piece of TIR that can be inserted via
`T.insert` into a PrimFunc.

For example:

```python
@T.macro
def copy_backwards(dst, src, size):
with T.block("backwards"):
for i in T.serial(size):
ai = T.axis.remap("S", [i])
T.reads(src[0:size])
T.writes(dst[0:size])
dst[ai] = src[size - ai - 1]

@T.prim_func
def foo_int32(A: T.Buffer((128,), "int32"), B: T.Buffer((128,), "int32")):
T.insert(copy_backwards, A, B, 128)

@T.prim_func
def foo_int8(A: T.Buffer((128,), "int8"), B: T.Buffer((128,), "int8")):
T.insert(copy_backwards, A, B, 128)
```

The above will generate two PrimFuncs that do the same backwards copy,
but applied to buffers with different data types.

Semantics:
- Function that is decorated with @T.macro can have any parameters that
  follow Python syntax, i.e. positional, keyword, etc. Type annotations
  are not required, but are allowed.
- The arguments to `T.insert` are macro name followed by the argument
  list.
  For `T.insert(arg1, arg2, arg3, ...)`, the values are substituted into
  the body of the macro as in the call `arg1(arg2, arg3, ...)`.
  The body with the substituted values is then inserted at the point
  where the `T.insert` is located.

* Fix linter

* Fix linter again

One linter suggested something that the other didn't like...

* Get rid of T.insert, apply macro via function-call syntax

* Store closure vars in TIRMacro

* ast.parse always returns ast.Module, hence doc is doc.Module

* Simplify `expand_macro`, capture environment variables

* Implement macro hygiene

* Fix linter

* Make T.macro work same as T.macro()

The previous commit inadvertently made T.macro (without parentheses)
illegal, only abbreviated form allowed was T.macro(). Restore T.macro
as a valid decorator use.

* Edit comment: insertion -> expansion

* Add import pytest

* One more typo...

* Remove stale testcase
---
 python/tvm/script/parser/_core.py  |   2 +-
 python/tvm/script/parser/core/entry.py |  31 +++---
 python/tvm/script/parser/tir/__init__.py   |   4 +-
 python/tvm/script/parser/tir/entry.py  |  99 ++-
 python/tvm/script/parser/tir/parser.py |  60 +++-
 tests/python/unittest/test_tvmscript_parser_tir.py | 107 +
 6 files changed, 286 insertions(+), 17 deletions(-)

diff --git a/python/tvm/script/parser/_core.py 
b/python/tvm/script/parser/_core.py
index 4f5411dc36..b7ba5ee471 100644
--- a/python/tvm/script/parser/_core.py
+++ b/python/tvm/script/parser/_core.py
@@ -18,5 +18,5 @@
 # pylint: disable=unused-import
 from .core import dispatch, doc, utils
 from .core.dispatch import OpMethod, register_op
-from .core.entry import parse
+from .core.entry import parse, parse_macro
 from .core.parser import Parser
diff --git a/python/tvm/script/parser/core/entry.py 
b/python/tvm/script/parser/core/entry.py
index 5315c0f675..08a593d5d3 100644
--- a/python/tvm/script/parser/core/entry.py
+++ b/python/tvm/script/parser/core/entry.py
@@ -25,6 +25,25 @@ from .error import ParserError
 from .parser import Parser
 
 
+def _default_globals() -> Dict[str, Any]:
+import tvm  # pylint: disable=import-outside-toplevel
+from tvm.script.parser import ir  # pylint: disable=import-outside-toplevel
+from tvm.script.parser import tir  # pylint: 
disable=import-outside-toplevel
+
+extra_vars = {"tvm": tvm, "I": ir, "ir": ir, "T": tir, "tir": tir}
+return extra_vars
+
+
+def parse_macro(program: Union[Any, str], extra_vars: Dict[str, Any] = None) 
-> Any:
+"""Generate the AST, and the source code for __repr__."""
+# The AST will be converted into TIR at the time of expansion.
+source = Source(program)
+source_txt = source.source
+source_ast = source.as_ast()
+closure_vars = extra_vars or _default_gl

[tvm] branch main updated: [LLVM] Minor refactor to LLVMModuleNode::SaveToFile (#15139)

2023-06-22 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 bee073b0c8 [LLVM] Minor refactor to LLVMModuleNode::SaveToFile (#15139)
bee073b0c8 is described below

commit bee073b0c8e8625216184a2dbb0204c0a376fc26
Author: Eric Lunderberg 
AuthorDate: Thu Jun 22 07:22:38 2023 -0500

[LLVM] Minor refactor to LLVMModuleNode::SaveToFile (#15139)

Previously, the `#if TVM_LLVM_VERSION` checks made it difficult to
determine the logic of LLVMModuleNode::SaveToFile while debugging.
This commit pulls out the preprocessor directives into wrapper
functions that maintain the same compatibility, making it easier to
follow the logic of the `SaveToFile` function.
---
 src/target/llvm/llvm_module.cc | 78 ++
 1 file changed, 40 insertions(+), 38 deletions(-)

diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc
index 4bb36ad284..85750fbf14 100644
--- a/src/target/llvm/llvm_module.cc
+++ b/src/target/llvm/llvm_module.cc
@@ -180,57 +180,59 @@ PackedFunc LLVMModuleNode::GetFunction(const String& 
name, const ObjectPtr llvm_target(*llvm_instance_, 
LLVMTarget::GetTargetMetadata(*module_));
+
 #if TVM_LLVM_VERSION <= 60
-std::unique_ptr m = llvm::CloneModule(module_);
+std::unique_ptr CloneLLVMModule(llvm::Module* mod) { return 
llvm::CloneModule(mod); }
 #else
-std::unique_ptr m = llvm::CloneModule(*module_);
+std::unique_ptr CloneLLVMModule(llvm::Module* mod) { return 
llvm::CloneModule(*mod); }
 #endif
-llvm::legacy::PassManager pass;
-llvm::TargetMachine* tm = llvm_target->GetOrCreateTargetMachine();
-#if TVM_LLVM_VERSION <= 60
-ICHECK(tm->addPassesToEmitFile(pass, dest, 
llvm::TargetMachine::CGFT_ObjectFile) == 0)
-<< "Cannot emit target CGFT_ObjectFile";
-#elif TVM_LLVM_VERSION <= 90
-ICHECK(tm->addPassesToEmitFile(pass, dest, nullptr, 
llvm::TargetMachine::CGFT_ObjectFile) == 0)
-<< "Cannot emit target CGFT_ObjectFile";
+
+#if TVM_LLVM_VERSION <= 90
+constexpr auto llvm_object_file_target = llvm::TargetMachine::CGFT_ObjectFile;
+constexpr auto llvm_assembly_file_target = 
llvm::TargetMachine::CGFT_AssemblyFile;
 #else
-ICHECK(tm->addPassesToEmitFile(pass, dest, nullptr, llvm::CGFT_ObjectFile) 
== 0)
-<< "Cannot emit target CGFT_ObjectFile";
+constexpr auto llvm_object_file_target = llvm::CGFT_ObjectFile;
+constexpr auto llvm_assembly_file_target = llvm::CGFT_AssemblyFile;
 #endif
-pass.run(*m);
-  } else if (fmt == "s" || fmt == "asm") {
-With llvm_target(*llvm_instance_, 
LLVMTarget::GetTargetMetadata(*module_));
+
+bool LLVMAddPassesToEmitFile(llvm::TargetMachine* tm, 
llvm::legacy::PassManager* pm,
+ llvm::raw_fd_ostream* dest,
+ decltype(llvm_object_file_target) 
llvm_file_target) {
 #if TVM_LLVM_VERSION <= 60
-std::unique_ptr m = llvm::CloneModule(module_);
+  return tm->addPassesToEmitFile(*pm, *dest, llvm_file_target);
 #else
-std::unique_ptr m = llvm::CloneModule(*module_);
+  return tm->addPassesToEmitFile(*pm, *dest, nullptr, llvm_file_target);
 #endif
+}
+
+}  // namespace
+
+void LLVMModuleNode::SaveToFile(const String& file_name_str, const String& 
format) {
+  // CHECK(imports_.empty()) << "SaveToFile does not handle imported modules";
+  std::string file_name = file_name_str;
+  std::string fmt = runtime::GetFileFormat(file_name, format);
+  std::error_code ecode;
+  llvm::raw_fd_ostream dest(file_name, ecode, llvm_open_output_flag);
+  ICHECK_EQ(ecode.value(), 0) << "Cannot open file: " << file_name << " " << 
ecode.message();
+  bool is_obj_file = fmt == "o" || fmt == "obj";
+  bool is_asm_file = fmt == "s" || fmt == "asm";
+  if (is_obj_file || is_asm_file) {
+auto llvm_file_target = is_obj_file ? llvm_object_file_target : 
llvm_assembly_file_target;
+
+With llvm_target(*llvm_instance_, 
LLVMTarget::GetTargetMetadata(*module_));
 llvm::legacy::PassManager pass;
 llvm::TargetMachine* tm = llvm_target->GetOrCreateTargetMachine();
-#if TVM_LLVM_VERSION <= 60
-ICHECK(tm->addPassesToEmitFile(pass, dest, 
llvm::TargetMachine::CGFT_AssemblyFile) == 0)
-<< "Cannot emit target CGFT_AssemblyFile";
-#elif TVM_LLVM_VERSION <= 90
-ICHECK(tm->addPassesToEmitFile(pass, dest, nullptr, 
llvm::TargetMachine::CGFT_AssemblyFile) ==
-   0)
-<< "Cannot emit target CGFT_AssemblyFile";
-#else
-ICHECK(tm->addPassesToEmitFile(pass, dest, nullptr, 
llvm::CGFT_AssemblyFile) == 0)
-<< "Cannot emit target CGFT_As

[tvm] branch main updated: [IR,TE,TIR] Use f-strings for string formatting, NFC (#14990)

2023-06-01 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 00126b0484 [IR,TE,TIR] Use f-strings for string formatting, NFC 
(#14990)
00126b0484 is described below

commit 00126b04841d2e7716e615a46fe2c9a78b17ee35
Author: Krzysztof Parzyszek 
AuthorDate: Thu Jun 1 19:35:41 2023 -0500

[IR,TE,TIR] Use f-strings for string formatting, NFC (#14990)

* [IR,TE,TIR] Use f-strings for string formatting, NFC

Replace uses of % and .format() with f-strings.

Reformat modified files.

* Rearrange pylint directives for better formatting
---
 python/tvm/ir/container.py  |   4 +-
 python/tvm/ir/expr.py   |   6 +-
 python/tvm/ir/json_compact.py   |   4 +-
 python/tvm/te/hybrid/module.py  |   2 +-
 python/tvm/te/hybrid/parser.py  |  10 +-
 python/tvm/te/hybrid/preprocessor.py|   4 +-
 python/tvm/te/hybrid/utils.py   |   6 +-
 python/tvm/te/operation.py  |  11 +--
 python/tvm/te/schedule.py   |   2 +-
 python/tvm/te/tag.py|   2 +-
 python/tvm/te/tensor.py |   4 +-
 python/tvm/tir/buffer.py|  10 +-
 python/tvm/tir/ir_builder.py|   2 +-
 python/tvm/tir/schedule/schedule.py | 170 +++-
 python/tvm/tir/schedule/state.py|   9 +-
 python/tvm/tir/tensor_intrin/arm_cpu.py |   8 +-
 python/tvm/tir/tensor_intrin/cuda.py|  17 ++--
 17 files changed, 96 insertions(+), 175 deletions(-)

diff --git a/python/tvm/ir/container.py b/python/tvm/ir/container.py
index 3c7a57a830..e35c61c05c 100644
--- a/python/tvm/ir/container.py
+++ b/python/tvm/ir/container.py
@@ -46,7 +46,7 @@ class Array(Object):
 raise AttributeError("handle is not set")
 if name == "type_key":
 return super().__getattr__(name)
-raise AttributeError("%s has no attribute %s" % (str(type(self)), 
name))
+raise AttributeError(f"{type(self)} has no attribute {name}")
 
 
 @tvm._ffi.register_object
@@ -77,7 +77,7 @@ class Map(Object):
 raise AttributeError("handle is not set")
 if name == "type_key":
 return super().__getattr__(name)
-raise AttributeError("%s has no attribute %s" % (str(type(self)), 
name))
+raise AttributeError(f"{type(self)} has no attribute {name}")
 
 def keys(self):
 return iter(self)
diff --git a/python/tvm/ir/expr.py b/python/tvm/ir/expr.py
index 1c775b461e..5a83d8e5d9 100644
--- a/python/tvm/ir/expr.py
+++ b/python/tvm/ir/expr.py
@@ -50,7 +50,7 @@ class RelayExpr(BaseExpr):
 """
 ret = self._checked_type_
 if ret is None:
-raise ValueError("The type checker has not populated" " the 
checked_type for this node")
+raise ValueError("The type checker has not populated the 
checked_type for this node")
 return ret
 
 
@@ -92,9 +92,7 @@ class GlobalVar(RelayExpr):
 return tvm.tir.call_tir(self, *args)
 
 arg_types = [type(x) for x in args]
-raise RuntimeError(
-"Do not know how to handle GlobalVar.__call__ for types 
{}".format(arg_types)
-)
+raise RuntimeError(f"Do not know how to handle GlobalVar.__call__ for 
types {arg_types}")
 
 def astext(self, show_meta_data=True, annotate=None):
 """Get the text format of the expression.
diff --git a/python/tvm/ir/json_compact.py b/python/tvm/ir/json_compact.py
index 8e9d3550ca..6ce2a8b9e2 100644
--- a/python/tvm/ir/json_compact.py
+++ b/python/tvm/ir/json_compact.py
@@ -153,7 +153,7 @@ def create_updater_06_to_07():
 val = jdata["nodes"][root_idx]
 sidx = len(nodes)
 nodes.append(val)
-item["attrs"][key] = "%d" % sidx
+item["attrs"][key] = f"{sidx}"
 return item
 
 return _convert
@@ -260,5 +260,5 @@ def upgrade_json(json_str):
 elif from_version.startswith("0.8"):
 data = create_updater_08_to_09()(data)
 else:
-raise ValueError("Cannot update from version %s" % from_version)
+raise ValueError(f"Cannot update from version {from_version}")
 return json.dumps(data, indent=2)
diff --git a/python/tvm/te/hybrid/module.py b/python/tvm/te/hybrid/module.py
index af6270045b..729805b31b 100644
--- a/python/tvm/te/hybrid/module.py
+++ b/python/tvm/te/hybrid/module.py
@@ -51,7 +51,7 @@ class HybridModule(object):
 temp = utils.tempdir()
 dst = temp.relpath("script.py")
 with open(dst, "

[tvm] branch main updated: [Relay] Use f-strings for string formatting, NFC (#14838)

2023-05-13 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 3756b716d5 [Relay] Use f-strings for string formatting, NFC (#14838)
3756b716d5 is described below

commit 3756b716d537a158f668794555d5193e29100ad0
Author: Krzysztof Parzyszek 
AuthorDate: Sat May 13 09:20:21 2023 -0500

[Relay] Use f-strings for string formatting, NFC (#14838)

* [Relay] Use f-strings for string formatting, NFC

Replace uses of % and .format() with f-strings.

Reformat modified files.

* Fix typo in python/tvm/relay/frontend/tensorflow_ops.py

`0[s0_size] -> s0[s0_size]`
---
 python/tvm/relay/backend/interpreter.py|  11 ++-
 python/tvm/relay/backend/te_compiler.py|   4 +-
 python/tvm/relay/build_module.py   |   2 +-
 python/tvm/relay/expr.py   |  69 +-
 python/tvm/relay/expr_functor.py   |   8 +-
 python/tvm/relay/frontend/tensorflow_ops.py|   2 +-
 python/tvm/relay/loops.py  |   2 +-
 python/tvm/relay/prelude.py|  76 +---
 python/tvm/relay/qnn/op/layout_conversions.py  |   4 +-
 python/tvm/relay/qnn/op/qnn.py |  81 +++--
 python/tvm/relay/quantize/_calibrate.py|   4 +-
 python/tvm/relay/quantize/quantize.py  |   4 +-
 python/tvm/relay/testing/dcgan.py  |   4 +-
 python/tvm/relay/testing/densenet.py   |  12 +--
 python/tvm/relay/testing/inception_v3.py   | 100 +
 python/tvm/relay/testing/init.py   |  11 ++-
 python/tvm/relay/testing/layers.py |  12 +--
 python/tvm/relay/testing/lstm.py   |  20 ++---
 python/tvm/relay/testing/mobilenet.py  |   2 +-
 python/tvm/relay/testing/py_converter.py   |  21 ++---
 python/tvm/relay/testing/resnet.py |   8 +-
 python/tvm/relay/testing/resnet_3d.py  |   8 +-
 python/tvm/relay/testing/squeezenet.py |  17 ++--
 python/tvm/relay/testing/tf.py |   8 +-
 python/tvm/relay/testing/tflite.py |   2 +-
 python/tvm/relay/testing/vgg.py|   8 +-
 .../transform/fake_quantization_to_integer.py  |  30 ++-
 python/tvm/relay/type_functor.py   |   2 +-
 28 files changed, 185 insertions(+), 347 deletions(-)

diff --git a/python/tvm/relay/backend/interpreter.py 
b/python/tvm/relay/backend/interpreter.py
index e4da6f447f..80a8880fbc 100644
--- a/python/tvm/relay/backend/interpreter.py
+++ b/python/tvm/relay/backend/interpreter.py
@@ -99,7 +99,7 @@ class Executor(object):
 
 if kwargs and not isinstance(expr, Function):
 raise Exception(
-"can only supply keyword parameters for a " "relay.Function, 
found {0}".format(expr)
+f"can only supply keyword parameters for a relay.Function, 
found {expr}"
 )
 
 params = expr.params
@@ -111,17 +111,16 @@ class Executor(object):
 if i < num_of_args:
 if kwargs.get(name):
 raise Exception(
-"duplicate argument supplied in "
-"both positional args (at position: {0}), "
-"and keyword argument (with name: {1})".format(i, name)
+f"duplicate argument supplied in "
+f"both positional args (at position: {i}), "
+f"and keyword argument (with name: {name})"
 )
 else:
 cargs.append(kwargs[name])
 
 if len(cargs) != len(params):
 raise Exception(
-"insufficient arguments, expected "
-"{0}, provided {1}".format(len(cargs), len(params))
+f"insufficient arguments, expected " f"{len(cargs)}, provided 
{len(params)}"
 )
 
 return tuple(cargs)
diff --git a/python/tvm/relay/backend/te_compiler.py 
b/python/tvm/relay/backend/te_compiler.py
index 814e793290..84e4ecbaec 100644
--- a/python/tvm/relay/backend/te_compiler.py
+++ b/python/tvm/relay/backend/te_compiler.py
@@ -111,8 +111,8 @@ def get_valid_implementations(op, attrs, inputs, out_type, 
target):
 """
 fstrategy = op.get_attr("FTVMStrategy")
 assert fstrategy is not None, (
-"%s doesn't have an FTVMStrategy registered. You can register "
-"one in python with `tvm.relay.op.register_strategy`." % op.name
+f"{op.name} doesn't have an FTVMStrategy re

[tvm] branch main updated: [Relay] Handle pad value coming from Tensor instead of scalar (#14735)

2023-04-28 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 e2e1696c74 [Relay] Handle pad value coming from Tensor instead of 
scalar (#14735)
e2e1696c74 is described below

commit e2e1696c742957d2ac3b508b438a82c85e141794
Author: Krzysztof Parzyszek 
AuthorDate: Fri Apr 28 16:57:18 2023 -0500

[Relay] Handle pad value coming from Tensor instead of scalar (#14735)

* [Relay] Handle pad value coming from Tensor instead of scalar

The PadCompute function would pass empty index to obtain the pad value.
This caused a crash when the pad value was given in a tensor with the
following message:

Check failed: shape.size() == indices.size() (1 vs. 0)
  : Tensor dimension mismatch in read ndim = 1, indices.size=0

* Move test to tests/python/relay/test_op_level2.py
---
 src/relay/op/nn/pad.cc   |  2 +-
 tests/python/relay/test_op_level2.py | 19 +++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/relay/op/nn/pad.cc b/src/relay/op/nn/pad.cc
index 365873d2fd..8cfb369901 100644
--- a/src/relay/op/nn/pad.cc
+++ b/src/relay/op/nn/pad.cc
@@ -177,7 +177,7 @@ Array PadCompute(const Attrs& attrs, const 
Array& inputs
 pad_after.push_back(pad_width[i][1]);
   }
   te::Tensor cast_pad_value = topi::cast(inputs[1], inputs[0]->dtype);
-  const PrimExpr& pad_value = cast_pad_value(Array());
+  const PrimExpr& pad_value = 
cast_pad_value(Array(inputs[1]->shape.size(), 0));
   return Array{topi::pad(inputs[0], pad_before, pad_after, 
pad_value, "T_pad",
  topi::kElementWise, param->pad_mode)};
 }
diff --git a/tests/python/relay/test_op_level2.py 
b/tests/python/relay/test_op_level2.py
index 434b4fa0a0..0a0ae561ab 100644
--- a/tests/python/relay/test_op_level2.py
+++ b/tests/python/relay/test_op_level2.py
@@ -1444,6 +1444,25 @@ def test_pad_run_dynamic_pad_value():
 _test_run("int32")
 
 
+def test_pad_value_in_array():
+A = relay.var("A", shape=(32, 32), dtype="int8")
+
+# Extract pad value from an array
+p0 = relay.Constant(tvm.nd.array(np.array([2], dtype="int8")))
+p1 = relay.nn.pad(A, pad_value=p0, pad_width=((1, 1), (1, 1)))
+
+func = relay.Function(relay.analysis.free_vars(p1), p1)
+mod = tvm.IRModule.from_expr(func)
+
+target = "llvm"
+lib = relay.build(
+mod,
+tvm.target.Target(target, host=target),
+runtime=relay.backend.Runtime("cpp"),
+executor=relay.backend.Executor("aot", {"unpacked-api": False, 
"interface-api": "packed"}),
+)
+
+
 @tvm.testing.uses_gpu
 @pytest.mark.parametrize("dtype", ["float32", "float16"])
 def test_lrn(executor_kind, dtype):



[tvm] branch main updated: [TIR][Hexagon] Use the "target" value in T.func_attr for VTCM limit (#14567)

2023-04-13 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 b48fcaba22 [TIR][Hexagon] Use the "target" value in T.func_attr for 
VTCM limit (#14567)
b48fcaba22 is described below

commit b48fcaba227c6d455c30bec2216183fed9853677
Author: Eric Lunderberg 
AuthorDate: Thu Apr 13 14:16:30 2023 -0500

[TIR][Hexagon] Use the "target" value in T.func_attr for VTCM limit (#14567)

* [TIR][Hexagon] Use the "target" value in T.func_attr for VTCM limit

For the VerifyVTCMLimit, read directly from the function attribute, if
the function has already been annotated with the target.

* Retain passing of target to VerifyVTCMLimit
---
 include/tvm/tir/analysis.h |  6 ++--
 src/auto_scheduler/feature.cc  |  4 +--
 src/driver/driver_api.cc   | 11 +---
 src/tir/analysis/calculate_allocated_memory.cc | 39 +++---
 4 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/include/tvm/tir/analysis.h b/include/tvm/tir/analysis.h
index 5bac25faa5..4ed164e5ad 100644
--- a/include/tvm/tir/analysis.h
+++ b/include/tvm/tir/analysis.h
@@ -26,6 +26,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -348,12 +349,13 @@ TVM_DLL Pass VerifyGPUCode(Map 
constraints);
 /*!
  * \brief Pass to checks if the size of the allocated vtcm memory satisfies 
the limit
  *
- * \param limit The limit to check.
+ * \param target The target whose VTCM limit should be used for any
+ * functions not already annotated with `tvm::attr::kTarget`.
  *
  * \returns The pass.
  * \sa tvm::tir::CalculateAllocatedBytes
  */
-TVM_DLL Pass VerifyVTCMLimit(const Integer& limit);
+TVM_DLL Pass VerifyVTCMLimit(Optional target = NullOpt);
 
 /*!
  * \brief Statically check TIR code for out of bounds array access.
diff --git a/src/auto_scheduler/feature.cc b/src/auto_scheduler/feature.cc
index 884215c24a..65cc13eb61 100644
--- a/src/auto_scheduler/feature.cc
+++ b/src/auto_scheduler/feature.cc
@@ -1408,9 +1408,7 @@ void GetPerStoreFeaturesWorkerFunc(const SearchTask& 
task, const State& state, i
 }
 if (IsHexagonTask(task)) {
   Target target = task->target;
-  const auto vtcm_capacity = 
target->GetAttr("vtcm-capacity").value().IntValue();
-  const auto& optimize =
-  
tir::transform::Sequential({tir::transform::VerifyVTCMLimit(vtcm_capacity)});
+  const auto& optimize = 
tir::transform::Sequential({tir::transform::VerifyVTCMLimit(target)});
   optimize(mod);
 }
 const auto& optimize =
diff --git a/src/driver/driver_api.cc b/src/driver/driver_api.cc
index 1962b9ab3b..486b40c994 100644
--- a/src/driver/driver_api.cc
+++ b/src/driver/driver_api.cc
@@ -544,22 +544,13 @@ runtime::Module build(const IRModule& funcs, const 
Target& target_arg,
   return TIRToRuntime(inputs, target_host);
 }
 
-int64_t GetVTCMCapacity(Target target, const transform::PassContext& pass_ctx) 
{
-  if (!target.defined()) target = Target::Current(/*allow_not_defined=*/true);
-  if (target.defined() && target->kind->name == "hexagon") {
-auto value = Downcast(target->attrs.at("vtcm-capacity"))->value;
-if (value > 0) return value;
-  }
-  return pass_ctx->GetConfig("tir.vtcm_capacity", 
Integer(0)).value()->value;
-}
-
 transform::Sequential MixedModulePassManager(IRModule mixed_mod, Target 
target) {
   transform::PassContext pass_ctx = transform::PassContext::Current();
 
   Array mixed_pass_list;
 
   // VerifyVTCMLimit must occur before LowerVtcmAlloc
-  
mixed_pass_list.push_back(tir::transform::VerifyVTCMLimit(GetVTCMCapacity(target,
 pass_ctx)));
+  mixed_pass_list.push_back(tir::transform::VerifyVTCMLimit(target));
   // LowerVtcmAlloc must occur after any transformations that modify memory 
allocation locations
   mixed_pass_list.push_back(tir::transform::LowerVtcmAlloc());
 
diff --git a/src/tir/analysis/calculate_allocated_memory.cc 
b/src/tir/analysis/calculate_allocated_memory.cc
index 95fd7f134e..ffdfc1f801 100644
--- a/src/tir/analysis/calculate_allocated_memory.cc
+++ b/src/tir/analysis/calculate_allocated_memory.cc
@@ -96,20 +96,39 @@ bool VerifyVTCMLimit(const PrimFunc& func, Integer limit) {
   return true;
 }
 
+int64_t GetVTCMCapacity(Target target, const transform::PassContext& pass_ctx) 
{
+  if (!target.defined()) target = Target::Current(/*allow_not_defined=*/true);
+  if (target.defined() && target->kind->name == "hexagon") {
+auto value = Downcast(target->attrs.at("vtcm-capacity"))->value;
+if (value > 0) return value;
+  }
+  return pass_ctx->GetConfig("tir.vtcm_capacity", 
I

[tvm] branch main updated: [AOT] Fix warning on dropping const in TVMAotExecutor_GetInputName (#14529)

2023-04-13 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 68ce1e871c [AOT] Fix warning on dropping const in 
TVMAotExecutor_GetInputName (#14529)
68ce1e871c is described below

commit 68ce1e871cbcd90789f462524ec0943bfee2ff0b
Author: Eric Lunderberg 
AuthorDate: Thu Apr 13 11:37:34 2023 -0500

[AOT] Fix warning on dropping const in TVMAotExecutor_GetInputName (#14529)

Prior to this commit, the `TVMAotExecutor_GetInputName` function
accepted a `char** name` output parameter.  When used, assignment of a
`const char*` into `*name` dropped the `const`, resulting in a
warning.  Changing the argument type to `const char**` (pointer to a
mutable pointer to a `const char`) resolves this warning.
---
 include/tvm/runtime/crt/aot_executor.h  | 2 +-
 src/runtime/crt/aot_executor/aot_executor.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/tvm/runtime/crt/aot_executor.h 
b/include/tvm/runtime/crt/aot_executor.h
index 4783adec8e..693a66c3ae 100644
--- a/include/tvm/runtime/crt/aot_executor.h
+++ b/include/tvm/runtime/crt/aot_executor.h
@@ -100,7 +100,7 @@ int TVMAotExecutor_GetInputIndex(TVMAotExecutor* executor, 
const char* name);
  * \param name Output for retrieving name.
  * \return Pointer to input name in `name`.
  */
-int TVMAotExecutor_GetInputName(TVMAotExecutor* executor, int index, char** 
name);
+int TVMAotExecutor_GetInputName(TVMAotExecutor* executor, int index, const 
char** name);
 
 /*!
  * \brief Run the generated program.
diff --git a/src/runtime/crt/aot_executor/aot_executor.c 
b/src/runtime/crt/aot_executor/aot_executor.c
index 8a47bb008b..9e733c21c3 100644
--- a/src/runtime/crt/aot_executor/aot_executor.c
+++ b/src/runtime/crt/aot_executor/aot_executor.c
@@ -82,7 +82,7 @@ int TVMAotExecutor_GetInputIndex(TVMAotExecutor* executor, 
const char* name) {
   return rv;
 }
 
-int TVMAotExecutor_GetInputName(TVMAotExecutor* executor, int index, char** 
name) {
+int TVMAotExecutor_GetInputName(TVMAotExecutor* executor, int index, const 
char** name) {
   const TVMMetadata* md = executor->metadata;
   *name = md->inputs[index].name;
   return 0;



[tvm] branch main updated: [LLVM] Validate generated LLVM module before optimization (#14564)

2023-04-12 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 b1ab4dc1d5 [LLVM] Validate generated LLVM module before optimization 
(#14564)
b1ab4dc1d5 is described below

commit b1ab4dc1d5e45cd18cb6a81062e22361746084c9
Author: Eric Lunderberg 
AuthorDate: Wed Apr 12 13:37:25 2023 -0500

[LLVM] Validate generated LLVM module before optimization (#14564)

* [LLVM] Validate generated LLVM module before optimization

Because LLVM's optimizations assume that the generated module is
valid, validation should be done before optimization, rather than
after.  This has the additional benefit of providing error messages
from LLVM that more closely relate to the TVM-generated LLVM IR,
rather than the optimized LLVM IR.

* Resolve linkage/attribute errors found by llvm::Verify

* Prioritize AlwaysInline over OptimizeNone
---
 src/target/llvm/codegen_llvm.cc  | 13 -
 src/target/llvm/codegen_llvm.h   |  6 ++
 src/target/llvm/codegen_nvptx.cc |  2 +-
 src/target/llvm/llvm_module.cc   | 18 --
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc
index 3fbc93f678..2a8c3226f3 100644
--- a/src/target/llvm/codegen_llvm.cc
+++ b/src/target/llvm/codegen_llvm.cc
@@ -66,6 +66,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -310,6 +311,14 @@ void CodeGenLLVM::AddFunctionInternal(const PrimFunc& f, 
bool ret_void) {
   }
 }
 
+void CodeGenLLVM::Verify() const {
+  std::string verify_errors_storage;
+  llvm::raw_string_ostream verify_errors(verify_errors_storage);
+  LOG_IF(FATAL, llvm::verifyModule(*module_, _errors))
+  << "LLVM module verification failed with the following errors: \n"
+  << verify_errors.str();
+}
+
 std::unique_ptr CodeGenLLVM::Finish() {
   this->AddStartupFunction();
   for (size_t i = 0; i < link_modules_.size(); ++i) {
@@ -317,8 +326,9 @@ std::unique_ptr CodeGenLLVM::Finish() {
 << "Failed to link modules";
   }
   link_modules_.clear();
-  // optimize
+  this->Verify();
   this->Optimize();
+  this->Verify();
   return std::move(module_);
 }
 
@@ -335,6 +345,7 @@ void CodeGenLLVM::HandleImport(const std::string& code) {
   
mlib->setDataLayout(llvm_target_->GetOrCreateTargetMachine()->createDataLayout());
   // mark all the functions as force inline
   for (llvm::Function& f : mlib->functions()) {
+f.removeFnAttr(llvm::Attribute::OptimizeNone);
 f.removeFnAttr(llvm::Attribute::NoInline);
 f.addFnAttr(llvm::Attribute::AlwaysInline);
 f.setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
diff --git a/src/target/llvm/codegen_llvm.h b/src/target/llvm/codegen_llvm.h
index b46ae07b84..0d5650c473 100644
--- a/src/target/llvm/codegen_llvm.h
+++ b/src/target/llvm/codegen_llvm.h
@@ -146,6 +146,12 @@ class CodeGenLLVM : public ExprFunctor,
* \return the created module.
*/
   virtual std::unique_ptr Finish();
+
+  /*!
+   * \brief Validate the generated module using llvm::verifyModule
+   */
+  void Verify() const;
+
   /*!
* \brief Add functions from the (unordered) range to the current module in 
a deterministic order.
*The range consists of objects convertible to PrimFunc.
diff --git a/src/target/llvm/codegen_nvptx.cc b/src/target/llvm/codegen_nvptx.cc
index e64a2dc5b9..46816eb20c 100644
--- a/src/target/llvm/codegen_nvptx.cc
+++ b/src/target/llvm/codegen_nvptx.cc
@@ -121,7 +121,7 @@ class CodeGenNVPTX : public CodeGenLLVM {
 ICHECK(storage_scope.rank == runtime::StorageRank::kShared)
 << "Can only allocate shared or local memory inside kernel";
 buf = AllocateSharedMemory(op->dtype, constant_size, 3, info.alignment,
-   llvm::GlobalValue::PrivateLinkage);
+   llvm::GlobalValue::ExternalLinkage);
   }
 }
 
diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc
index 4ae0b786b6..2173cad4a7 100644
--- a/src/target/llvm/llvm_module.cc
+++ b/src/target/llvm/llvm_module.cc
@@ -39,7 +39,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -330,11 +329,6 @@ void LLVMModuleNode::Init(const IRModule& mod, const 
Target& target) {
   if (tm->getTargetTriple().isOSDarwin()) {
 module_->addModuleFlag(llvm::Module::Override, "Dwarf Version", 2);
   }
-  std::string verify_errors_storage;
-  llvm::raw_string_ostream verify_errors(verify_errors_storage);
-  LOG_IF(FATAL, llvm::verifyModule(*module_, _errors))
-  << "LLVM module verification failed with the following errors: \n"
-  << 

[tvm] branch main updated: [LLVM] Expand tvm::Type to DWARF conversion (#14568)

2023-04-11 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 ca7c3d8a14 [LLVM] Expand tvm::Type to DWARF conversion (#14568)
ca7c3d8a14 is described below

commit ca7c3d8a14dca982635627f03ebbf6f1195e6586
Author: Eric Lunderberg 
AuthorDate: Tue Apr 11 18:51:01 2023 -0500

[LLVM] Expand tvm::Type to DWARF conversion (#14568)

* [LLVM] Expand tvm::Type to DWARF conversion

Prior to this commit, DWARF debug symbols for `float32`, `int8`, and
`int32` could be generated, with other datatypes resulting in an
error.  This commit expands the range of types with debug symbols to
allow for any `DLDataTypeCode::kDLInt`, `kDLUint`, or `kDLFloat`,
regardless of the bitsize.

* Use existing DLDataType2String

* Added unit test
---
 src/target/llvm/codegen_cpu.cc| 28 ++-
 tests/python/unittest/test_target_codegen_llvm.py | 20 
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc
index 21d2c6ebe0..59575c370f 100644
--- a/src/target/llvm/codegen_cpu.cc
+++ b/src/target/llvm/codegen_cpu.cc
@@ -55,6 +55,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -285,12 +286,7 @@ llvm::DIType* CodeGenCPU::GetDebugType(const Type& ty_tir) 
{
 llvm::DIType* CodeGenCPU::GetDebugType(const Type& ty_tir, llvm::Type* 
ty_llvm) {
   if (ty_llvm == t_void_) {
 return nullptr;
-  } else if (ty_llvm == llvm::Type::getFloatTy(*llvm_target_->GetContext())) {
-return dbg_info_->di_builder_->createBasicType("float", 32, 
llvm::dwarf::DW_ATE_float);
-  } else if (ty_llvm == t_int8_) {
-return dbg_info_->di_builder_->createBasicType("int8", 8, 
llvm::dwarf::DW_ATE_signed);
-  } else if (ty_llvm == t_int32_) {
-return dbg_info_->di_builder_->createBasicType("int32", 32, 
llvm::dwarf::DW_ATE_signed);
+
   } else if (ty_llvm->isPointerTy()) {
 auto* ptr_type = ty_tir.as();
 ICHECK(ptr_type != nullptr || GetRuntimeDataType(ty_tir).is_handle())
@@ -300,6 +296,26 @@ llvm::DIType* CodeGenCPU::GetDebugType(const Type& ty_tir, 
llvm::Type* ty_llvm)
  : nullptr;
 return dbg_info_->di_builder_->createPointerType(pointee_type,
  
ty_llvm->getPrimitiveSizeInBits());
+
+  } else if (auto* prim_type = ty_tir.as()) {
+DataType dtype = prim_type->dtype;
+auto dwarf_type = [&]() -> llvm::dwarf::TypeKind {
+  if (dtype.is_bool()) {
+return llvm::dwarf::DW_ATE_boolean;
+  } else if (dtype.is_float()) {
+return llvm::dwarf::DW_ATE_float;
+  } else if (dtype.is_int()) {
+return llvm::dwarf::DW_ATE_signed;
+  } else if (dtype.is_uint()) {
+return llvm::dwarf::DW_ATE_unsigned;
+  } else {
+LOG(FATAL) << "No DWARF representation for TIR type " << dtype;
+  }
+}();
+
+return dbg_info_->di_builder_->createBasicType(DLDataType2String(dtype),
+   dtype.bits() * 
dtype.lanes(), dwarf_type);
+
   } else {
 std::string type_str;
 llvm::raw_string_ostream rso(type_str);
diff --git a/tests/python/unittest/test_target_codegen_llvm.py 
b/tests/python/unittest/test_target_codegen_llvm.py
index 3190115aa6..856de716fc 100644
--- a/tests/python/unittest/test_target_codegen_llvm.py
+++ b/tests/python/unittest/test_target_codegen_llvm.py
@@ -1002,5 +1002,25 @@ def test_llvm_assume():
 m = tvm.build(mod, [inp, out], target="llvm")
 
 
+@tvm.testing.requires_llvm
+def test_debug_symbol_for_float64():
+"""Check that LLVM can define DWARF debug type for float64
+
+In previous versions, only specific data types could exist in the
+function signature.  In this test, the "calling_conv" attribute
+prevents lowering to the PackedFunc API.
+"""
+
+@T.prim_func
+def func(a: T.handle("float64"), b: T.handle("float64"), n: T.int64):
+T.func_attr({"calling_conv": 2})
+A = T.Buffer(16, "float64", data=a)
+B = T.Buffer(16, "float64", data=b)
+for i in range(n):
+B[i] = A[i]
+
+tvm.build(func, target="llvm")
+
+
 if __name__ == "__main__":
 tvm.testing.main()



[tvm] branch main updated (1db4464c08 -> 9fb9fd6898)

2023-04-11 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 1db4464c08 [Fix][TIR][Analysis] Reduction block checking alloc_buffers 
(#14589)
 add 9fb9fd6898 [TIR] Use String instead of StringImm for 
AttrStmtNode::node (#14491)

No new revisions were added by this update.

Summary of changes:
 src/tir/transforms/make_packed_api.cc |  2 +-
 tests/python/unittest/test_tvmscript_roundtrip.py | 40 +++
 2 files changed, 27 insertions(+), 15 deletions(-)



[tvm] branch main updated: [Codegen][LLVM] Remove cast to i8* in builtin::address_of (#14563)

2023-04-11 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 1c5442d2e9 [Codegen][LLVM] Remove cast to i8* in builtin::address_of 
(#14563)
1c5442d2e9 is described below

commit 1c5442d2e958e8b698a550e35a74684b38398b54
Author: Eric Lunderberg 
AuthorDate: Tue Apr 11 14:06:15 2023 -0500

[Codegen][LLVM] Remove cast to i8* in builtin::address_of (#14563)

* [Codegen][LLVM] Remove cast to i8* in builtin::address_of

This cast was initially added when `CreateBufferPtr` did not include
the cast to the appropriate address space, and is no longer
necessary.  Removing the cast will not harm LLVM configurations with
opaque pointers ([default in LLVM

15+](https://github.com/llvm/llvm-project/blob/main/llvm/docs/OpaquePointers.rst)),
and avoids type mismatches when using LLVM configurations that use
typed pointers.

* Added handling of i8* argument to non-overloaded prefetch

For compatibility with earlier versions of LLVM.  Newer versions have
an overloaded prefetch intrinsic, and the pointer cast is unnecessary.
---
 src/target/llvm/codegen_llvm.cc | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc
index 7c32f3cfa1..69fe8aa2b7 100644
--- a/src/target/llvm/codegen_llvm.cc
+++ b/src/target/llvm/codegen_llvm.cc
@@ -1279,6 +1279,19 @@ llvm::Value* CodeGenLLVM::CreateIntrinsic(const 
CallNode* op) {
 #else
   << llvm::Intrinsic::getName(id, {});
 #endif
+
+// In earlier versions of LLVM's, the prefetch intrinsic is not
+// overloaded, and always takes the first argument as i8*.  If
+// this is the case, this argument should insert a cast to i8*.
+if (id == llvm::Intrinsic::prefetch) {
+  llvm::Type* param_type = f->arg_begin()->getType();
+  if (param_type != arg_value[0]->getType()) {
+unsigned addrspace =
+
llvm::dyn_cast(arg_value[0]->getType())->getAddressSpace();
+arg_value[0] = builder_->CreatePointerCast(arg_value[0], 
t_char_->getPointerTo(addrspace));
+  }
+}
+
 return builder_->CreateCall(f, arg_value);
   } else if (op->op.same_as(builtin::bitwise_and())) {
 return builder_->CreateAnd(MakeValue(op->args[0]), MakeValue(op->args[1]));
@@ -1314,9 +1327,7 @@ llvm::Value* CodeGenLLVM::CreateIntrinsic(const CallNode* 
op) {
 
 TypedPointer buffer_ptr = CreateBufferPtr(MakeValue(load->buffer->data), 
load->buffer->dtype,
   indices_val, load->dtype);
-unsigned addrspace =
-
llvm::dyn_cast(buffer_ptr.addr->getType())->getAddressSpace();
-return builder_->CreatePointerCast(buffer_ptr.addr, 
t_char_->getPointerTo(addrspace));
+return buffer_ptr.addr;
   } else if (op->op.same_as(builtin::reinterpret()) && is_zero(op->args[0])) {
 return llvm::Constant::getNullValue(t_void_p_);
   } else if (op->op.same_as(builtin::isnullptr())) {



[tvm] branch main updated (1113de2ce1 -> 5239ec05e9)

2023-04-06 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 1113de2ce1 [relay] preserve the order of input_info of pytorch (#14462)
 add 5239ec05e9 [TIR] [Schedule] Add get_output_blocks primitive (#14490)

No new revisions were added by this update.

Summary of changes:
 include/tvm/tir/schedule/schedule.h|  9 
 python/tvm/tir/schedule/schedule.py| 23 +
 src/tir/schedule/analysis.h| 10 
 src/tir/schedule/analysis/analysis.cc  | 27 ++
 src/tir/schedule/concrete_schedule.cc  |  7 +++
 src/tir/schedule/concrete_schedule.h   |  1 +
 src/tir/schedule/primitive.h   |  9 
 src/tir/schedule/primitive/get_block_loop.cc   | 30 +++
 src/tir/schedule/schedule.cc   |  2 +
 src/tir/schedule/traced_schedule.cc| 11 
 src/tir/schedule/traced_schedule.h |  1 +
 .../python/unittest/test_tir_schedule_utilities.py | 59 ++
 12 files changed, 189 insertions(+)



[tvm] branch main updated (e51ba294d9 -> 287cd38651)

2023-04-05 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from e51ba294d9 [ACL] Prevent offloading of per-channel quantized operators 
(#14484)
 add 287cd38651 [TIR] Improved SeqStmt::Flatten utility (#14497)

No new revisions were added by this update.

Summary of changes:
 include/tvm/tir/stmt.h | 36 +---
 1 file changed, 25 insertions(+), 11 deletions(-)



[tvm] branch main updated: [LLVM] Add guard for #include (#14469)

2023-04-05 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 4b6e635825 [LLVM] Add guard for #include 
 (#14469)
4b6e635825 is described below

commit 4b6e635825d43512575fa260c213bd02e739d0c9
Author: Krzysztof Parzyszek 
AuthorDate: Wed Apr 5 08:26:34 2023 -0500

[LLVM] Add guard for #include  
(#14469)

The file llvm/Transforms/IPO/PassManagerBuilder.h has been removed in
LLVM 17, as a part of the transition to the new pass manager. Add a LLVM
version guard around the #include.
---
 src/target/llvm/codegen_amdgpu.cc | 2 ++
 src/target/llvm/codegen_nvptx.cc  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/target/llvm/codegen_amdgpu.cc 
b/src/target/llvm/codegen_amdgpu.cc
index 327f23af2c..a177aa7f68 100644
--- a/src/target/llvm/codegen_amdgpu.cc
+++ b/src/target/llvm/codegen_amdgpu.cc
@@ -42,7 +42,9 @@
 #include 
 #include 
 #include 
+#if TVM_LLVM_VERSION < 170
 #include 
+#endif
 #include 
 #include 
 #include 
diff --git a/src/target/llvm/codegen_nvptx.cc b/src/target/llvm/codegen_nvptx.cc
index ec561667c1..e64a2dc5b9 100644
--- a/src/target/llvm/codegen_nvptx.cc
+++ b/src/target/llvm/codegen_nvptx.cc
@@ -45,7 +45,9 @@
 #include 
 #include 
 #include 
+#if TVM_LLVM_VERSION < 170
 #include 
+#endif
 #include 
 
 #include 



[tvm] branch main updated (dba987cae0 -> 579d999653)

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

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


from dba987cae0 [Arith] Simplifications for floormod(x, 2) (#13936)
 add 579d999653 [pytest] Don't return values from test_* functions (#14475)

No new revisions were added by this update.

Summary of changes:
 tests/python/contrib/test_hexagon/test_2d_physical_buffers.py | 2 +-
 tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)



[tvm] branch main updated (2c052b2067 -> 76c8e66211)

2023-04-03 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 2c052b2067 [Frontend][Oneflow] Use FLOW_2_STR_DTYPE for dtype (#14454)
 add 76c8e66211 [Hexagon][TOPI] Use IndexMap axis separator instead of TE 
(#14459)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/utils.py | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)



[tvm] branch main updated (10a12bacb8 -> b56d7f56ab)

2023-03-23 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 10a12bacb8 [CI][EZ] Upgrade CI Lint Image (#14373)
 add b56d7f56ab [TIR][Utility] More flexible tir::Substitute arguments 
(#14251)

No new revisions were added by this update.

Summary of changes:
 include/tvm/runtime/container/array.h  |   6 +
 include/tvm/tir/stmt_functor.h | 144 +
 src/te/operation/create_primfunc.cc|   2 +-
 src/te/operation/cross_thread_reduction.cc |   1 +
 src/te/operation/hybrid_op.cc  |   4 +-
 src/te/operation/op_utils.cc   |  16 ---
 src/te/operation/op_utils.h|  16 ---
 src/tir/ir/expr.cc |   3 +-
 src/tir/ir/index_map.cc|   2 +-
 src/tir/ir/stmt_functor.cc |  11 --
 src/tir/schedule/primitive/blockize_tensorize.cc   |   2 +-
 src/tir/schedule/primitive/cache_index.cc  |   4 +-
 src/tir/schedule/primitive/cache_read_write.cc |   4 +-
 .../schedule/primitive/layout_transformation.cc|  18 +--
 src/tir/schedule/primitive/reduction.cc|   8 +-
 src/tir/transforms/inject_virtual_thread.cc|   3 +-
 src/tir/transforms/lower_cross_thread_reduction.cc |   2 +-
 .../manifest_shared_memory_local_stage.cc  |   2 +-
 src/tir/transforms/split_host_device.cc|   2 +-
 src/tir/transforms/storage_rewrite.cc  |   2 +-
 src/tir/transforms/vectorize_loop.cc   |   3 +-
 21 files changed, 153 insertions(+), 102 deletions(-)



[tvm] branch main updated: [LLVM] Fix registerCallbacks API after recent change (#14323)

2023-03-17 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 f7c2bbbe87 [LLVM] Fix registerCallbacks API after recent change 
(#14323)
f7c2bbbe87 is described below

commit f7c2bbbe87bdcb005f4bd918d96fe783a25578d3
Author: Anirudh Sundar Subramaniam 
AuthorDate: Fri Mar 17 19:39:17 2023 +0530

[LLVM] Fix registerCallbacks API after recent change (#14323)

LLVM upstream recently changed their API for registerCallbacks in
https://reviews.llvm.org/D146160 and this causes an error while building
---
 src/target/llvm/codegen_llvm.cc | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc
index ee5a6796c9..dd9c3ddb5b 100644
--- a/src/target/llvm/codegen_llvm.cc
+++ b/src/target/llvm/codegen_llvm.cc
@@ -398,7 +398,11 @@ void CodeGenLLVM::Optimize() {
   }
 
   llvm::StandardInstrumentations si(*llvm_target_->GetContext(), 
debug_logging, verify_each);
+#if LLVM_VERSION_MAJOR >= 17
+  si.registerCallbacks(pic, );
+#else
   si.registerCallbacks(pic, );
+#endif
   llvm::ModulePassManager mpass;
   if (verify_each) {
 mpass.addPass(llvm::VerifierPass());



[tvm] branch main updated (f4520c4f15 -> 32e500b7f7)

2023-03-16 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from f4520c4f15 [TVMC] Improve --desired-layouts functionality (#14272)
 add 32e500b7f7 [LLVM] Add support to generate llvm.assume (#14294)

No new revisions were added by this update.

Summary of changes:
 src/target/llvm/codegen_llvm.cc   |  3 +++
 tests/python/unittest/test_target_codegen_llvm.py | 24 +++
 2 files changed, 27 insertions(+)



[tvm] branch main updated: [LLVM] Add support for DeclBufferNode (#14103)

2023-02-23 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 125bbb271b [LLVM] Add support for DeclBufferNode (#14103)
125bbb271b is described below

commit 125bbb271bc91e4a807af57a9c2fefa64b2fb547
Author: Anirudh Sundar Subramaniam 
AuthorDate: Fri Feb 24 02:19:12 2023 +0530

[LLVM] Add support for DeclBufferNode (#14103)

`DeclBufferNode` was added recently in #12300, but support to traverse it 
in codegen_llvm was not added. Since this just stmt just declares a new buffer 
for a body of TIR, we just need to traverse the body to properly generate code 
for LLVM.
---
 src/target/llvm/codegen_llvm.cc | 5 +
 src/target/llvm/codegen_llvm.h  | 1 +
 2 files changed, 6 insertions(+)

diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc
index dcca337320..87b85290b0 100644
--- a/src/target/llvm/codegen_llvm.cc
+++ b/src/target/llvm/codegen_llvm.cc
@@ -1962,6 +1962,11 @@ void CodeGenLLVM::VisitStmt_(const SeqStmtNode* op) {
   }
 }
 
+void CodeGenLLVM::VisitStmt_(const DeclBufferNode* op) {
+  EmitDebugLocation(op);
+  VisitStmt(op->body);
+}
+
 void CodeGenLLVM::VisitStmt_(const EvaluateNode* op) {
   EmitDebugLocation(op);
   MakeValue(op->value);
diff --git a/src/target/llvm/codegen_llvm.h b/src/target/llvm/codegen_llvm.h
index 632cfaafc5..62b0b0cc4b 100644
--- a/src/target/llvm/codegen_llvm.h
+++ b/src/target/llvm/codegen_llvm.h
@@ -223,6 +223,7 @@ class CodeGenLLVM : public ExprFunctor,
   void VisitStmt_(const LetStmtNode* op) override;
   void VisitStmt_(const SeqStmtNode* op) override;
   void VisitStmt_(const EvaluateNode* op) override;
+  void VisitStmt_(const DeclBufferNode* op) override;
 
   // Get constant string
   llvm::Constant* GetConstString(const std::string& str);



[tvm] branch main updated: [LLVM] Remove call to EmitDebugLocation from AddAliasInfo (#13872)

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

kparzysz 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 c81aaa852c [LLVM] Remove call to EmitDebugLocation from AddAliasInfo 
(#13872)
c81aaa852c is described below

commit c81aaa852c5b9de72f8dbc5fdaa088e7e35bedb7
Author: Krzysztof Parzyszek 
AuthorDate: Mon Jan 30 14:15:07 2023 -0600

[LLVM] Remove call to EmitDebugLocation from AddAliasInfo (#13872)

This function only creates alias metadata, so there isn't anything
for it to create debug location information for. If `index` is used
in executable code, the debug location should be emitted then.
---
 src/target/llvm/codegen_llvm.cc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc
index 2182ecfa51..dcca337320 100644
--- a/src/target/llvm/codegen_llvm.cc
+++ b/src/target/llvm/codegen_llvm.cc
@@ -557,7 +557,6 @@ llvm::Type* CodeGenLLVM::GetLLVMType(const PrimExpr& expr) 
const {
 //
 void CodeGenLLVM::AddAliasInfo(llvm::Instruction* inst, const VarNode* 
buffer_var, PrimExpr index,
DataType access_dtype) {
-  EmitDebugLocation(index->span);
   if (alias_var_set_.count(buffer_var) != 0) {
 // Mark all possibly aliased pointer as same type.
 llvm::MDNode* meta = md_tbaa_alias_set_;



[tvm] branch main updated: [Hexagon][CI] Update the docker image ID to reflect newer LLVM (#13870)

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

kparzysz 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 803207c256 [Hexagon][CI] Update the docker image ID to reflect newer 
LLVM (#13870)
803207c256 is described below

commit 803207c2568db28753f832465f4ff5ad675d7ca3
Author: Krzysztof Parzyszek 
AuthorDate: Mon Jan 30 12:53:01 2023 -0600

[Hexagon][CI] Update the docker image ID to reflect newer LLVM (#13870)

* [Hexagon][CI] Update the docker image ID to reflect newer LLVM

The latest image ID is ci_hexagon:20230127-185848-95fa22308.

* Set C/C++ compilers in /opt/sccache to cc/c++
---
 ci/jenkins/docker-images.ini   | 2 +-
 tests/scripts/task_config_build_hexagon.sh | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ci/jenkins/docker-images.ini b/ci/jenkins/docker-images.ini
index 53ad2092ea..149ea7b76b 100644
--- a/ci/jenkins/docker-images.ini
+++ b/ci/jenkins/docker-images.ini
@@ -21,7 +21,7 @@ ci_arm: tlcpack/ci-arm:20221013-060115-61c9742ea
 ci_cortexm: tlcpack/ci-cortexm:20230116-133924-dad13d1c1
 ci_cpu: tlcpack/ci-cpu:20230110-070003-d00168ffb
 ci_gpu: tlcpack/ci-gpu:20221128-070141-ae4fd7df7
-ci_hexagon: tlcpack/ci-hexagon:20221013-060115-61c9742ea
+ci_hexagon: tlcpack/ci_hexagon:20230127-185848-95fa22308
 ci_i386: tlcpack/ci-i386:20221013-060115-61c9742ea
 ci_lint: tlcpack/ci-lint:20221013-060115-61c9742ea
 ci_minimal: tlcpack/ci-minimal:20230117-070124-125886350
diff --git a/tests/scripts/task_config_build_hexagon.sh 
b/tests/scripts/task_config_build_hexagon.sh
index 0736ed6b53..a3a42f18ee 100755
--- a/tests/scripts/task_config_build_hexagon.sh
+++ b/tests/scripts/task_config_build_hexagon.sh
@@ -31,11 +31,12 @@ echo set\(USE_LLVM "${CLANG_LLVM_HOME}/bin/llvm-config"\) 
>> config.cmake
 
 if [[ ${CI:-false} == "true" ]]; then
 # sccache needs to be used in CI to speed up builds
-echo set\(CMAKE_CXX_COMPILER "/opt/sccache/clang++"\) >> config.cmake
+echo set\(CMAKE_C_COMPILER "/opt/sccache/cc"\) >> config.cmake
+echo set\(CMAKE_CXX_COMPILER "/opt/sccache/c++"\) >> config.cmake
 else
 echo 'Skipping sccache setup for local build'
-echo set\(CMAKE_CXX_COMPILER \"/usr/bin/c++\"\) >> config.cmake
 echo set\(CMAKE_C_COMPILER \"/usr/bin/cc\"\) >> config.cmake
+echo set\(CMAKE_CXX_COMPILER \"/usr/bin/c++\"\) >> config.cmake
 fi
 
 echo set\(USE_HEXAGON "ON"\) >> config.cmake



[tvm] branch main updated: Enable C++17 for cmake modules (#13869)

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

kparzysz 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 76c5186e15 Enable C++17 for cmake modules (#13869)
76c5186e15 is described below

commit 76c5186e15b2453375ca79f81826d0c5cdff4bf6
Author: Egor Churaev 
AuthorDate: Mon Jan 30 18:01:20 2023 +0300

Enable C++17 for cmake modules (#13869)

Moved the lines which add c++17 to CXX_FLAGS before the include of
modules. After this c++17 features should be also supported in source
code of the modules.
---
 CMakeLists.txt | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 032e0bc2af..a82c640974 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -478,6 +478,17 @@ endif(USE_KALLOC_ALIGNMENT)
 # need to be re-compiled every time. Using ccache 4.0+ can resolve this issue.
 include(cmake/utils/CCache.cmake)
 
+include(CheckCXXCompilerFlag)
+if(NOT MSVC)
+  check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17)
+  set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
+  set(CMAKE_CUDA_STANDARD 17)
+else()
+  check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17)
+  set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}")
+  set(CMAKE_CUDA_STANDARD 17)
+endif()
+
 # Module rules
 include(cmake/modules/VTA.cmake)
 include(cmake/modules/StandaloneCrt.cmake)
@@ -525,17 +536,6 @@ include(cmake/modules/Git.cmake)
 include(cmake/modules/LibInfo.cmake)
 include(cmake/modules/RustExt.cmake)
 
-include(CheckCXXCompilerFlag)
-if(NOT MSVC)
-  check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17)
-  set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
-  set(CMAKE_CUDA_STANDARD 17)
-else()
-  check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17)
-  set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}")
-  set(CMAKE_CUDA_STANDARD 17)
-endif()
-
 set(LIBINFO_FILE ${CMAKE_CURRENT_LIST_DIR}/src/support/libinfo.cc)
 add_lib_info(${LIBINFO_FILE})
 list(REMOVE_ITEM COMPILER_SRCS ${LIBINFO_FILE})



[tvm] branch main updated (21d7968b61 -> 123f1f5e2c)

2023-01-06 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 21d7968b61 [microTVM] Fix MacOS build with USE_MICRO=ON (#13711)
 add 123f1f5e2c [tir] Add line level debug info (#13012)

No new revisions were added by this update.

Summary of changes:
 .gitignore|   6 ++
 include/tvm/tir/transform.h   |   7 ++
 python/tvm/tir/transform/transform.py |  12 +++
 src/driver/driver_api.cc  |   8 ++
 src/ir/transform.cc   |   1 +
 src/printer/text_printer.h|  40 
 src/printer/tir_text_printer.cc   |  53 +--
 src/printer/tir_text_printer_debug.cc |  97 +++
 src/printer/tir_text_printer_debug.h  |  70 ++
 src/target/llvm/codegen_cpu.cc|  84 ++---
 src/target/llvm/codegen_cpu.h |   2 +
 src/target/llvm/codegen_llvm.cc   |  55 +--
 src/target/llvm/codegen_llvm.h|  10 +-
 src/tir/transforms/install_debug_spans.cc | 150 ++
 src/tir/transforms/install_debug_spans.h  | 132 ++
 tests/python/tir/test_debug_info.py   | 124 
 16 files changed, 762 insertions(+), 89 deletions(-)
 create mode 100644 src/printer/tir_text_printer_debug.cc
 create mode 100644 src/printer/tir_text_printer_debug.h
 create mode 100644 src/tir/transforms/install_debug_spans.cc
 create mode 100644 src/tir/transforms/install_debug_spans.h
 create mode 100644 tests/python/tir/test_debug_info.py



[tvm] branch main updated (ce97138ebe -> cdb4eea138)

2022-12-15 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from ce97138ebe [TVMScript] Fix print round-tripable multi thread env 
binding (#13622)
 add cdb4eea138 [TOPI][Hexagon] Implement global_avg_pool2d for hexagon 
(#13614)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/qnn/__init__.py|   1 +
 python/tvm/topi/hexagon/qnn/global_avg_pool2d.py   |  95 +++
 python/tvm/topi/hexagon/slice_ops/__init__.py  |   1 +
 .../topi/hexagon/slice_ops/global_avg_pool2d.py|  52 +++
 python/tvm/topi/hexagon/utils.py   |  12 +++
 .../python/contrib/test_hexagon/infrastructure.py  |  13 +++
 .../test_global_avg_pool2d.py} | 104 +
 7 files changed, 217 insertions(+), 61 deletions(-)
 create mode 100755 python/tvm/topi/hexagon/qnn/global_avg_pool2d.py
 create mode 100755 python/tvm/topi/hexagon/slice_ops/global_avg_pool2d.py
 copy tests/python/contrib/test_hexagon/topi/{test_adaptive_avg_pool1d.py => 
slice_op/test_global_avg_pool2d.py} (60%)



[tvm] branch main updated: [tir] Add copy on write to all nodes (#13512)

2022-11-29 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 694d4bf5ea [tir] Add copy on write to all nodes (#13512)
694d4bf5ea is described below

commit 694d4bf5eaf65df4eaad93188830112c6b139956
Author: driazati <9407960+driaz...@users.noreply.github.com>
AuthorDate: Tue Nov 29 13:58:21 2022 -0800

[tir] Add copy on write to all nodes (#13512)

This enables copy on write methods for all nodes since some were missing
it before (see #13012 for more context)

Co-authored-by: driazati 
---
 include/tvm/ir/expr.h  |  2 ++
 include/tvm/tir/expr.h | 30 ++
 include/tvm/tir/stmt.h | 12 
 3 files changed, 44 insertions(+)

diff --git a/include/tvm/ir/expr.h b/include/tvm/ir/expr.h
index 94927b4892..bb4c468f45 100644
--- a/include/tvm/ir/expr.h
+++ b/include/tvm/ir/expr.h
@@ -526,6 +526,7 @@ class IntImm : public PrimExpr {
   TVM_DLL IntImm(DataType dtype, int64_t value, Span span = Span());
 
   TVM_DEFINE_OBJECT_REF_METHODS(IntImm, PrimExpr, IntImmNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(IntImmNode);
 };
 
 /*!
@@ -572,6 +573,7 @@ class FloatImm : public PrimExpr {
   TVM_DLL FloatImm(DataType dtype, double value, Span span = Span());
 
   TVM_DEFINE_OBJECT_REF_METHODS(FloatImm, PrimExpr, FloatImmNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(FloatImmNode);
 };
 
 /*!
diff --git a/include/tvm/tir/expr.h b/include/tvm/tir/expr.h
index 674ff0b7f4..689b1c0a17 100644
--- a/include/tvm/tir/expr.h
+++ b/include/tvm/tir/expr.h
@@ -79,6 +79,7 @@ class StringImm : public PrimExpr {
  public:
   TVM_DLL StringImm(String value, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(StringImm, PrimExpr, StringImmNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(StringImmNode);
 };
 
 /*!
@@ -117,6 +118,7 @@ class Cast : public PrimExpr {
  public:
   TVM_DLL Cast(DataType dtype, PrimExpr value, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Cast, PrimExpr, CastNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(CastNode);
 };
 
 /*!
@@ -165,6 +167,7 @@ class Add : public PrimExpr {
  public:
   TVM_DLL Add(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Add, PrimExpr, AddNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(AddNode);
 };
 
 /*! \brief a - b */
@@ -181,6 +184,7 @@ class Sub : public PrimExpr {
  public:
   TVM_DLL Sub(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Sub, PrimExpr, SubNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(SubNode);
 };
 
 /*! \brief a * b */
@@ -197,6 +201,7 @@ class Mul : public PrimExpr {
  public:
   TVM_DLL Mul(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Mul, PrimExpr, MulNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(MulNode);
 };
 
 /*!
@@ -216,6 +221,7 @@ class Div : public PrimExpr {
  public:
   TVM_DLL Div(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Div, PrimExpr, DivNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(DivNode);
 };
 
 /*!
@@ -235,6 +241,7 @@ class Mod : public PrimExpr {
  public:
   TVM_DLL Mod(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Mod, PrimExpr, ModNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(ModNode);
 };
 
 /*! \brief Floor division, floor(a/b) */
@@ -251,6 +258,7 @@ class FloorDiv : public PrimExpr {
  public:
   TVM_DLL FloorDiv(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(FloorDiv, PrimExpr, FloorDivNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(FloorDivNode);
 };
 
 /*! \brief The remainder of the floordiv */
@@ -267,6 +275,7 @@ class FloorMod : public PrimExpr {
  public:
   TVM_DLL FloorMod(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(FloorMod, PrimExpr, FloorModNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(FloorModNode);
 };
 
 /*! \brief min(a, b) */
@@ -283,6 +292,7 @@ class Min : public PrimExpr {
  public:
   TVM_DLL Min(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Min, PrimExpr, MinNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(MinNode);
 };
 
 /*! \brief max(a, b) */
@@ -299,6 +309,7 @@ class Max : public PrimExpr {
  public:
   TVM_DLL Max(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(Max, PrimExpr, MaxNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(MaxNode);
 };
 
 /*!
@@ -347,6 +358,7 @@ class EQ : public PrimExpr {
  public:
   TVM_DLL EQ(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(EQ, PrimExpr, EQNode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(EQNode);
 };
 
 /*! \brief a != b */
@@ -363,6 +375,7 @@ class NE : public PrimExpr {
  public:
   TVM_DLL NE(PrimExpr a, PrimExpr b, Span span = Span());
   TVM_DEFINE_OBJECT_REF_METHODS(NE, PrimExpr, NENode);
+  TVM_DEFINE_OBJECT_REF_COW_METHOD(NENode);
 };
 
 /*! \brief

[tvm] branch main updated (25e98dd5e4 -> 1e5fc25649)

2022-11-28 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 25e98dd5e4 [ACL] Enable int8 data type in pooling operators (#13488)
 add 1e5fc25649 [Hexagon]Call Acquire/Release resources API in Hexagon 
Launcher durin… (#13495)

No new revisions were added by this update.

Summary of changes:
 apps/hexagon_launcher/launcher_hexagon.cc | 6 ++
 1 file changed, 6 insertions(+)



[tvm] branch main updated (60e865a6fe -> 6cd1bb5e89)

2022-10-28 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 60e865a6fe [CI] Enable iOS RPC tests (#13229)
 add 6cd1bb5e89 [Hexagon] Update search pattern to find .so address for on 
device runs (#13230)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/hexagon/hexagon_profiler.py   | 13 +++--
 python/tvm/contrib/hexagon/profiling/process_lwp_data.py |  7 +++
 2 files changed, 14 insertions(+), 6 deletions(-)



[tvm] branch main updated (e41d0ed6eb -> 23c2909f29)

2022-10-25 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from e41d0ed6eb [Relay] Rewrite division by constant to multiply (#13182)
 add 23c2909f29 [Hexagon] Add support for instrumentation based profiling 
for Hexagon (#12971)

No new revisions were added by this update.

Summary of changes:
 apps/hexagon_launcher/README.md|  40 +++
 apps/hexagon_launcher/cmake/hexagon/CMakeLists.txt |   5 +-
 apps/hexagon_launcher/launcher_android.cc  |   9 +-
 apps/hexagon_launcher/launcher_core.h  |   3 +
 apps/hexagon_launcher/launcher_hexagon.cc  |  10 +-
 apps/hexagon_launcher/launcher_main.cc |  14 +-
 apps/hexagon_launcher/launcher_rpc.idl |   2 +-
 cmake/modules/Hexagon.cmake|   6 +
 cmake/modules/HexagonSDK.cmake |   6 +
 include/tvm/tir/builtin.h  |  10 +
 include/tvm/tir/transform.h|   6 +
 python/tvm/contrib/hexagon/build.py|  71 
 python/tvm/contrib/hexagon/hexagon_profiler.py | 119 +++
 .../contrib/hexagon/profiling/process_lwp_data.py  | 388 +
 python/tvm/contrib/hexagon/session.py  |   5 +
 python/tvm/tir/transform/transform.py  |  11 +
 src/driver/driver_api.cc   |  11 +
 src/runtime/dso_library.cc |  14 +
 src/runtime/hexagon/profiler/README.md |  99 ++
 src/runtime/hexagon/profiler/lwp_handler.S | 115 ++
 src/runtime/hexagon/profiler/prof_utils.cc |  78 +
 .../runtime/hexagon/profiler/prof_utils.h  |  12 +-
 src/runtime/hexagon/rpc/hexagon/rpc_server.cc  |  13 +
 src/runtime/hexagon/rpc/simulator/rpc_server.cc|  13 +
 src/target/llvm/codegen_hexagon.cc |  23 ++
 src/target/llvm/codegen_llvm.cc|   4 +
 src/tir/op/builtin.cc  |   6 +
 src/tir/transforms/profile_instrumentation.cc  | 293 
 tests/lint/check_file_type.py  |   1 +
 tests/python/contrib/test_hexagon/test_launcher.py | 158 +
 .../unittest/test_tir_transform_profiling_instr.py | 340 ++
 31 files changed, 1868 insertions(+), 17 deletions(-)
 create mode 100755 python/tvm/contrib/hexagon/hexagon_profiler.py
 create mode 100644 python/tvm/contrib/hexagon/profiling/process_lwp_data.py
 create mode 100644 src/runtime/hexagon/profiler/README.md
 create mode 100644 src/runtime/hexagon/profiler/lwp_handler.S
 create mode 100644 src/runtime/hexagon/profiler/prof_utils.cc
 copy apps/ios_rpc/tvmrpc/AppDelegate.h => 
src/runtime/hexagon/profiler/prof_utils.h (77%)
 create mode 100644 src/tir/transforms/profile_instrumentation.cc
 create mode 100644 tests/python/unittest/test_tir_transform_profiling_instr.py



[tvm] branch main updated (209e77c18b -> 4fe8e96c77)

2022-10-20 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 209e77c18b [tvmc] add instruments for PassContext (#13136)
 add 4fe8e96c77 [Hexagon] Set c++17 standard for launcher (#13140)

No new revisions were added by this update.

Summary of changes:
 apps/hexagon_launcher/CMakeLists.txt | 2 ++
 1 file changed, 2 insertions(+)



[tvm] branch main updated (9a673faa74 -> 332b1469b7)

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

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


from 9a673faa74 [ci] Initialize git during deploys (#12909)
 add 332b1469b7 [Hexagon] depth_to_space slice op (#12669)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/slice_ops/__init__.py  |   1 +
 .../tvm/topi/hexagon/slice_ops/depth_to_space.py   |  43 +++
 .../test_hexagon/topi/test_depth_to_space.py   | 136 +
 3 files changed, 180 insertions(+)
 create mode 100644 python/tvm/topi/hexagon/slice_ops/depth_to_space.py
 create mode 100644 
tests/python/contrib/test_hexagon/topi/test_depth_to_space.py



[tvm] branch main updated (e1f3f90588 -> f25a702a1f)

2022-09-26 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from e1f3f90588 [TOPI][Hexagon] Implement quantize op for hexagon (#12820)
 add f25a702a1f [TOPI][Hexagon] Add schedule and test for maxpool uint8 
layout (#12826)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/slice_ops/max_pool2d.py|  55 +++
 .../test_hexagon/topi/test_max_pool2d_slice.py | 105 +
 2 files changed, 100 insertions(+), 60 deletions(-)



[tvm] branch main updated (fd26813723 -> e1f3f90588)

2022-09-26 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from fd26813723 [TVMScript] Infer T.match_buffer parameters for region 
(#12890)
 add e1f3f90588 [TOPI][Hexagon] Implement quantize op for hexagon (#12820)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/qnn/__init__.py|   2 +
 python/tvm/topi/hexagon/qnn/quantize.py|  80 ++
 python/tvm/topi/hexagon/utils.py   |   5 +
 .../python/contrib/test_hexagon/infrastructure.py  |   4 +-
 .../contrib/test_hexagon/topi/test_quantize.py | 121 +
 5 files changed, 210 insertions(+), 2 deletions(-)
 create mode 100755 python/tvm/topi/hexagon/qnn/quantize.py
 create mode 100755 tests/python/contrib/test_hexagon/topi/test_quantize.py



[tvm] branch main updated (4c05656c65 -> 2eed663643)

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

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


from 4c05656c65 [TOPI][Hexagon] Add test and schedule for uint8 resize2d 
(#12559)
 add 2eed663643 [TOPI][Hexagon] Implement quantized elementwise for hexagon 
(#12606)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/qnn/__init__.py|   2 +-
 python/tvm/topi/hexagon/qnn/qadd_qsub_qmul.py  | 270 +
 .../topi/test_add_subtract_multiply.py | 217 +++--
 3 files changed, 463 insertions(+), 26 deletions(-)
 create mode 100755 python/tvm/topi/hexagon/qnn/qadd_qsub_qmul.py



[tvm] branch main updated (029fa462d2 -> 4c05656c65)

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

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


from 029fa462d2 [TIR][Arith] Add more strict checking in imm construction 
and folding. (#12515)
 add 4c05656c65 [TOPI][Hexagon] Add test and schedule for uint8 resize2d 
(#12559)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/resize2d.py| 41 +++--
 .../contrib/test_hexagon/topi/test_resize2d.py | 52 +-
 2 files changed, 80 insertions(+), 13 deletions(-)



[tvm] branch main updated (ff9a5309ec -> 269d536be0)

2022-09-07 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from ff9a5309ec [microTVM][Zephyr] Enable -O2 optimization on build by 
default (#12718)
 add 269d536be0 [HEXAGON] [TOPI] Dequantize (#12677)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/qnn/__init__.py|  5 ++
 python/tvm/topi/hexagon/qnn/dequantize.py  | 94 ++
 python/tvm/topi/hexagon/utils.py   |  7 ++
 .../python/contrib/test_hexagon/infrastructure.py  |  2 +
 ...test_tanh_slice.py => test_dequantize_slice.py} | 80 ++
 5 files changed, 154 insertions(+), 34 deletions(-)
 create mode 100644 python/tvm/topi/hexagon/qnn/dequantize.py
 copy tests/python/contrib/test_hexagon/topi/{test_tanh_slice.py => 
test_dequantize_slice.py} (57%)



[tvm] branch main updated (38ba8c0bb6 -> 038f15b5e2)

2022-09-01 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 38ba8c0bb6 [Relay] Extract intermediate node by its expression ID 
(#12646)
 add 038f15b5e2 [Hexagon] Implement fixed_point_multiply op through 
intrinsics. (#12659)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/__init__.py|   1 +
 python/tvm/topi/hexagon/injective.py   |   7 +-
 python/tvm/topi/hexagon/tensor_intrin.py   |  71 +++
 .../test_hexagon/test_fixed_point_multiply.py  | 140 +
 4 files changed, 216 insertions(+), 3 deletions(-)
 create mode 100644 python/tvm/topi/hexagon/tensor_intrin.py
 create mode 100644 
tests/python/contrib/test_hexagon/test_fixed_point_multiply.py



[tvm] branch main updated (2e83e03b2c -> 23e794422a)

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

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


from 2e83e03b2c [CI] Update Hexagon image to install boost (#12613)
 add 23e794422a Replace '> >' in templates with >>, NFC (#12615)

No new revisions were added by this update.

Summary of changes:
 docs/arch/convert_layout.rst   | 10 +++
 docs/arch/inferbound.rst   |  4 +--
 docs/dev/how_to/relay_bring_your_own_codegen.rst   |  2 +-
 include/tvm/auto_scheduler/feature.h   |  8 ++---
 include/tvm/relay/attrs/image.h| 14 -
 include/tvm/runtime/module.h   |  2 +-
 include/tvm/support/span.h |  2 +-
 include/tvm/te/operation.h |  2 +-
 include/tvm/topi/detail/extern.h   |  2 +-
 include/tvm/topi/transform.h   |  2 +-
 .../src/main/native/org_apache_tvm_native_c_api.cc |  4 +--
 src/arith/analyzer.cc  |  2 +-
 src/autotvm/touch_extractor.cc | 14 -
 src/contrib/ethosu/cascader/propagator.cc  |  8 ++---
 src/contrib/ethosu/cascader/propagator.h   |  6 ++--
 src/ir/span.cc |  2 +-
 src/node/reflection.cc |  2 +-
 src/printer/meta_data.h|  2 +-
 src/relay/analysis/dependency_graph.cc |  4 +--
 src/relay/ir/transform.cc  |  2 +-
 src/relay/transforms/convert_sparse_dense.cc   |  8 ++---
 src/relay/transforms/fuse_ops.cc   |  2 +-
 src/relay/transforms/let_list.h|  2 +-
 src/relay/transforms/partial_eval.cc   |  2 +-
 src/relay/transforms/type_infer.cc |  4 +--
 src/runtime/contrib/ethosn/ethosn_device.cc|  6 ++--
 src/runtime/graph_executor/graph_executor.cc   |  4 +--
 src/runtime/metal/metal_common.h   |  4 +--
 src/runtime/thread_pool.cc |  2 +-
 src/runtime/threading_backend.cc   |  2 +-
 src/runtime/vm/pooled_allocator.h  |  2 +-
 src/target/source/codegen_vhls.cc  |  2 +-
 src/te/operation/compute_op.cc |  8 ++---
 src/te/operation/compute_op.h  |  4 +--
 src/te/operation/tensor_compute_op.cc  | 13 -
 src/te/operation/tensorize.cc  | 29 +-
 src/te/schedule/graph.h|  6 ++--
 src/te/schedule/schedule_dataflow_rewrite.cc   |  2 +-
 src/tir/ir/buffer.cc   |  8 ++---
 src/tir/transforms/coproc_sync.cc  | 34 +++---
 src/tir/transforms/inject_double_buffer.cc |  4 +--
 src/tir/transforms/inject_virtual_thread.cc|  2 +-
 src/tir/transforms/ir_utils.h  |  2 +-
 src/tir/transforms/make_packed_api.cc  |  6 ++--
 src/tir/transforms/storage_access.h|  2 +-
 src/tir/transforms/storage_rewrite.cc  |  4 +--
 46 files changed, 128 insertions(+), 130 deletions(-)



[tvm] branch main updated (038523e5a2 -> bf65b396c1)

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

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


from 038523e5a2 [TIR] Expose Vector-related API in Python (#12571)
 add bf65b396c1 [Hexagon] Add support to run on multiple devices (#12504)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/hexagon/pytest_plugin.py | 60 +
 tests/scripts/setup-pytest-env.sh   |  2 +-
 tests/scripts/task_python_hexagon.sh| 14 ++-
 3 files changed, 59 insertions(+), 17 deletions(-)



[tvm] branch main updated (13ebbfb37f -> 8174d082e8)

2022-08-23 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 13ebbfb37f Replace std::result_of (deprecated in C++17) with 
std::invoke_result, NFC (#12562)
 add 8174d082e8 Add using directives for otherwise hidden virtual 
functions, NFC (#12561)

No new revisions were added by this update.

Summary of changes:
 src/relay/backend/annotate_used_memory.cc| 2 +-
 src/relay/transforms/annotate_texture_storage.cc | 4 
 src/relay/transforms/compiler_function_utils.cc  | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)



[tvm] branch main updated (66a31e97a7 -> e5e05feee3)

2022-08-22 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 66a31e97a7 [CI] Add alexnet and googlenet caffe model to request hook 
(#12510)
 add e5e05feee3 [LLVM] Add "cl-opt" attribute to target_kind "llvm" (#12440)

No new revisions were added by this update.

Summary of changes:
 src/target/llvm/llvm_instance.cc| 430 +++-
 src/target/llvm/llvm_instance.h | 194 ++---
 src/target/llvm/llvm_module.cc  |   4 +-
 src/target/target_kind.cc   |  24 ++
 tests/cpp/target_test.cc| 160 +++
 tests/python/unittest/test_target_target.py |   7 +
 6 files changed, 765 insertions(+), 54 deletions(-)



[tvm] branch main updated: [ci][tvmbot] Search more users when checking usernames (#12491)

2022-08-18 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 72b0f5ee34 [ci][tvmbot] Search more users when checking usernames 
(#12491)
72b0f5ee34 is described below

commit 72b0f5ee34be6acfadf7afc61264eef42b78c789
Author: driazati <9407960+driaz...@users.noreply.github.com>
AuthorDate: Thu Aug 18 17:12:12 2022 -0600

[ci][tvmbot] Search more users when checking usernames (#12491)

To figure out a user's association with the repo this code before
searched the associations in the repo filtered by the relevant username.
GitHub doesn't return the exact match only though, so we have to instead
collect many results and search through all of them.

Co-authored-by: driazati 
---
 tests/scripts/github_tvmbot.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/scripts/github_tvmbot.py b/tests/scripts/github_tvmbot.py
index ecda871123..3a39e69694 100755
--- a/tests/scripts/github_tvmbot.py
+++ b/tests/scripts/github_tvmbot.py
@@ -49,7 +49,7 @@ def to_json_str(obj: Any) -> str:
 COLLABORATORS_QUERY = """
 query ($owner: String!, $name: String!, $user: String!) {
   repository(owner: $owner, name: $name) {
-collaborators(query: $user, first: 1) {
+collaborators(query: $user, first: 100) {
   nodes {
 login
   }
@@ -61,7 +61,7 @@ query ($owner: String!, $name: String!, $user: String!) {
 MENTIONABLE_QUERY = """
 query ($owner: String!, $name: String!, $user: String!) {
   repository(owner: $owner, name: $name) {
-mentionableUsers(query: $user, first: 1) {
+mentionableUsers(query: $user, first: 100) {
   nodes {
 login
   }



[tvm] branch main updated: [Target] Only append default keys if target doesn't have any yet (#12474)

2022-08-18 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 6def53aeaa [Target] Only append default keys if target doesn't have 
any yet (#12474)
6def53aeaa is described below

commit 6def53aeaa51b4c24290909500057b3166fbeeea
Author: Krzysztof Parzyszek 
AuthorDate: Thu Aug 18 18:11:23 2022 -0500

[Target] Only append default keys if target doesn't have any yet (#12474)

* [Target] Only append default keys if target doesn't have any yet

This allows target parsers to provide their own target keys. Without this
change, the default keys would always be appended, which may or may not
be desirable.

* Add "cpu" to ARM CPU keys

* Add "cpu" to the keys in the mprofile target parser

* Restore the mprofile cpptest, since the "cpu" key is back

* So the -device attribute is actually needed...
---
 python/tvm/target/target.py   | 32 +++
 src/target/parsers/mprofile.cc| 10 ++
 src/target/target.cc  | 11 +++
 tests/cpp/target/parsers/mprofile_test.cc |  3 ++-
 tests/cpp/target_test.cc  |  3 +--
 5 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/python/tvm/target/target.py b/python/tvm/target/target.py
index aee4aa31a7..e0e5f0177b 100644
--- a/python/tvm/target/target.py
+++ b/python/tvm/target/target.py
@@ -531,7 +531,7 @@ def arm_cpu(model="unknown", options=None):
 }
 pre_defined_opt = trans_table.get(model, ["-model=%s" % model])
 
-opts = ["-device=arm_cpu"] + pre_defined_opt
+opts = ["-keys=arm_cpu,cpu", "-device=arm_cpu"] + pre_defined_opt
 opts = _merge_opts(opts, options)
 return Target(" ".join(["llvm"] + opts))
 
@@ -612,7 +612,7 @@ def riscv_cpu(model="sifive-u54", options=None):
 }
 pre_defined_opt = trans_table.get(model, ["-model=%s" % model])
 
-opts = ["-device=arm_cpu"] + pre_defined_opt
+opts = ["-keys=arm_cpu,cpu", "-device=arm_cpu"] + pre_defined_opt
 opts = _merge_opts(opts, options)
 return Target(" ".join(["llvm"] + opts))
 
@@ -762,22 +762,22 @@ def hexagon(cpu_ver="v66", **kwargs):
 
 STM32_SUPPORTED_SERIES = {
 # High-Performance
-"stm32H7xx": ["-device=arm_cpu", "-mcpu=cortex-m7", "-march=armv7e-m"],
-"stm32F7xx": ["-device=arm_cpu", "-mcpu=cortex-m7"],
-"stm32F4xx": ["-device=arm_cpu", "-mcpu=cortex-m4"],
-"stm32F2xx": ["-device=arm_cpu", "-mcpu=cortex-m3"],
+"stm32H7xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m7", 
"-march=armv7e-m"],
+"stm32F7xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m7"],
+"stm32F4xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m4"],
+"stm32F2xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m3"],
 # Mainstream
-"stm32G0xx": ["-device=arm_cpu", "-mcpu=cortex-m0+"],
-"stm32F0xx": ["-device=arm_cpu", "-mcpu=cortex-m0"],
-"stm32F1xx": ["-device=arm_cpu", "-mcpu=cortex-m3"],
-"stm32G4xx": ["-device=arm_cpu", "-mcpu=cortex-m4"],
-"stm32F3xx": ["-device=arm_cpu", "-mcpu=cortex-m4"],
+"stm32G0xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m0+"],
+"stm32F0xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m0"],
+"stm32F1xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m3"],
+"stm32G4xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m4"],
+"stm32F3xx": ["-keys=arm_cpu,cpu", "-device=arm_cpu", "-mcpu=cortex-m4"],
 # Low-power
-"stm32U5xx": ["-device=arm_cpu", "-mcpu=cortex-m33"],
-"stm32L5xx": ["-device=arm_cpu", "-mcpu=cortex-m33"],
-"stm32L4xx": ["-device=arm_cpu", "-mcpu=cortex-m4"],
-"stm32L1xx": ["-device=arm_cpu", "-mcpu=cortex-m3"],
-"stm32L0xx": ["-device=arm_cpu", "-mcpu=cortex-m0+"],
+"stm32U5x

[tvm] branch main updated: [HEXAGON] Auto-vectorization (fp16) for v68 (#12397)

2022-08-18 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 88928a40f1 [HEXAGON] Auto-vectorization (fp16) for v68 (#12397)
88928a40f1 is described below

commit 88928a40f15d080046dfe26200835670a9d8a925
Author: Aakanksha Verma <89928182+avquic...@users.noreply.github.com>
AuthorDate: Thu Aug 18 23:10:05 2022 +0530

[HEXAGON] Auto-vectorization (fp16) for v68 (#12397)

* Auto-vectorization (fp16) for v68

* use tvm.testing.main in fp16 test of tanh_slice op
---
 python/tvm/target/target.py   | 6 ++
 tests/python/contrib/test_hexagon/topi/test_tanh_slice.py | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/python/tvm/target/target.py b/python/tvm/target/target.py
index e53c709627..aee4aa31a7 100644
--- a/python/tvm/target/target.py
+++ b/python/tvm/target/target.py
@@ -724,6 +724,12 @@ def hexagon(cpu_ver="v66", **kwargs):
 
 llvm_options = config["llvm_options"]
 
+# To enable auto-vectorization for v68 target added the below 
llvm-option by default
+if arch_version == 68:
+if not llvm_options:
+llvm_options = ""
+llvm_options += " -force-hvx-float"
+
 # TVM's option parser doesn't allow '=' in values, but '=' can
 # appear in LLVM flags. Replace it with '@', since it's unlikely
 # that '@' will be used in another context.
diff --git a/tests/python/contrib/test_hexagon/topi/test_tanh_slice.py 
b/tests/python/contrib/test_hexagon/topi/test_tanh_slice.py
index b1e85971a2..d488d7dd46 100644
--- a/tests/python/contrib/test_hexagon/topi/test_tanh_slice.py
+++ b/tests/python/contrib/test_hexagon/topi/test_tanh_slice.py
@@ -106,4 +106,4 @@ class TestTanhSlice:
 
 
 if __name__ == "__main__":
-sys.exit(pytest.main(sys.argv))
+tvm.testing.main()



[tvm] branch main updated (da7675c546 -> a96bda446c)

2022-08-18 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from da7675c546 Fix memset of memory pool in PageMemoryManagerCreate 
(#12437)
 add a96bda446c Add RISC-V build/test pipeline to Jenkins. (#12441)

No new revisions were added by this update.

Summary of changes:
 Jenkinsfile| 257 +
 ci/jenkins/Build.groovy.j2 |  18 ++
 ci/jenkins/Test.groovy.j2  |  20 ++
 ci/jenkins/generate.py |  10 +-
 tests/scripts/ci.py|  14 ++
 ...build_cortexm.sh => task_config_build_riscv.sh} |   2 -
 ...m_compute_library.sh => task_riscv_microtvm.sh} |   9 +-
 7 files changed, 272 insertions(+), 58 deletions(-)
 copy tests/scripts/{task_config_build_cortexm.sh => 
task_config_build_riscv.sh} (96%)
 copy tests/scripts/{task_python_arm_compute_library.sh => 
task_riscv_microtvm.sh} (77%)



[tvm] branch main updated (250b68e202 -> da7675c546)

2022-08-18 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 250b68e202 [TVMScript] IRBuilder, IRBuilderFrame base class (#12482)
 add da7675c546 Fix memset of memory pool in PageMemoryManagerCreate 
(#12437)

No new revisions were added by this update.

Summary of changes:
 src/runtime/crt/memory/page_allocator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[tvm] branch main updated: Use std::make_unique instead of std::unique_ptr(new ...), NFC (#12459)

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

kparzysz 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 247c54b97d Use std::make_unique instead of std::unique_ptr(new ...), 
NFC (#12459)
247c54b97d is described below

commit 247c54b97dffaa8afbe5681310f73306551b53e8
Author: Krzysztof Parzyszek 
AuthorDate: Tue Aug 16 16:06:48 2022 -0500

Use std::make_unique instead of std::unique_ptr(new ...), NFC (#12459)
---
 apps/cpp_rpc/win32_process.cc| 4 ++--
 include/tvm/runtime/logging.h| 3 +--
 include/tvm/target/target_kind.h | 6 +++---
 src/relay/analysis/call_graph.cc | 2 +-
 src/runtime/contrib/edgetpu/edgetpu_runtime.cc   | 2 +-
 src/runtime/contrib/tflite/tflite_runtime.cc | 2 +-
 src/runtime/graph_executor/debug/graph_executor_debug.cc | 4 ++--
 src/runtime/rpc/rpc_event_impl.cc| 2 +-
 src/runtime/rpc/rpc_pipe_impl.cc | 5 ++---
 src/runtime/rpc/rpc_socket_impl.cc   | 8 +++-
 src/runtime/thread_pool.cc   | 9 -
 src/target/llvm/codegen_amdgpu.cc| 2 +-
 src/target/llvm/codegen_hexagon.cc   | 2 +-
 src/target/llvm/codegen_nvptx.cc | 2 +-
 src/target/llvm/llvm_module.cc   | 4 ++--
 src/tir/transforms/storage_rewrite.cc| 2 +-
 tests/cpp/aot_metadata_test.cc   | 2 +-
 17 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/apps/cpp_rpc/win32_process.cc b/apps/cpp_rpc/win32_process.cc
index bbf8367903..cd24e34b55 100644
--- a/apps/cpp_rpc/win32_process.cc
+++ b/apps/cpp_rpc/win32_process.cc
@@ -178,7 +178,7 @@ void SpawnRPCChild(SOCKET fd, seconds timeout) {
   child_command_line += file_map_path;
 
   // CreateProcessA requires a non const char*, so we copy our std::string
-  std::unique_ptr command_line_ptr(new char[child_command_line.size() 
+ 1]);
+  auto command_line_ptr = std::make_unique(child_command_line.size() + 
1);
   strcpy(command_line_ptr.get(), child_command_line.c_str());
 
   PROCESS_INFORMATION child_process_info;
@@ -258,4 +258,4 @@ void ChildProcSocketHandler(const std::string& mmap_path) {
   }
 }
 }  // namespace runtime
-}  // namespace tvm
\ No newline at end of file
+}  // namespace tvm
diff --git a/include/tvm/runtime/logging.h b/include/tvm/runtime/logging.h
index 8f6ccea40b..7b635eab04 100644
--- a/include/tvm/runtime/logging.h
+++ b/include/tvm/runtime/logging.h
@@ -540,8 +540,7 @@ std::unique_ptr LogCheckFormat(const X& x, 
const Y& y) {
   std::ostringstream os;
   os << " (" << x << " vs. " << y << ") ";  // CHECK_XX(x, y) requires x and y 
can be serialized to
 // string. Use CHECK(x OP y) 
otherwise.
-  // no std::make_unique until c++14
-  return std::unique_ptr(new std::string(os.str()));
+  return std::make_unique(os.str());
 }
 
 // Inline _Pragma in macros does not work reliably on old version of MSVC and
diff --git a/include/tvm/target/target_kind.h b/include/tvm/target/target_kind.h
index 96a6f27a86..63c92fedbd 100644
--- a/include/tvm/target/target_kind.h
+++ b/include/tvm/target/target_kind.h
@@ -324,7 +324,7 @@ struct ValueTypeInfoMaker {
 ValueTypeInfo info;
 info.type_index = tindex;
 info.type_key = runtime::Object::TypeIndex2Key(tindex);
-info.key = std::unique_ptr(new ValueTypeInfo(key_type()()));
+info.key = std::make_unique(key_type()());
 info.val = nullptr;
 return info;
   }
@@ -340,8 +340,8 @@ struct ValueTypeInfoMaker {
 ValueTypeInfo info;
 info.type_index = tindex;
 info.type_key = runtime::Object::TypeIndex2Key(tindex);
-info.key = std::unique_ptr(new ValueTypeInfo(key_type()()));
-info.val = std::unique_ptr(new ValueTypeInfo(val_type()()));
+info.key = std::make_unique(key_type()());
+info.val = std::make_unique(val_type()());
 return info;
   }
 };
diff --git a/src/relay/analysis/call_graph.cc b/src/relay/analysis/call_graph.cc
index 17bbe5e951..d12ec7b98c 100644
--- a/src/relay/analysis/call_graph.cc
+++ b/src/relay/analysis/call_graph.cc
@@ -112,7 +112,7 @@ CallGraphEntry* CallGraphNode::LookupGlobalVar(const 
GlobalVar& gv) {
   if (call_graph_node) return call_graph_node.get();
 
   // Create the node for the inserted entry.
-  call_graph_node = std::unique_ptr(new CallGraphEntry(gv));
+  call_graph_node = std::make_unique(gv);
   return call_graph_node.get();
 }
 
diff --git a/src/runtime/contrib/edgetpu/edgetpu_runtime.cc 
b/src/runtime/contrib/edgetpu/edgetpu_runtime.cc
index bf179cc8cf..a2f159b55d 100644
--- a/src/runtime/contrib/edgetpu/edgetpu_ru

[tvm] branch main updated (09a4ac48ed -> bd56231325)

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

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


from 09a4ac48ed [ETHOSN] Add support for Requantize (#12384)
 add bd56231325 Use std::optional instead of dmlc::optional, NFC (#12443)

No new revisions were added by this update.

Summary of changes:
 apps/hexagon_api/CMakeLists.txt|   5 +-
 apps/hexagon_launcher/cmake/android/CMakeLists.txt |   2 +-
 apps/hexagon_launcher/cmake/hexagon/CMakeLists.txt |   2 +-
 conda/recipe/build.sh  |   2 +-
 src/relay/transforms/fold_explicit_padding.cc  |  13 ++-
 src/relay/transforms/pattern_utils.h   |  35 ---
 src/runtime/hexagon/rpc/simulator/session.cc   | 113 -
 src/runtime/vm/profiler/vm.cc  |   2 +-
 src/runtime/vm/profiler/vm.h   |   4 +-
 src/te/autodiff/ad_simplify.cc |   8 +-
 src/tir/transforms/common_subexpr_elim_tools.h |   5 +-
 11 files changed, 85 insertions(+), 106 deletions(-)



[tvm] branch main updated (c3c7c4ccc3 -> db1ed779f8)

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

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


from c3c7c4ccc3 [Profiler] Fix graph_executor_debug hang (#12382)
 add db1ed779f8 [docs] Update minimum compiler requirements for building 
from source (#12405)

No new revisions were added by this update.

Summary of changes:
 docs/install/from_source.rst | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)



[tvm] branch main updated: Update C++ standard to C++17 (#12337)

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

kparzysz 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 99f5e921a5 Update C++ standard to C++17 (#12337)
99f5e921a5 is described below

commit 99f5e921a51691529c48037dd20a44cf0edec147
Author: Krzysztof Parzyszek 
AuthorDate: Thu Aug 11 17:21:53 2022 -0500

Update C++ standard to C++17 (#12337)

* Update C++ standard to C++17

LLVM has switched to C++17 in its development branch. Follow suit to be
able to compile LLVM headers.

* Clang 8.0+ also supports -faligned-new

* Make make verbose

* Use CMAKE_OSX_DEPLOYMENT_TARGET to set minimum macOS version (10.12)

* Update llvmdev version in conda to >= 11

Something seems to be wrong with the llvmdev 10.0.0 packages, since the
LLVM unit test fails on Windows. It works fine when LLVM 10 is compiled
from sources.
---
 CMakeLists.txt  | 14 +++---
 apps/android_camera/app/src/main/jni/Application.mk |  2 +-
 apps/android_deploy/app/src/main/jni/Application.mk |  2 +-
 apps/android_rpc/app/src/main/jni/Application.mk|  2 +-
 apps/bundle_deploy/Makefile |  2 +-
 apps/dso_plugin_module/Makefile |  2 +-
 apps/extension/Makefile |  2 +-
 apps/howto_deploy/Makefile  |  2 +-
 apps/howto_deploy/tvm_runtime_pack.cc   |  2 +-
 apps/rocm_rpc/Makefile  |  2 +-
 apps/tf_tvmdsoop/CMakeLists.txt |  2 +-
 conda/build-environment.yaml|  2 +-
 conda/recipe/build.sh   |  6 --
 conda/recipe/meta.yaml  |  6 +++---
 golang/Makefile |  2 +-
 python/setup.py |  2 +-
 16 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a321f64b3a..4bc4d1823f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -202,7 +202,7 @@ else(MSVC)
   set(TVM_VISIBILITY_FLAG "-fvisibility=hidden")
 endif(HIDE_PRIVATE_SYMBOLS)
   endif ()
-  if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
+  if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND
   CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
 set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}")
   endif()
@@ -505,13 +505,13 @@ include(cmake/modules/RustExt.cmake)
 
 include(CheckCXXCompilerFlag)
 if(NOT MSVC)
-  check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14)
-  set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
-  set(CMAKE_CUDA_STANDARD 14)
+  check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17)
+  set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
+  set(CMAKE_CUDA_STANDARD 17)
 else()
-  check_cxx_compiler_flag("/std:c++14" SUPPORT_CXX14)
-  set(CMAKE_CXX_FLAGS "/std:c++14 ${CMAKE_CXX_FLAGS}")
-  set(CMAKE_CUDA_STANDARD 14)
+  check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17)
+  set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}")
+  set(CMAKE_CUDA_STANDARD 17)
 endif()
 
 set(LIBINFO_FILE ${CMAKE_CURRENT_LIST_DIR}/src/support/libinfo.cc)
diff --git a/apps/android_camera/app/src/main/jni/Application.mk 
b/apps/android_camera/app/src/main/jni/Application.mk
index 6ac3271f49..83b7b4417b 100644
--- a/apps/android_camera/app/src/main/jni/Application.mk
+++ b/apps/android_camera/app/src/main/jni/Application.mk
@@ -31,7 +31,7 @@ include $(config)
 APP_ABI ?= all
 APP_STL := c++_shared
 
-APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
+APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++17 -Oz -frtti
 ifeq ($(USE_OPENCL), 1)
 APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
 endif
diff --git a/apps/android_deploy/app/src/main/jni/Application.mk 
b/apps/android_deploy/app/src/main/jni/Application.mk
index 220c6af3bc..4a83907ff3 100644
--- a/apps/android_deploy/app/src/main/jni/Application.mk
+++ b/apps/android_deploy/app/src/main/jni/Application.mk
@@ -27,7 +27,7 @@ include $(config)
 
 APP_STL := c++_static
 
-APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
+APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++17 -Oz -frtti
 ifeq ($(USE_OPENCL), 1)
APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
 endif
diff --git a/apps/android_rpc/app/src/main/jni/Application.mk 
b/apps/android_rpc/app/src/main/jni/Application.mk
index e3078906ff..df560863f0 100644
--- a/apps/android_rpc/app/src/main/jni/Application.mk
+++ b/apps/android_rpc/app/src/main/jni/Application.mk
@@ -31,7 +31,7 @@ include $(config)
 APP_ABI ?= armeabi-v7a arm64-v8a x86 x86_64 mips
 APP_STL := c++_shared
 
-APP_CPPFLAGS +=

[tvm] branch main updated: [TVMScript] Make classes derived from ObjectPath non-nullable (#12304)

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

kparzysz 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 359a642e92 [TVMScript] Make classes derived from ObjectPath 
non-nullable (#12304)
359a642e92 is described below

commit 359a642e927ba9275f6b8cf52d48ff82c566948d
Author: Krzysztof Parzyszek 
AuthorDate: Thu Aug 4 13:04:21 2022 -0500

[TVMScript] Make classes derived from ObjectPath non-nullable (#12304)

`ObjectPath` is marked as non-nullable, which causes it not to have a
default constructor. The derived classes, on the other hand, are not
marked as such, thus getting an explicitly defaulted default constructor
(via TVM macros). This constructor can't actually be called since it
ends up being deleted, so the derived classes are effectively non-
nullable.
---
 include/tvm/node/object_path.h | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/tvm/node/object_path.h b/include/tvm/node/object_path.h
index 5175c5b0c4..35f947a68f 100644
--- a/include/tvm/node/object_path.h
+++ b/include/tvm/node/object_path.h
@@ -147,7 +147,7 @@ class RootPathNode final : public ObjectPathNode {
 
 class RootPath : public ObjectPath {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(RootPath, ObjectPath, RootPathNode);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(RootPath, ObjectPath, 
RootPathNode);
 };
 
 // - Attribute access -
@@ -169,7 +169,8 @@ class AttributeAccessPathNode final : public ObjectPathNode 
{
 
 class AttributeAccessPath : public ObjectPath {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(AttributeAccessPath, ObjectPath, 
AttributeAccessPathNode);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(AttributeAccessPath, ObjectPath,
+AttributeAccessPathNode);
 };
 
 // - Unknown attribute access -
@@ -188,8 +189,8 @@ class UnknownAttributeAccessPathNode final : public 
ObjectPathNode {
 
 class UnknownAttributeAccessPath : public ObjectPath {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(UnknownAttributeAccessPath, ObjectPath,
-UnknownAttributeAccessPathNode);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(UnknownAttributeAccessPath, 
ObjectPath,
+UnknownAttributeAccessPathNode);
 };
 
 // - Array element access by index -
@@ -211,7 +212,7 @@ class ArrayIndexPathNode : public ObjectPathNode {
 
 class ArrayIndexPath : public ObjectPath {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(ArrayIndexPath, ObjectPath, 
ArrayIndexPathNode);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(ArrayIndexPath, ObjectPath, 
ArrayIndexPathNode);
 };
 
 // - Missing array element -
@@ -233,7 +234,8 @@ class MissingArrayElementPathNode : public ObjectPathNode {
 
 class MissingArrayElementPath : public ObjectPath {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(MissingArrayElementPath, ObjectPath, 
MissingArrayElementPathNode);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(MissingArrayElementPath, 
ObjectPath,
+MissingArrayElementPathNode);
 };
 
 // - Map value -
@@ -255,7 +257,7 @@ class MapValuePathNode : public ObjectPathNode {
 
 class MapValuePath : public ObjectPath {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(MapValuePath, ObjectPath, MapValuePathNode);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(MapValuePath, ObjectPath, 
MapValuePathNode);
 };
 
 // - Missing map entry -
@@ -274,7 +276,8 @@ class MissingMapEntryPathNode : public ObjectPathNode {
 
 class MissingMapEntryPath : public ObjectPath {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(MissingMapEntryPath, ObjectPath, 
MissingMapEntryPathNode);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(MissingMapEntryPath, ObjectPath,
+MissingMapEntryPathNode);
 };
 
 }  // namespace tvm



[tvm] branch main updated (46a8498ba9 -> 2e02cf7cbe)

2022-08-03 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 46a8498ba9 [MetaSchedule] Enhance Conv2d NCHW Winograd Schedule Rules 
(#12127)
 add 2e02cf7cbe [LLVM] Create LLVM scope object for use with LLVM libraries 
(#12140)

No new revisions were added by this update.

Summary of changes:
 src/target/llvm/codegen_amdgpu.cc  |  30 +-
 src/target/llvm/codegen_arm.cc |   5 +-
 src/target/llvm/codegen_blob.cc|  24 +-
 src/target/llvm/codegen_blob.h |  15 +-
 src/target/llvm/codegen_cpu.cc |  94 +++---
 src/target/llvm/codegen_cpu.h  |  10 +-
 src/target/llvm/codegen_hexagon.cc |  51 ++-
 src/target/llvm/codegen_llvm.cc| 142 
 src/target/llvm/codegen_llvm.h |  29 +-
 src/target/llvm/codegen_nvptx.cc   |  33 +-
 src/target/llvm/codegen_x86_64.cc  |   8 +-
 src/target/llvm/llvm_common.cc | 211 
 src/target/llvm/llvm_common.h  |  89 -
 src/target/llvm/llvm_instance.cc   | 365 
 src/target/llvm/llvm_instance.h| 266 +++
 src/target/llvm/llvm_module.cc | 672 +
 src/target/llvm/llvm_module.h  |   1 -
 17 files changed, 1157 insertions(+), 888 deletions(-)
 delete mode 100644 src/target/llvm/llvm_common.cc
 delete mode 100644 src/target/llvm/llvm_common.h
 create mode 100644 src/target/llvm/llvm_instance.cc
 create mode 100644 src/target/llvm/llvm_instance.h



[tvm] branch main updated: [Relay][VM] Fix an ICHECK which never fails in ctor of VMFunction (#12241)

2022-07-30 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 c0a3da84bc [Relay][VM] Fix an ICHECK which never fails in ctor of 
VMFunction (#12241)
c0a3da84bc is described below

commit c0a3da84bcc801e21d8e4dfc68a68665977d8912
Author: Twice 
AuthorDate: Sun Jul 31 01:47:58 2022 +0800

[Relay][VM] Fix an ICHECK which never fails in ctor of VMFunction (#12241)
---
 include/tvm/runtime/vm/vm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/tvm/runtime/vm/vm.h b/include/tvm/runtime/vm/vm.h
index e58fe5eeb3..f58df7d5af 100644
--- a/include/tvm/runtime/vm/vm.h
+++ b/include/tvm/runtime/vm/vm.h
@@ -94,7 +94,7 @@ struct VMFunction {
 instructions(std::move(instructions)),
 register_file_size(register_file_size),
 param_device_indexes(std::move(param_device_indexes)) {
-ICHECK_EQ(params.size(), param_device_indexes.size());
+ICHECK_EQ(this->params.size(), this->param_device_indexes.size());
   }
 
   VMFunction() = default;



[tvm] branch main updated: [AutoSchedule] Fix misusage of an already-moved object (#12239)

2022-07-30 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 12dcfd70ef [AutoSchedule] Fix misusage of an already-moved object 
(#12239)
12dcfd70ef is described below

commit 12dcfd70ef365a9d5cdccdcc516bf818367e561a
Author: Twice 
AuthorDate: Sun Jul 31 01:32:54 2022 +0800

[AutoSchedule] Fix misusage of an already-moved object (#12239)
---
 src/auto_scheduler/search_policy/sketch_policy.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/auto_scheduler/search_policy/sketch_policy.cc 
b/src/auto_scheduler/search_policy/sketch_policy.cc
index 4a4ab18b5e..8b0faed5b5 100644
--- a/src/auto_scheduler/search_policy/sketch_policy.cc
+++ b/src/auto_scheduler/search_policy/sketch_policy.cc
@@ -150,7 +150,7 @@ SketchPolicy::SketchPolicy(SearchTask task, CostModel 
program_cost_model,
 node->mutation_rules.push_back(std::make_shared(0.90));
 node->mutation_rules.push_back(std::make_shared(0.10));
   } else {
-LOG(FATAL) << "No default sketch rules for target: " << task->target;
+LOG(FATAL) << "No default sketch rules for target: " << 
node->search_task->target;
   }
 
   data_ = std::move(node);



[tvm] branch main updated: [TOPI][HEXAGON] Implement depthwise conv2d slice op. (#12218)

2022-07-29 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 c6d733a7eb [TOPI][HEXAGON] Implement depthwise conv2d slice op. 
(#12218)
c6d733a7eb is described below

commit c6d733a7eba7d5d86fef224d6215b8b14c350cda
Author: arangasa <76030063+arang...@users.noreply.github.com>
AuthorDate: Sat Jul 30 00:31:57 2022 +0530

[TOPI][HEXAGON] Implement depthwise conv2d slice op. (#12218)
---
 python/tvm/topi/hexagon/slice_ops/__init__.py  |   1 +
 python/tvm/topi/hexagon/slice_ops/dwconv2d.py  | 162 +++
 .../test_hexagon/topi/test_dwconv2d_slice.py   | 318 +
 3 files changed, 481 insertions(+)

diff --git a/python/tvm/topi/hexagon/slice_ops/__init__.py 
b/python/tvm/topi/hexagon/slice_ops/__init__.py
index c178aeeb0e..fe1180e439 100644
--- a/python/tvm/topi/hexagon/slice_ops/__init__.py
+++ b/python/tvm/topi/hexagon/slice_ops/__init__.py
@@ -33,3 +33,4 @@ from .conv2d import *
 from .reshape import reshape_compute, reshape_stir_schedule
 from .relu import relu_compute, relu_stir_schedule
 from .tanh import tanh_te_compute, tanhf16_schedule
+from .dwconv2d import *
diff --git a/python/tvm/topi/hexagon/slice_ops/dwconv2d.py 
b/python/tvm/topi/hexagon/slice_ops/dwconv2d.py
new file mode 100644
index 00..698495daf1
--- /dev/null
+++ b/python/tvm/topi/hexagon/slice_ops/dwconv2d.py
@@ -0,0 +1,162 @@
+# 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=line-too-long
+
+"""Hexagon slice dwconv2d compute and schedule"""
+import typing
+
+import tvm
+from tvm import te
+from ..utils import get_layout_transform_fn
+
+
+def dwconv2d_compute(
+activations: te.Tensor,
+weights: te.Tensor,
+out_shape: typing.Tuple,
+stride: typing.Tuple,
+dilation: typing.Tuple,
+dtype: str,
+) -> te.Tensor:
+"""Compute for slice dwconv2d op for hexagon.
+This op makes the following assumptions:
+1. This op is written for a sliced dw convolution with 2d physical buffers
+2. The input activations is assumed to be in NHWC layout and filter is in 
HWIO layout
+Parameters
+--
+activations : te.Tensor
+Input activations padded for inner dimension size
+weights : te.Tensor
+Weights without dilation
+out_shape : typing.Tuple
+The logical output shape without considering input padding
+stride : typing.Tuple
+stride
+dilation : typing.Tuple
+dilation
+dtype : str
+dtype
+Returns
+---
+output : te.Tensor
+Output of applying 2D depthwise convolution of Weights on Input
+"""
+
+filt_shape = weights.shape
+
+reduce_height = tvm.te.reduce_axis((0, filt_shape[0]), 
name="reduce_height")
+reduce_width = tvm.te.reduce_axis((0, filt_shape[1]), name="reduce_width")
+stride_height, stride_width = stride
+dilation_height, dilation_width = dilation
+output = tvm.te.compute(
+out_shape,
+lambda n, h, w, c: tvm.te.sum(
+(
+activations[
+n,
+h * stride_height + reduce_height * dilation_height,
+w * stride_width + reduce_width * dilation_width,
+c,
+]
+* weights[reduce_height, reduce_width, 0, c]
+).astype(dtype),
+axis=[reduce_height, reduce_width],
+),
+name="Output",
+)
+return output
+
+
+def dwconv2d_schedule(
+outs: te.Tensor,
+ins: typing.List[te.Tensor],
+transform_activation_layout: str,
+transform_weights: typing.Callable,
+) -> tvm.tir.Schedule:
+"""STIR schedule definition for the compute defined above by 
dwconv2d_compute.
+- Auto-generated prim_func before applying schedule primitives for 
reference
+- The below TVMScript code is for dwconv2d with padded input 
dimensions and a stride of 1x1
+# from tvm.script import tir 

[tvm] branch main updated (465b579e3b -> 7b6cb60fcb)

2022-07-27 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 465b579e3b [ci][docker] Use RFC image tags only (#11938)
 add 7b6cb60fcb [Target] Improve string interpretation in Target creation 
(#12152)

No new revisions were added by this update.

Summary of changes:
 src/target/target.cc | 258 ++-
 tests/cpp/target_test.cc |  86 
 2 files changed, 274 insertions(+), 70 deletions(-)



[tvm] branch main updated: tanh float16 (#12165)

2022-07-24 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 dc1324635a tanh float16 (#12165)
dc1324635a is described below

commit dc1324635a52e9cf0a8dbf535c58e60b92fe4736
Author: Aakanksha Verma <89928182+avquic...@users.noreply.github.com>
AuthorDate: Mon Jul 25 02:58:09 2022 +0530

tanh float16 (#12165)

Co-authored-by: aakaverm 
---
 python/tvm/topi/hexagon/slice_ops/__init__.py  |   1 +
 python/tvm/topi/hexagon/slice_ops/tanh.py  |  56 +++
 .../contrib/test_hexagon/topi/test_tanh_slice.py   | 109 +
 3 files changed, 166 insertions(+)

diff --git a/python/tvm/topi/hexagon/slice_ops/__init__.py 
b/python/tvm/topi/hexagon/slice_ops/__init__.py
index f6c30c2500..c178aeeb0e 100644
--- a/python/tvm/topi/hexagon/slice_ops/__init__.py
+++ b/python/tvm/topi/hexagon/slice_ops/__init__.py
@@ -32,3 +32,4 @@ from .cast import (
 from .conv2d import *
 from .reshape import reshape_compute, reshape_stir_schedule
 from .relu import relu_compute, relu_stir_schedule
+from .tanh import tanh_te_compute, tanhf16_schedule
diff --git a/python/tvm/topi/hexagon/slice_ops/tanh.py 
b/python/tvm/topi/hexagon/slice_ops/tanh.py
new file mode 100644
index 00..3e10ec599c
--- /dev/null
+++ b/python/tvm/topi/hexagon/slice_ops/tanh.py
@@ -0,0 +1,56 @@
+# 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
+
+""" Hexagon tanh slice op compute and schedule """
+import tvm
+from tvm import te, tir
+from ..utils import get_layout_transform_fn
+
+
+def tanh_te_compute(in_tensor):
+out_tensor = te.compute(
+in_tensor.shape, lambda n, h, w, c: tvm.tir.tanh(in_tensor[n, h, w, 
c]), name="tanhf16"
+)
+return out_tensor
+
+
+def tanhf16_stir_sched_nhwc(func, in_layout, out_layout, h_split_factor=8):
+"""Schedule for nhwc fp16 to nchw fp16 layout"""
+sch = tir.Schedule(func, debug_mask="all")
+block_name = "tanhf16"
+n, h, w, c = sch.get_loops(sch.get_block(block_name))
+h_outer, h_inner = sch.split(h, [None, h_split_factor])
+w_outer, w_inner = sch.split(w, [None, 4])
+c_outer, c_inner = sch.split(c, [None, 32])
+w_inner_o, w_inner_i = sch.split(w_inner, [None, 2])
+sch.reorder(n, h_outer, w_outer, c_outer, h_inner, w_inner_o, c_inner, 
w_inner_i)
+sch.transform_layout(block_name, "A", in_layout)
+sch.transform_layout(block_name, block_name, out_layout)
+fused = sch.fuse(c_inner, w_inner_i)
+sch.vectorize(fused)
+return sch
+
+
+def tanhf16_schedule(tanh_func, in_layout_str, out_layout_str):
+in_layout_transform_func = get_layout_transform_fn(in_layout_str)
+out_layout_transform_func = get_layout_transform_fn(out_layout_str)
+return tanhf16_stir_sched_nhwc(
+tanh_func,
+in_layout_transform_func,
+out_layout_transform_func,
+)
diff --git a/tests/python/contrib/test_hexagon/topi/test_tanh_slice.py 
b/tests/python/contrib/test_hexagon/topi/test_tanh_slice.py
new file mode 100644
index 00..b1e85971a2
--- /dev/null
+++ b/tests/python/contrib/test_hexagon/topi/test_tanh_slice.py
@@ -0,0 +1,109 @@
+# 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

[tvm] branch main updated: [hexagon][testing] nonrandom tests (#12164)

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

kparzysz 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 832c7674fe [hexagon][testing] nonrandom tests (#12164)
832c7674fe is described below

commit 832c7674fef385887a2fb99b8530736a40dfc820
Author: Christian Convey 
AuthorDate: Sat Jul 23 12:45:45 2022 -0400

[hexagon][testing] nonrandom tests (#12164)

Add support for populating unit-test input tensors
with values other than random.
---
 tests/python/contrib/test_hexagon/pytest_util.py   | 66 ++
 .../test_hexagon/topi/test_avg_pool2d_slice.py | 30 --
 2 files changed, 92 insertions(+), 4 deletions(-)

diff --git a/tests/python/contrib/test_hexagon/pytest_util.py 
b/tests/python/contrib/test_hexagon/pytest_util.py
index fb28ebeb68..0264fc1bc2 100644
--- a/tests/python/contrib/test_hexagon/pytest_util.py
+++ b/tests/python/contrib/test_hexagon/pytest_util.py
@@ -59,6 +59,22 @@ def get_test_id(*test_params, test_param_descs: 
List[Optional[str]] = None) -> s
 val_str = "F"
 need_prefix_separator = True
 
+elif type(param_val) == TensorContentConstant:
+val_str = f"const({param_val.elem_value})"
+need_prefix_separator = True
+
+elif type(param_val) == TensorContentDtypeMin:
+val_str = "min"
+need_prefix_separator = True
+
+elif type(param_val) == TensorContentDtypeMax:
+val_str = "max"
+need_prefix_separator = True
+
+elif type(param_val) == TensorContentRandom:
+val_str = "random"
+need_prefix_separator = True
+
 else:
 val_str = str(param_val)
 need_prefix_separator = True
@@ -91,3 +107,53 @@ def get_multitest_ids(
 get_test_id(*single_test_param_list, test_param_descs=param_descs)
 for single_test_param_list in multitest_params_list
 ]
+
+
+def get_numpy_dtype_info(np_dtype_name: str) -> Union[np.finfo, np.iinfo]:
+"""
+Return an appropriate 'np.iinfo' or 'np.finfo' object corresponding to
+the specified dtype.
+"""
+np_dtype = np.dtype(np_dtype_name)
+kind = np_dtype.kind
+
+if kind == "f":
+return np.finfo(np_dtype_name)
+elif kind == "i":
+return np.iinfo(np_dtype_name)
+else:
+raise TypeError(
+f"np_dtype_name ({np_dtype_name}) must indicate some 
floating-point or integral data type"
+)
+
+
+TensorContentConstant = collections.namedtuple("TensorContentConstant", 
["elem_value"])
+TensorContentRandom = collections.namedtuple("TensorContentRandom", [])
+TensorContentDtypeMin = collections.namedtuple("TensorContentDtypeMin", [])
+TensorContentDtypeMax = collections.namedtuple("TensorContentDtypeMax", [])
+
+
+def create_populated_numpy_ndarray(
+input_shape: Union[list, tuple], dtype: str, input_tensor_populator
+) -> np.ndarray:
+"""
+Create a numpy tensor with the specified shape, dtype, and content.
+"""
+itp = input_tensor_populator  # just for brevity
+
+if type(itp) == TensorContentConstant:
+return np.full(tuple(input_shape), itp.elem_value, dtype=dtype)
+
+elif type(itp) == TensorContentDtypeMin:
+info = get_numpy_dtype_info(dtype)
+return np.full(tuple(input_shape), info.min, dtype=dtype)
+
+elif type(itp) == TensorContentDtypeMax:
+info = get_numpy_dtype_info(dtype)
+return np.full(tuple(input_shape), info.max, dtype=dtype)
+
+elif type(itp) == TensorContentRandom:
+return np.random.random(input_shape).astype(dtype)
+
+else:
+raise ValueError(f"Unexpected input_tensor_populator type: 
{type(itp)}")
diff --git a/tests/python/contrib/test_hexagon/topi/test_avg_pool2d_slice.py 
b/tests/python/contrib/test_hexagon/topi/test_avg_pool2d_slice.py
index 34e9b751b9..af60e0f2e0 100644
--- a/tests/python/contrib/test_hexagon/topi/test_avg_pool2d_slice.py
+++ b/tests/python/contrib/test_hexagon/topi/test_avg_pool2d_slice.py
@@ -18,7 +18,6 @@
 import pytest
 import numpy as np
 from typing import *
-import collections
 
 from tvm import te
 import tvm.testing
@@ -27,7 +26,14 @@ from tvm.contrib.hexagon.build import HexagonLauncher
 from tvm.contrib.hexagon.session import Session
 import tvm.topi.hexagon.slice_ops as sl
 from ..infrastructure import allocate_hexagon_array, transform_numpy
-from ..pytest_util import get_multitest_ids
+from ..pytest_util import (
+get_multitest_ids,
+create_populated_numpy_ndarray,
+TensorContentConstant,
+TensorContentRandom,
+TensorContentDtypeMin,
+TensorContentDtypeMax,
+)
 
 
 

[tvm] branch main updated: [hexagon][testing] Better pytest ID strings (#12154)

2022-07-22 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 9863cf0d5f [hexagon][testing] Better pytest ID strings (#12154)
9863cf0d5f is described below

commit 9863cf0d5f49e54c21d1a1243d87fd01f7277911
Author: Christian Convey 
AuthorDate: Fri Jul 22 15:52:56 2022 -0400

[hexagon][testing] Better pytest ID strings (#12154)

- Add utility functions to allow more human-readable pytest test IDs.
  Helpful when ID strings become too large for humans to easily read.

- Update the `test_avg_pool2d_slice.py` unit test to use this mechanism.
---
 tests/python/contrib/test_hexagon/pytest_util.py   | 93 ++
 .../test_hexagon/topi/test_avg_pool2d_slice.py | 45 ---
 2 files changed, 125 insertions(+), 13 deletions(-)

diff --git a/tests/python/contrib/test_hexagon/pytest_util.py 
b/tests/python/contrib/test_hexagon/pytest_util.py
new file mode 100644
index 00..fb28ebeb68
--- /dev/null
+++ b/tests/python/contrib/test_hexagon/pytest_util.py
@@ -0,0 +1,93 @@
+# 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.
+
+import pytest
+import numpy as np
+from typing import *
+import collections
+import tvm.testing
+
+
+def get_test_id(*test_params, test_param_descs: List[Optional[str]] = None) -> 
str:
+"""
+An opinionated alternative to pytest's default algorithm for generating a
+test's ID string.  Intended to make it easier for human readers to
+interpret the test IDs.
+
+'test_params': The sequence of pytest parameter values supplied to some 
unit
+   test.
+
+'test_param_descs': An (optional) means to provide additional text for 
some/all of the
+   paramuments in 'test_params'.
+
+   If provided, then len(test_params) must equal len(test_param_descs).
+   Each element test_param_descs that is a non-empty string will be used
+   in some sensible way in this function's returned string.
+"""
+
+assert len(test_params) > 0
+
+if test_param_descs is None:
+test_param_descs = [None] * len(test_params)
+else:
+assert len(test_param_descs) == len(test_params)
+
+def get_single_param_chunk(param_val, param_desc: Optional[str]):
+if type(param_val) == list:
+# Like str(list), but avoid the whitespace padding.
+val_str = "[" + ",".join(str(x) for x in param_val) + "]"
+need_prefix_separator = False
+
+elif type(param_val) == bool:
+if param_val:
+val_str = "T"
+else:
+val_str = "F"
+need_prefix_separator = True
+
+else:
+val_str = str(param_val)
+need_prefix_separator = True
+
+if param_desc and need_prefix_separator:
+return f"{param_desc}:{val_str}"
+elif param_desc and not need_prefix_separator:
+return f"{param_desc}{val_str}"
+else:
+return val_str
+
+chunks = [
+get_single_param_chunk(param_val, param_desc)
+for param_val, param_desc in zip(test_params, test_param_descs)
+]
+return "-".join(chunks)
+
+
+def get_multitest_ids(
+multitest_params_list: List[List], param_descs: 
Optional[List[Optional[str]]]
+) -> List[str]:
+"""
+A convenience function for classes that use both 'tvm.testing.parameters' 
and 'get_test_id'.
+
+This function provides a workaround for a specific quirk in Python, where 
list-comprehension
+can't necessarily access the value of another class-variable, discused 
here:
+https://stackoverflow.com/q/13905741
+"""
+return [
+get_test_id(*single_test_param_list, test_param_descs=param_descs)
+for single_test_param_list in multitest_params_list
+]
diff --git a/tests/python/contrib/test_hexagon/topi/test_avg_pool2d_slice.py 
b/tests/python/contrib/test_hexagon/topi/test_avg_pool2d_slice.py
index 

[tvm] branch main updated: [HEXAGON] QCOM hexagon library (qhl) (#12149)

2022-07-22 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 a07e18ea4e [HEXAGON] QCOM hexagon library (qhl) (#12149)
a07e18ea4e is described below

commit a07e18ea4ee063f98bc97412b40c488e13110856
Author: Aakanksha Verma <89928182+avquic...@users.noreply.github.com>
AuthorDate: Fri Jul 22 22:29:57 2022 +0530

[HEXAGON] QCOM hexagon library (qhl) (#12149)

* qcom hexagon library (qhl)

* fix lint errors

* fix lint errors

Co-authored-by: aakaverm 
---
 apps/hexagon_api/CMakeLists.txt|   1 +
 cmake/config.cmake |   3 +
 cmake/modules/Hexagon.cmake|  28 -
 src/runtime/hexagon/qhl/qhl_wrapper.cc |  89 +++
 src/target/llvm/codegen_hexagon.cc |  59 ++
 src/target/llvm/intrin_rule_hexagon.cc | 171 ++---
 tests/scripts/task_config_build_hexagon.sh |   1 +
 7 files changed, 332 insertions(+), 20 deletions(-)

diff --git a/apps/hexagon_api/CMakeLists.txt b/apps/hexagon_api/CMakeLists.txt
index 82c4b5b66d..5234be3c1a 100644
--- a/apps/hexagon_api/CMakeLists.txt
+++ b/apps/hexagon_api/CMakeLists.txt
@@ -131,6 +131,7 @@ ExternalProject_Add(hexagon_tvm_runtime_rpc
 "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
 "-DUSE_ALTERNATIVE_LINKER=OFF"
 "-DUSE_CUSTOM_LOGGING=ON"
+"-DUSE_HEXAGON_QHL=ON"
 "${GTEST_FLAG}"
   INSTALL_COMMAND ""
   BUILD_ALWAYS ON
diff --git a/cmake/config.cmake b/cmake/config.cmake
index b9a3aaef7d..4cd10f104a 100644
--- a/cmake/config.cmake
+++ b/cmake/config.cmake
@@ -322,6 +322,9 @@ set(USE_HEXAGON_RPC OFF)
 # Valid values are v65, v66, v68, v69.
 set(USE_HEXAGON_ARCH "v66")
 
+# Whether to use QHL library
+set(USE_HEXAGON_QHL OFF)
+
 # Whether to use ONNX codegen
 set(USE_TARGET_ONNX OFF)
 
diff --git a/cmake/modules/Hexagon.cmake b/cmake/modules/Hexagon.cmake
index 6e9b7dc70c..c08ea5eb1d 100644
--- a/cmake/modules/Hexagon.cmake
+++ b/cmake/modules/Hexagon.cmake
@@ -89,6 +89,10 @@ endif()
 
 # From here on, USE_HEXAGON is assumed to be TRUE.
 
+if(BUILD_FOR_HOST AND USE_HEXAGON_QHL)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_QHL")
+endif()
+
 function(add_android_paths)
   get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
 SDK_INCLUDE SDK_INCLUDE_DIRS
@@ -148,8 +152,27 @@ if(BUILD_FOR_HEXAGON)
   include_directories(SYSTEM ${SDK_INCLUDE_DIRS} ${QURT_INCLUDE_DIRS})
 
   set(USE_CUSTOM_LOGGING ON) # To use a custom logger
-endif()
 
+# QHL support.
+  if(USE_HEXAGON_QHL)
+file_glob_append(TVM_QHL_WRAPPER_SRCS
+  "${TVMRT_SOURCE_DIR}/hexagon/qhl/*.cc"
+)
+
+include_directories(
+  "${USE_HEXAGON_SDK}/libs/qhl_hvx/inc/qhmath_hvx"
+  "${USE_HEXAGON_SDK}/libs/qhl_hvx/inc/internal/"
+
+  "${USE_HEXAGON_SDK}/libs/qhl/inc/qhmath"
+  "${USE_HEXAGON_SDK}/libs/qhl/src/internal/"
+  )
+set_property(SOURCE ${TVM_QHL_WRAPPER_SRCS} APPEND_STRING  PROPERTY 
COMPILE_FLAGS "-Wno-narrowing -mhvx -mhvx-length=128B")
+
+list(APPEND TVM_RUNTIME_LINKER_LIBS -Wl,--whole-archive 
${USE_HEXAGON_SDK}/libs/qhl_hvx/prebuilt/hexagon_toolv84_v68/libqhmath_hvx.a 
-Wl,--no-whole-archive)
+list(APPEND TVM_RUNTIME_LINKER_LIBS -Wl,--whole-archive 
${USE_HEXAGON_SDK}/libs/qhl/prebuilt/hexagon_toolv84_v68/libqhmath.a 
-Wl,--no-whole-archive)
+
+  endif()
+endif()
 
 if(USE_HEXAGON_RPC)
   function(build_rpc_idl)
@@ -238,5 +261,4 @@ if(USE_HEXAGON_RPC)
   endif()
 endif()   # USE_HEXAGON_RPC
 
-
-list(APPEND RUNTIME_SRCS ${RUNTIME_HEXAGON_SRCS})
+list(APPEND RUNTIME_SRCS ${RUNTIME_HEXAGON_SRCS} ${TVM_QHL_WRAPPER_SRCS})
diff --git a/src/runtime/hexagon/qhl/qhl_wrapper.cc 
b/src/runtime/hexagon/qhl/qhl_wrapper.cc
new file mode 100644
index 00..df188c8907
--- /dev/null
+++ b/src/runtime/hexagon/qhl/qhl_wrapper.cc
@@ -0,0 +1,89 @@
+/*
+ * 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

[tvm] branch main updated: Revert "support overlapped itersum (#12039)" (#12137)

2022-07-19 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 eb7cf7051d Revert "support overlapped itersum (#12039)" (#12137)
eb7cf7051d is described below

commit eb7cf7051dd239ef86db13875687ef6d5ebb9418
Author: Florin Blanaru 
AuthorDate: Wed Jul 20 00:36:38 2022 +0100

Revert "support overlapped itersum (#12039)" (#12137)

This reverts commit 3e7a2ad9568a79fb775c0ca9d09a3fa2f51f792f.
---
 src/arith/iter_affine_map.cc   | 91 ++
 tests/python/unittest/test_arith_intset.py |  7 +-
 .../python/unittest/test_arith_iter_affine_map.py  | 58 +-
 .../unittest/test_meta_schedule_space_cpu.py   | 26 +++
 .../unittest/test_meta_schedule_space_cuda.py  | 12 +--
 tests/python/unittest/test_tir_schedule_reorder.py | 30 +--
 .../unittest/test_tir_schedule_split_fuse.py   |  8 +-
 .../test_tir_schedule_state_cached_flags.py|  2 +-
 8 files changed, 58 insertions(+), 176 deletions(-)

diff --git a/src/arith/iter_affine_map.cc b/src/arith/iter_affine_map.cc
index 83e2821c98..d2aa16ded1 100644
--- a/src/arith/iter_affine_map.cc
+++ b/src/arith/iter_affine_map.cc
@@ -177,12 +177,8 @@ class IterMapRewriter : public ExprMutator {
   using Parent = ExprMutator;
 
   explicit IterMapRewriter(Analyzer* analyzer, const Map& 
input_iters,
-   IterMapLevel check_level, bool 
simplify_trivial_iterators,
-   Array* errors)
-  : analyzer_(analyzer),
-check_level_(check_level),
-errors_(*errors),
-padding_predicate_(const_false()) {
+   bool simplify_trivial_iterators, Array* 
errors)
+  : analyzer_(analyzer), errors_(*errors), 
padding_predicate_(const_false()) {
 for (auto kv : input_iters) {
   const Var& var = kv.first;
   const Range& vrng = kv.second;
@@ -423,8 +419,6 @@ class IterMapRewriter : public ExprMutator {
 
   // Internal analyzer
   Analyzer* analyzer_;
-  // Iter map check level
-  IterMapLevel check_level_;
   // Error messages for each unresolved expression.
   Array& errors_;
   // The var map
@@ -657,7 +651,7 @@ class IterMapRewriter : public ExprMutator {
   if (predicate_induced_max.defined())
 predicate_induced_max = predicate_induced_max.value() - base;
 }
-Optional opt = TryFuseIters(expr, check_level_);
+Optional opt = TryFuseIters(expr);
 ICHECK(!opt.defined() || opt.value()->args.size() == 1);
 // scale should be 1
 if (opt.defined() && is_one(opt.value()->args[0]->scale)) {
@@ -708,7 +702,7 @@ class IterMapRewriter : public ExprMutator {
   IterSumExpr NormalizeToIterWithOffset(IterSumExpr expr) {
 // We are normalizing a regular iter
 if (expr->args.size() < 1) return expr;
-Optional opt = TryFuseIters(expr, check_level_);
+Optional opt = TryFuseIters(expr);
 if (opt.defined()) {
   return opt.value();
 } else {
@@ -741,10 +735,9 @@ class IterMapRewriter : public ExprMutator {
*return a corresponding IterSumExpr with extra offset if needed.
*Try to normalize IterSum into a fused IterMark
* \param expr The input sum.
-   * \param check_level The check level if iter mapping.
* \return The sum with the fused IterMark and extra offset if succeed.
*/
-  Optional TryFuseIters(IterSumExpr expr, IterMapLevel 
check_level) {
+  Optional TryFuseIters(IterSumExpr expr) {
 // select the iterators in order
 std::vector visited(expr->args.size(), false);
 std::vector flattened_iters, grouped_iters;
@@ -765,42 +758,14 @@ class IterMapRewriter : public ExprMutator {
 }
 // check if it can be remapped into a fused pattern.
 PrimExpr expected_extra_base = 0;
-PrimExpr tail_extent = 0;
 PrimExpr expected_scale = base_scale.value();
 for (size_t i = 0; i < expr->args.size();) {
-  // find position such that expr->args[j] match expected scale
-  int j = i == 0 ? base_index : expr->args.size() - 1;
-
-  size_t matched_pos = expr->args.size();
-  PrimExpr matched_scale{nullptr};
-  bool is_exact_match{false};
-
-  for (; j >= 0; --j) {
-if (visited[j]) {
-  continue;
-}
-const PrimExpr& cur_scale = expr->args[j]->scale;
-
-// for bijective mapping, the matched scale must equal to expected 
scale
-if (analyzer_->CanProveEqual(cur_scale, expected_scale)) {
-  matched_pos = j;
-  matched_scale = cur_scale;
-  is_exact_match = true;
-  break;
-}
-if (check_level != IterMapLevel::Bijective && 
base_scale.value()->value == 1) {
-  // find the closest scale which is less

[tvm] branch main updated (342fbea84e -> 7bf5fa449c)

2022-07-19 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 342fbea84e [CMSIS-NN] Fix typo in EmitPool2D (#11702)
 add 7bf5fa449c [Target] Add "features" property to Target (#12121)

No new revisions were added by this update.

Summary of changes:
 include/tvm/target/target.h | 40 +
 python/tvm/_ffi/runtime_ctypes.py   |  1 +
 python/tvm/target/target.py | 12 +
 src/target/target.cc| 11 
 src/target/target_kind.cc   | 14 ++
 tests/cpp/target_test.cc| 22 +++-
 tests/python/unittest/test_target_target.py | 10 
 7 files changed, 109 insertions(+), 1 deletion(-)



[tvm] branch main updated: [Target] Add target_parser to TargetKind (#12119)

2022-07-18 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 d4309cf810 [Target] Add target_parser to TargetKind (#12119)
d4309cf810 is described below

commit d4309cf81003c5fdeeb75583ac96cc0926a22b25
Author: Christopher Sidebottom 
AuthorDate: Mon Jul 18 20:37:20 2022 +0100

[Target] Add target_parser to TargetKind (#12119)

This adds the `target_parser` as described in 
https://github.com/apache/tvm-rfcs/pull/71, which parses an incoming 
`TargetJSON` and produces a new configuration for generating the final `Target` 
object from.

Marks `set_attrs_preprocessor` as deprecated and errors if both 
`set_attrs_preprocessor` and `set_target_parser` exist together.
---
 docs/arch/device_target_interactions.rst |  4 +--
 include/tvm/target/target_kind.h | 23 ++
 src/target/target.cc | 17 +--
 src/target/target_kind.cc| 52 
 tests/cpp/target_test.cc | 47 +
 5 files changed, 112 insertions(+), 31 deletions(-)

diff --git a/docs/arch/device_target_interactions.rst 
b/docs/arch/device_target_interactions.rst
index 9c391d31be..ec8d52226e 100644
--- a/docs/arch/device_target_interactions.rst
+++ b/docs/arch/device_target_interactions.rst
@@ -194,8 +194,8 @@ different code generation targets can run on the same 
physical device.
 device type.)
 
 All options for a specific target kind are added with the
-``add_attr_option`` function, with optional default values.  A
-preprocessor can be added with ``set_attrs_preprocessor`` to define
+``add_attr_option`` function, with optional default values.  A `Target`
+parser can be added with ``set_target_parser`` to process
 any parameters that are dynamically based on other parameters or
 queried from device properties.
 
diff --git a/include/tvm/target/target_kind.h b/include/tvm/target/target_kind.h
index 4879470e76..e20f8547af 100644
--- a/include/tvm/target/target_kind.h
+++ b/include/tvm/target/target_kind.h
@@ -37,6 +37,16 @@ namespace tvm {
 
 class Target;
 
+/*!
+ * \brief TargetParser to apply on instantiation of a given TargetKind
+ *
+ * \param target_json Target in JSON format to be transformed during parsing.
+ *
+ * \return The transformed Target JSON object.
+ */
+using TargetJSON = Map;
+using FTVMTargetParser = TypedPackedFunc;
+
 /*!
  * \brief RelayToTIR tvm::transform::Pass specific to a TargetKind
  *
@@ -82,6 +92,8 @@ class TargetKindNode : public Object {
   Array default_keys;
   /*! \brief Function used to preprocess on target creation */
   PackedFunc preprocessor;
+  /*! \brief Function used to parse a JSON target during creation */
+  FTVMTargetParser target_parser;
 
   void VisitAttrs(AttrVisitor* v) {
 v->Visit("name", );
@@ -207,6 +219,11 @@ class TargetKindRegEntry {
*/
   template 
   inline TargetKindRegEntry& set_attrs_preprocessor(FLambda f);
+  /*!
+   * \brief Set the parsing function applied upon target creation
+   * \param parser The Target parsing function
+   */
+  inline TargetKindRegEntry& set_target_parser(FTVMTargetParser parser);
   /*!
* \brief Register a valid configuration option and its ValueType for 
validation
* \param key The configuration key
@@ -353,11 +370,17 @@ inline TargetKindRegEntry& 
TargetKindRegEntry::set_default_keys(std::vector
 inline TargetKindRegEntry& TargetKindRegEntry::set_attrs_preprocessor(FLambda 
f) {
+  LOG(WARNING) << "set_attrs_preprocessor is deprecated please use 
set_target_parser instead";
   using FType = typename 
tvm::runtime::detail::function_signature::FType;
   kind_->preprocessor = 
tvm::runtime::TypedPackedFunc(std::move(f)).packed();
   return *this;
 }
 
+inline TargetKindRegEntry& 
TargetKindRegEntry::set_target_parser(FTVMTargetParser parser) {
+  kind_->target_parser = parser;
+  return *this;
+}
+
 template 
 inline TargetKindRegEntry& TargetKindRegEntry::add_attr_option(const String& 
key) {
   ICHECK(!kind_->key2vtype_.count(key))
diff --git a/src/target/target.cc b/src/target/target.cc
index 01f9bfaeec..207a399a77 100644
--- a/src/target/target.cc
+++ b/src/target/target.cc
@@ -52,7 +52,7 @@ class TargetInternal {
   static ObjectPtr FromString(const String& 
tag_or_config_or_target_str);
   static ObjectPtr FromConfigString(const String& config_str);
   static ObjectPtr FromRawString(const String& target_str);
-  static ObjectPtr FromConfig(std::unordered_map 
config);
+  static ObjectPtr FromConfig(Map config);
   static void ConstructorDispatcher(TVMArgs args, TVMRetValue* rv);
   static Target WithHost(const Target& target, const Target& target_host) {
 ObjectPtr n = make_object(*target.get());
@@ -716,17 +716,27 @@ ObjectP

[tvm] branch main updated: [TIR][BugFix] Fix a wrong use of T.exp in test_compute_inline_opaque_access_with_tvm_access_ptr. (#12117)

2022-07-16 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 b84ed27260 [TIR][BugFix] Fix a wrong use of T.exp in 
test_compute_inline_opaque_access_with_tvm_access_ptr. (#12117)
b84ed27260 is described below

commit b84ed27260d492e954963448e6cc8aee329b4cc6
Author: albert qing <2628...@qq.com>
AuthorDate: Sun Jul 17 06:11:02 2022 +0800

[TIR][BugFix] Fix a wrong use of T.exp in 
test_compute_inline_opaque_access_with_tvm_access_ptr. (#12117)

Co-authored-by: sqing 
---
 tests/python/unittest/test_tir_schedule_compute_inline.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/python/unittest/test_tir_schedule_compute_inline.py 
b/tests/python/unittest/test_tir_schedule_compute_inline.py
index 617e13db27..ec19402969 100644
--- a/tests/python/unittest/test_tir_schedule_compute_inline.py
+++ b/tests/python/unittest/test_tir_schedule_compute_inline.py
@@ -556,11 +556,11 @@ def exp_exp_opaque_access_with_tvm_access_ptr(
 for i0 in T.serial(16):
 with T.block("compute_1"):
 i0_2 = T.axis.spatial(16, i0)
-T.reads(compute_1[i0_2], lookup_table[0:1024])
+T.reads(lookup_table[0:1024], compute_1[i0_2])
 T.writes(compute[i0_2])
+T.evaluate(lookup_table.access_ptr("r"))
 compute[i0_2] = T.exp(
 compute_1[i0_2],
-lookup_table.access_ptr("r"),
 dtype="float16",
 )
 
@@ -576,11 +576,11 @@ def exp_exp_opaque_access_with_tvm_access_ptr_inlined(
 i0_1 = T.axis.spatial(16, i0)
 # Do not put the opaque access to new write region when opaque 
access
 # wrapped with a tvm_access_ptr and the access mask set to "read 
only"
-T.reads(x[i0_1], lookup_table[0:1024])
+T.reads(lookup_table[0:1024], x[i0_1])
 T.writes(compute[i0_1])
+T.evaluate(lookup_table.access_ptr("r"))
 compute[i0_1] = T.exp(
 T.exp(x[i0_1], dtype="float16"),
-lookup_table.access_ptr("r"),
 dtype="float16",
 )
 



[tvm] branch main updated: fix typo (#12115)

2022-07-16 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 c54eea7d0a fix typo (#12115)
c54eea7d0a is described below

commit c54eea7d0a9890c25eae15df1a0c47b263b27a07
Author: Job Henandez Lara 
AuthorDate: Sat Jul 16 10:08:56 2022 -0700

fix typo (#12115)
---
 tests/python/frontend/keras/test_forward.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/python/frontend/keras/test_forward.py 
b/tests/python/frontend/keras/test_forward.py
index 025af29ba4..ff9e20cff2 100644
--- a/tests/python/frontend/keras/test_forward.py
+++ b/tests/python/frontend/keras/test_forward.py
@@ -45,7 +45,7 @@ else:
 
 def pytest_generate_tests(metafunc):
 # This function generates the list of tests for pytest, based
-# on scenatios that will change the parameters in which the
+# on scenarios that will change the parameters in which the
 # tests use to run.
 # https://docs.pytest.org/en/latest/example/parametrize.html
 idlist = []



[tvm] branch main updated: [TOPI] [Hexagon] Uint8 Reshape and batch flatten slice ops (#12037)

2022-07-16 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 c0e996e291 [TOPI] [Hexagon] Uint8 Reshape and batch flatten slice ops 
(#12037)
c0e996e291 is described below

commit c0e996e2914585fe6b0c11fb2efdaea5c6b9daf9
Author: abhikran-quic <63697863+abhikran-q...@users.noreply.github.com>
AuthorDate: Sat Jul 16 20:40:39 2022 +0530

[TOPI] [Hexagon] Uint8 Reshape and batch flatten slice ops (#12037)

* [TOPI] [Hexagon] Uint8 Reshape and batch flatten slice ops

* Fix documentation
---
 python/tvm/topi/hexagon/slice_ops/reshape.py   | 13 +++---
 python/tvm/topi/hexagon/utils.py   | 21 ++
 .../python/contrib/test_hexagon/infrastructure.py  | 12 +-
 .../contrib/test_hexagon/topi/test_reshape.py  | 47 +++---
 4 files changed, 72 insertions(+), 21 deletions(-)

diff --git a/python/tvm/topi/hexagon/slice_ops/reshape.py 
b/python/tvm/topi/hexagon/slice_ops/reshape.py
index 374c20bb72..2220253e21 100644
--- a/python/tvm/topi/hexagon/slice_ops/reshape.py
+++ b/python/tvm/topi/hexagon/slice_ops/reshape.py
@@ -40,13 +40,14 @@ def reshape_compute(inp: te.Tensor, new_shape: tuple) -> 
te.Tensor:
 return topi.transform.reshape(inp, new_shape)
 
 
-def stir_schedule_nhwc_1024c(
+def stir_sched_nhwc_2d_op(
 out: te.Tensor,
 inp: te.Tensor,
 out_layout: str,
 in_layout: str,
+c_split: int,
 ) -> tir.Schedule:
-"""Schedule for output layout: nhwc-1024c-2d"""
+"""Schedule for output layout: nc-1024-2d, nc-2048-2d"""
 reshape_func = te.create_prim_func([inp, out])
 sch = tir.Schedule(reshape_func, debug_mask="all")
 compute = sch.get_block("T_reshape")
@@ -57,7 +58,7 @@ def stir_schedule_nhwc_1024c(
 jout, channel = sch.split(j, [None, inp.shape[3]])
 height, width = sch.split(jout, [inp.shape[1], inp.shape[2]])
 channelo, channeli = sch.split(channel, [None, 1024])
-channelio, channelii = sch.split(channeli, [None, 64])
+channelio, channelii = sch.split(channeli, [None, c_split])
 sch.reorder(i, height, width, channelo, channelio, channelii)
 sch.vectorize(channelii)
 return sch
@@ -101,8 +102,10 @@ def reshape_stir_schedule(
 sch : tvm.tir.Schedule
 The STIR schedule for slice reshape compute
 """
-if output_layout == "nhwc-8h2w32c2w-2d":
+if output_layout in ["nhwc-8h2w32c2w-2d", "nhwc-8h8w32c-2d"]:
 return stir_schedule_nhwc_8h2w32c2w(out, inp, output_layout, 
input_layout)
 if output_layout == "nc-1024-2d":
-return stir_schedule_nhwc_1024c(out, inp, output_layout, input_layout)
+return stir_sched_nhwc_2d_op(out, inp, output_layout, input_layout, 64)
+if output_layout == "nc-2048-2d":
+return stir_sched_nhwc_2d_op(out, inp, output_layout, input_layout, 
128)
 raise RuntimeError(f"Unexpected layout '{output_layout}'")
diff --git a/python/tvm/topi/hexagon/utils.py b/python/tvm/topi/hexagon/utils.py
index 4458c55e62..3b8914ffe9 100644
--- a/python/tvm/topi/hexagon/utils.py
+++ b/python/tvm/topi/hexagon/utils.py
@@ -87,6 +87,21 @@ def nc_1024_2d(n, c):
 return [n, c // 1024, te.AXIS_SEPARATOR, c % 1024]
 
 
+def nhwc_2048c_2d(n, h, w, c):
+"""Return index map for nhwc_2048 2d layout"""
+return [n, h, w, c // 2048, te.AXIS_SEPARATOR, c % 2048]
+
+
+def nc_2048_2d(n, c):
+"""Return index map for nc_2048 2d layout"""
+return [n, c // 2048, te.AXIS_SEPARATOR, c % 2048]
+
+
+def nhwc_8h8w32c_2d(n, h, w, c):
+"""Return index map for nhwc_8h8w32c 2d layout"""
+return [n, h // 8, w // 8, c // 32, te.AXIS_SEPARATOR, h % 8, w % 8, c % 
32]
+
+
 def iohw_16i32o2i_1d(height, width, in_channel, out_channel):
 return [
 in_channel // 32,
@@ -129,4 +144,10 @@ def get_layout_transform_fn(layout):
 return nc_1024c_2d
 if layout == "iohw-16i32o2i-1d":
 return iohw_16i32o2i_1d
+if layout == "nhwc-2048c-2d":
+return nhwc_2048c_2d
+if layout == "nc-2048-2d":
+return nc_2048_2d
+if layout == "nhwc-8h8w32c-2d":
+return nhwc_8h8w32c_2d
 raise RuntimeError(f"Unexpected layout '{layout}'")
diff --git a/tests/python/contrib/test_hexagon/infrastructure.py 
b/tests/python/contrib/test_hexagon/infrastructure.py
index a1fbfdefcd..7108ac5598 100644
--- a/tests/python/contrib/test_hexagon/infrastructure.py
+++ b/tests/python/contrib/test_hexagon/infrastructure.py
@@ -256,7 +256,17 @@ def transform_numpy(arr_np, current_layout: str, 
new_layout: str):

[tvm] branch main updated: Add member object accessors to With<> (#12100)

2022-07-15 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 770738c514 Add member object accessors to With<> (#12100)
770738c514 is described below

commit 770738c51442579b0f56eb6c6d341ec73fa33e7f
Author: Krzysztof Parzyszek 
AuthorDate: Fri Jul 15 11:51:05 2022 -0500

Add member object accessors to With<> (#12100)

* Add member object accessors to With<>

Currently the With<> template constructs an object, but gives no access
to it, so it's only applicable to situations where we rely on the side-
effects of creating the object.

* Restart CI
---
 include/tvm/support/with.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/include/tvm/support/with.h b/include/tvm/support/with.h
index d4547a304e..3651e05e74 100644
--- a/include/tvm/support/with.h
+++ b/include/tvm/support/with.h
@@ -67,6 +67,14 @@ class With {
   /*! \brief destructor, leaves the scope of the context. */
   ~With() DMLC_THROW_EXCEPTION { ctx_.ExitWithScope(); }
 
+  ContextType* get() { return _; }
+  const ContextType* get() const { return _; }
+
+  ContextType* operator->() { return get(); }
+  const ContextType* operator->() const { return get(); }
+  ContextType& operator*() { return *get(); }
+  const ContextType* operator*() const { return *get(); }
+
  private:
   /*! \brief internal context type. */
   ContextType ctx_;



[tvm] branch main updated: fold const or empty iter partition (#12080)

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

kparzysz 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 6a6093bc18 fold const or empty iter partition (#12080)
6a6093bc18 is described below

commit 6a6093bc180ed762b3e0d19eb37fcf10d97289c1
Author: wrongtest 
AuthorDate: Wed Jul 13 22:52:35 2022 +0800

fold const or empty iter partition (#12080)
---
 src/tir/transforms/loop_partition.cc | 30 --
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/tir/transforms/loop_partition.cc 
b/src/tir/transforms/loop_partition.cc
index 59ac339006..677506889e 100644
--- a/src/tir/transforms/loop_partition.cc
+++ b/src/tir/transforms/loop_partition.cc
@@ -587,16 +587,17 @@ Stmt LoopPartitioner::TryPartition(const Stmt& stmt, Var 
var, PrimExpr min, Prim
   if (middle_interval_i->HasLowerBound()) {
 body_begin = analyzer_.Simplify(middle_interval.min());
 if (!analyzer_.CanProve(body_begin == min)) {
-  PrimExpr cond = (body_begin - min >= 0);
-  if (!analyzer_.CanProve(cond)) {
-LOG(WARNING) << "Cannot prove: " << cond << ", when generating the pre 
doubt loop";
-body_begin = Max(body_begin, min);
+  PrimExpr extent = analyzer_.Simplify(body_begin - min);
+  if (!analyzer_.CanProve(extent > 0)) {
+body_begin = tvm::max(body_begin, min);
 // stop recursing on this interval if we can't prove it has 
non-negative length
 pre_stmt_recurse = false;
   }
-  if (!partition_thread_scope) {
-Stmt pre_body = Substitute(body, {{Var{var}, var + min}});
-pre_stmt = MakeFor(stmt.get(), body_begin - min, pre_body);
+  if (!analyzer_.CanProve(extent <= 0)) {
+if (!partition_thread_scope) {
+  Stmt pre_body = Substitute(body, {{Var{var}, var + min}});
+  pre_stmt = MakeFor(stmt.get(), body_begin - min, pre_body);
+}
   }
 }
   } else {
@@ -612,16 +613,17 @@ Stmt LoopPartitioner::TryPartition(const Stmt& stmt, Var 
var, PrimExpr min, Prim
 post_doubt_begin = analyzer_.Simplify(middle_interval.max() + 1);
 if (!analyzer_.CanProve(middle_interval.max() == max)) {
   // require the extent to be non-negative
-  PrimExpr cond = (max - post_doubt_begin + 1 >= 0);
-  if (!analyzer_.CanProve(cond)) {
-LOG(WARNING) << "Cannot prove: " << cond << ", when generating the 
post doubt loop";
-post_doubt_begin = Min(post_doubt_begin, max + 1);
+  PrimExpr extent = analyzer_.Simplify(max - post_doubt_begin + 1);
+  if (!analyzer_.CanProve(extent > 0)) {
+post_doubt_begin = tvm::min(post_doubt_begin, max + 1);
 // stop recursing on this interval if we can't prove it has 
non-negative length
 post_stmt_recurse = false;
   }
-  if (!partition_thread_scope) {
-Stmt post_body = Substitute(body, {{Var{var}, var + 
post_doubt_begin}});
-post_stmt = MakeFor(stmt.get(), max - post_doubt_begin + 1, post_body);
+  if (!analyzer_.CanProve(extent <= 0)) {
+if (!partition_thread_scope) {
+  Stmt post_body = Substitute(body, {{Var{var}, var + 
post_doubt_begin}});
+  post_stmt = MakeFor(stmt.get(), extent, post_body);
+}
   }
 }
   } else {



[tvm] branch main updated (5be8e0a3de -> ae72e7e653)

2022-07-11 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 5be8e0a3de [Collage] SubGraphs (#11981)
 add ae72e7e653 Fix node.func to node.funcs on parser.py (#12053)

No new revisions were added by this update.

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



[tvm] branch main updated: [Fix] fix python setup.py file bug (#12000)

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

kparzysz 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 af4373f2fb [Fix] fix python setup.py file bug (#12000)
af4373f2fb is described below

commit af4373f2fbb6afa6827f7e3e4964bad644644d39
Author: Zhengqiang Yin 
AuthorDate: Fri Jul 8 03:38:27 2022 +0800

[Fix] fix python setup.py file bug (#12000)

* fix setup.py bug

Signed-off-by: Zhengqiang Yin 

* remove data_files field

* keep a init setup_kwargs
---
 python/setup.py | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/python/setup.py b/python/setup.py
index 87f533a329..a7ba115e0a 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -164,18 +164,8 @@ class BinaryDistribution(Distribution):
 return False
 
 
-include_libs = False
-wheel_include_libs = False
-if not CONDA_BUILD:
-if "bdist_wheel" in sys.argv:
-wheel_include_libs = True
-else:
-include_libs = True
-
 setup_kwargs = {}
-
-# For bdist_wheel only
-if wheel_include_libs:
+if not CONDA_BUILD:
 with open("MANIFEST.in", "w") as fo:
 for path in LIB_LIST:
 if os.path.isfile(path):
@@ -190,12 +180,6 @@ if wheel_include_libs:
 
 setup_kwargs = {"include_package_data": True}
 
-if include_libs:
-curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
-for i, path in enumerate(LIB_LIST):
-LIB_LIST[i] = os.path.relpath(path, curr_path)
-setup_kwargs = {"include_package_data": True, "data_files": [("tvm", 
LIB_LIST)]}
-
 
 def get_package_data_files():
 # Relay standard libraries
@@ -253,7 +237,7 @@ setup(
 )
 
 
-if wheel_include_libs:
+if not CONDA_BUILD:
 # Wheel cleanup
 os.remove("MANIFEST.in")
 for path in LIB_LIST:



[tvm] branch main updated: [Topi] [Hexagon] Conv2d slice op initial version (#11489)

2022-07-06 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 95f578912f [Topi] [Hexagon] Conv2d slice op initial version (#11489)
95f578912f is described below

commit 95f578912f8e6a6f7199188e52ce98966b919f05
Author: Anirudh Sundar 
AuthorDate: Wed Jul 6 20:22:44 2022 +0530

[Topi] [Hexagon] Conv2d slice op initial version (#11489)
---
 python/tvm/topi/hexagon/slice_ops/__init__.py  |   1 +
 python/tvm/topi/hexagon/slice_ops/conv2d.py| 242 +++
 python/tvm/topi/hexagon/utils.py   |  14 +
 .../contrib/test_hexagon/topi/test_conv2d_slice.py | 339 +
 4 files changed, 596 insertions(+)

diff --git a/python/tvm/topi/hexagon/slice_ops/__init__.py 
b/python/tvm/topi/hexagon/slice_ops/__init__.py
index 5b5c0b8421..ce1641bfda 100755
--- a/python/tvm/topi/hexagon/slice_ops/__init__.py
+++ b/python/tvm/topi/hexagon/slice_ops/__init__.py
@@ -23,3 +23,4 @@ from .argmax import argmax_compute, argmax_schedule
 from .batch_flatten import batch_flatten_compute, batch_flatten_stir_schedule
 from .softmax_slice import *
 from .clip import *
+from .conv2d import *
diff --git a/python/tvm/topi/hexagon/slice_ops/conv2d.py 
b/python/tvm/topi/hexagon/slice_ops/conv2d.py
new file mode 100644
index 00..439fd80648
--- /dev/null
+++ b/python/tvm/topi/hexagon/slice_ops/conv2d.py
@@ -0,0 +1,242 @@
+# 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=line-too-long
+
+"""Hexagon slice conv2d compute and schedule"""
+import typing
+
+import tvm
+from tvm import te
+
+from ..utils import get_layout_transform_fn
+
+
+def conv2d_compute(
+activations: te.Tensor,
+weights: te.Tensor,
+out_shape: typing.Tuple,
+stride: typing.Tuple,
+dilation: typing.Tuple,
+dtype: str,
+output_name: str,
+weights_width_reversed: bool = True,
+) -> te.Tensor:
+"""Compute for slice conv2d op for hexagon.
+
+This op makes the following assumptions:
+1. This op is written for a sliced convolution with 2d physical buffers
+2. The input activations is assumed to be in NHWC layout and filter is in 
HWIO layout
+3. Grouped convolutions are not supported. and there will be a separate 
compute definition for depthwise convolution
+4. In order to get grouped convolutions, it is assumed that the op will be 
sliced according to the groups and multiple calls to this compute would be 
placed.
+
+
+Parameters
+--
+activations : te.Tensor
+Input activations padded for inner dimension size
+weights : te.Tensor
+Weights without dilation
+out_shape : typing.Tuple
+The logical output shape without considering input padding
+stride : typing.Tuple
+stride
+dilation : typing.Tuple
+dilation
+dtype : str
+dtype
+output_name : str
+The name to be given to output. This would become the block name for 
the corresponding STIR compute
+weights_width_reversed : bool
+The width axis of weights are expected in reverse order if 
weights_width_reversed is True
+
+Returns
+---
+output : te.Tensor
+Output of applying 2D convolution of Weights on Input
+"""
+
+filt_shape = weights.shape
+
+reduce_channel = tvm.te.reduce_axis((0, filt_shape[2]), 
name="reduce_channel")
+reduce_height = tvm.te.reduce_axis((0, filt_shape[0]), 
name="reduce_height")
+reduce_width = tvm.te.reduce_axis((0, filt_shape[1]), name="reduce_width")
+stride_height, stride_width = stride
+dilation_height, dilation_width = dilation
+
+if weights_width_reversed:
+weights_width_var = filt_shape[1] - reduce_width - 1
+else:
+weights_width_var = reduce_width
+
+output = tvm.te.compute(
+out_shape,
+lambda n, h, w, c: tvm.te.sum(
+(
+activations[
+n,
+h * strid

[tvm] branch main updated (c97895e0ff -> 50cd4d635c)

2022-07-01 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from c97895e0ff [Hexagon] Fix use of subprocess.run in _check_call_verbose 
(#11985)
 add 50cd4d635c [Hexagon] Enable int8 vlut codegen for Relay take (LUT) 
operator (#11693)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/injective.py |   6 ++
 src/target/llvm/codegen_hexagon.cc   | 147 +++
 2 files changed, 153 insertions(+)



[tvm] branch main updated: [Hexagon] Fix use of subprocess.run in _check_call_verbose (#11985)

2022-07-01 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 c97895e0ff [Hexagon] Fix use of subprocess.run in _check_call_verbose 
(#11985)
c97895e0ff is described below

commit c97895e0ffb512e73c89de7cdee9846f052244fc
Author: Krzysztof Parzyszek 
AuthorDate: Fri Jul 1 14:00:43 2022 -0500

[Hexagon] Fix use of subprocess.run in _check_call_verbose (#11985)

It uses parameters that are not present in Python 3.6, plus it
catches generic exception, which may not have `stdout` or `stderr`
members.
---
 python/tvm/contrib/hexagon/build.py | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/python/tvm/contrib/hexagon/build.py 
b/python/tvm/contrib/hexagon/build.py
index 080b982877..fe7434f738 100644
--- a/python/tvm/contrib/hexagon/build.py
+++ b/python/tvm/contrib/hexagon/build.py
@@ -47,8 +47,15 @@ def _check_call_verbose(cmd, **kwargs) -> None:
 the stdout/stderr provided by the subprocess.
 """
 try:
-subprocess.run(cmd, capture_output=True, check=True, text=True, 
**kwargs)
-except Exception as err:
+subprocess.run(
+cmd,
+check=True,
+encoding="UTF-8",
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+**kwargs,
+)
+except subprocess.CalledProcessError as err:
 error_msg = f"{err}\nstdout:\n{err.stdout}\nstderr:\n{err.stderr}"
 raise Exception(error_msg)
 



[tvm] branch main updated (80a0c6c53d -> 915c23b61b)

2022-06-30 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 80a0c6c53d [microNPU] Fix offloading incompatible average pool (#11469)
 add 915c23b61b [TOPI] [Hexagon] Batch flatten slice op initial version 
(#11522)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/slice_ops/__init__.py  |   1 +
 python/tvm/topi/hexagon/slice_ops/batch_flatten.py |  77 
 python/tvm/topi/hexagon/utils.py   |  14 +++
 .../python/contrib/test_hexagon/infrastructure.py  |   6 ++
 .../test_hexagon/topi/test_batch_flatten.py| 101 +
 5 files changed, 199 insertions(+)
 create mode 100644 python/tvm/topi/hexagon/slice_ops/batch_flatten.py
 create mode 100644 tests/python/contrib/test_hexagon/topi/test_batch_flatten.py



[tvm] branch main updated: Fix clear-stale-images.sh with multiple worktree. (#11921)

2022-06-27 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 ae2de20c15 Fix clear-stale-images.sh with multiple worktree. (#11921)
ae2de20c15 is described below

commit ae2de20c152deb541bb09cef20ceade7d1a1e532
Author: Andrew Reusch 
AuthorDate: Mon Jun 27 16:26:19 2022 -0700

Fix clear-stale-images.sh with multiple worktree. (#11921)

* Process substitution doesn't error out in bash.
---
 docker/clear-stale-images.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/docker/clear-stale-images.sh b/docker/clear-stale-images.sh
index 1e1e4b86a4..1c09870956 100755
--- a/docker/clear-stale-images.sh
+++ b/docker/clear-stale-images.sh
@@ -66,13 +66,15 @@ for r in "${repositories[@]}"; do
 worktree="${r}"
 else
 worktree="$(cat "${r}/.git")"
+worktree="${worktree##gitdir: }"
 fi
+worktree_list=$(cd "${worktree}" && git worktree list --porcelain | grep 
'^worktree ')
 while read wt; do
 d="${wt:9:${#wt}}"  # strip "worktree " prefix
 for img in $(cat "${d}/Jenkinsfile" | grep -E '^ci_[a-z]+ = ' | sed -E 
"s/ci_[a-z]+ = '([^\"]*)'/\1/"); do
 used_images=( "${used_images[@]}" "${img}" )
 done
-done < <(cd "${worktree}" && git worktree list --porcelain | grep 
'^worktree ')
+done < <(echo -n "${worktree_list}")
 done
 
 declare -a to_rm



[tvm] branch main updated: Add missing headers to llvm_module.cc/.h, NFC (#11925)

2022-06-27 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 5f9ff8ad6e Add missing headers to llvm_module.cc/.h, NFC (#11925)
5f9ff8ad6e is described below

commit 5f9ff8ad6e3947f157438e76deef36af02fe00f8
Author: Krzysztof Parzyszek 
AuthorDate: Mon Jun 27 18:23:59 2022 -0500

Add missing headers to llvm_module.cc/.h, NFC (#11925)
---
 src/target/llvm/llvm_module.cc | 19 +++
 src/target/llvm/llvm_module.h  |  7 +--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc
index 8e87229155..861d191050 100644
--- a/src/target/llvm/llvm_module.cc
+++ b/src/target/llvm/llvm_module.cc
@@ -23,6 +23,9 @@
  */
 #ifdef TVM_LLVM_VERSION
 
+#include "llvm_module.h"
+
+#include 
 #include 
 #include 
 #include 
@@ -46,11 +49,24 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
+#include 
+#include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include "../../runtime/file_utils.h"
 #include "../../runtime/library_module.h"
@@ -416,6 +432,7 @@ class LLVMModuleNode final : public runtime::ModuleNode {
 runtime::InitContextFunctions(
 [this](const char* name) { return 
reinterpret_cast(GetGlobalAddr(name)); });
   }
+
   // Get global address from execution engine.
   uint64_t GetGlobalAddr(const std::string& name) const {
 // first verifies if GV exists.
@@ -425,6 +442,7 @@ class LLVMModuleNode final : public runtime::ModuleNode {
   return 0;
 }
   }
+
   uint64_t GetFunctionAddr(const std::string& name) const {
 // first verifies if GV exists.
 if (mptr_->getFunction(name) != nullptr) {
@@ -611,4 +629,5 @@ TVM_REGISTER_GLOBAL("runtime.CreateLLVMCrtMetadataModule")
 
 }  // namespace codegen
 }  // namespace tvm
+
 #endif  // TVM_LLVM_VERSION
diff --git a/src/target/llvm/llvm_module.h b/src/target/llvm/llvm_module.h
index 660d81400b..3a50c2c424 100644
--- a/src/target/llvm/llvm_module.h
+++ b/src/target/llvm/llvm_module.h
@@ -25,11 +25,14 @@
 #ifndef TVM_TARGET_LLVM_LLVM_MODULE_H_
 #define TVM_TARGET_LLVM_LLVM_MODULE_H_
 
+#ifdef TVM_LLVM_VERSION
+
+#include 
+#include 
+#include 
 #include 
 #include 
 
-#ifdef TVM_LLVM_VERSION
-
 namespace tvm {
 namespace codegen {
 



[tvm] branch main updated (9cf5021385 -> cc6a85bb1c)

2022-06-27 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 9cf5021385 [microTVM][zephyr] Increase stack size for zephyr 
host-driven AoT tests (#11777)
 add cc6a85bb1c [HEXAGON] Initial clip operator for Hexagon (#11549)

No new revisions were added by this update.

Summary of changes:
 python/tvm/topi/hexagon/slice_ops/__init__.py  |   1 +
 python/tvm/topi/hexagon/slice_ops/clip.py  |  66 +++
 .../python/contrib/test_hexagon/topi/test_clip.py  | 128 +
 3 files changed, 195 insertions(+)
 mode change 100644 => 100755 python/tvm/topi/hexagon/slice_ops/__init__.py
 create mode 100755 python/tvm/topi/hexagon/slice_ops/clip.py
 create mode 100755 tests/python/contrib/test_hexagon/topi/test_clip.py



[tvm] branch main updated: Delete `from __future__ import annotations` since it requires Python 3.7+ (#11889)

2022-06-24 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 d439f6c4f1 Delete `from __future__ import annotations` since it 
requires Python 3.7+ (#11889)
d439f6c4f1 is described below

commit d439f6c4f18ddabeed487ea8ba253f25dd1e6fb8
Author: Krzysztof Parzyszek 
AuthorDate: Fri Jun 24 16:06:19 2022 -0500

Delete `from __future__ import annotations` since it requires Python 3.7+ 
(#11889)
---
 python/tvm/meta_schedule/profiler.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/python/tvm/meta_schedule/profiler.py 
b/python/tvm/meta_schedule/profiler.py
index a83d0fa16e..206c2429d8 100644
--- a/python/tvm/meta_schedule/profiler.py
+++ b/python/tvm/meta_schedule/profiler.py
@@ -15,7 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 """A context manager that profiles tuning time cost for different parts."""
-from __future__ import annotations
 
 import logging
 from contextlib import contextmanager



[tvm] branch main updated (8c3d922b7e -> ed3294fb3f)

2022-06-24 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 8c3d922b7e [TIR][Pass] Remove-Weight-Layout-Rewrite-Block (#11870)
 add ed3294fb3f [Arith] Update BufferDomainTouched to support vector 
access. (#11722)

No new revisions were added by this update.

Summary of changes:
 src/arith/domain_touched.cc| 18 ---
 tests/python/unittest/test_arith_domain_touched.py | 63 +-
 2 files changed, 50 insertions(+), 31 deletions(-)



[tvm] branch main updated: [LLVM] Remove PrintModule (defined in llvm_common.cc) (#11851)

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

kparzysz 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 9968b73426 [LLVM] Remove PrintModule (defined in llvm_common.cc) 
(#11851)
9968b73426 is described below

commit 9968b73426d496d59dc3ebafd0437cf551d0407f
Author: Krzysztof Parzyszek 
AuthorDate: Thu Jun 23 13:19:10 2022 -0500

[LLVM] Remove PrintModule (defined in llvm_common.cc) (#11851)

* [LLVM] Remove PrintModule (defined in llvm_common.cc)

The only use of that function is commented out. `llvm::Module` can be
printed directly to `llvm::raw_ostream` via <<, so it's quite easy to
insert printing code when needed:
```
  std::string s;
  llvm::raw_string_ostream os(s);
  os << module;   // s (or os.str()) has the LLVM IR text
```

* Restart CI
---
 src/target/llvm/codegen_llvm.cc | 1 -
 src/target/llvm/llvm_common.cc  | 7 ---
 src/target/llvm/llvm_common.h   | 2 --
 3 files changed, 10 deletions(-)

diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc
index f56c6765a6..720347957b 100644
--- a/src/target/llvm/codegen_llvm.cc
+++ b/src/target/llvm/codegen_llvm.cc
@@ -319,7 +319,6 @@ void CodeGenLLVM::Optimize() {
 fpass.run(*it);
   }
   fpass.doFinalization();
-  // PrintModule(module_.get());
   mpass.run(*module_);
 }
 
diff --git a/src/target/llvm/llvm_common.cc b/src/target/llvm/llvm_common.cc
index f13e8563e0..06b2be2d9f 100644
--- a/src/target/llvm/llvm_common.cc
+++ b/src/target/llvm/llvm_common.cc
@@ -189,13 +189,6 @@ std::string LLVMTargetToString(const Target& target) {
   return os.str();
 }
 
-void PrintModule(const llvm::Module* mod) {
-  std::string modpe_str;
-  llvm::raw_string_ostream rso(modpe_str);
-  mod->print(rso, nullptr);
-  LOG(INFO) << rso.str();
-}
-
 }  // namespace codegen
 }  // namespace tvm
 #endif  // TVM_LLVM_VERSION
diff --git a/src/target/llvm/llvm_common.h b/src/target/llvm/llvm_common.h
index d59f3977cd..e11392be29 100644
--- a/src/target/llvm/llvm_common.h
+++ b/src/target/llvm/llvm_common.h
@@ -126,8 +126,6 @@ std::unique_ptr 
GetLLVMTargetMachine(const Target& target,
  */
 std::string LLVMTargetToString(const Target& target);
 
-void PrintModule(const llvm::Module* mod);
-
 }  // namespace codegen
 }  // namespace tvm
 



[tvm] branch main updated: [LLVM] Remove `using llvm::BasicBlock`, NFC (#11850)

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

kparzysz 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 79e64ad8e0 [LLVM] Remove `using llvm::BasicBlock`, NFC (#11850)
79e64ad8e0 is described below

commit 79e64ad8e004884d6332061339194022ced2430d
Author: Krzysztof Parzyszek 
AuthorDate: Thu Jun 23 11:11:50 2022 -0500

[LLVM] Remove `using llvm::BasicBlock`, NFC (#11850)

There are a few places in CodeGenLLVM and CodeGenCPU that have this
directive. There is no other `using` directive for any other LLVM
type anywhere. Remove it for consistency with the rest of the code.
---
 src/target/llvm/codegen_cpu.cc  | 34 ++
 src/target/llvm/codegen_llvm.cc | 34 +++---
 2 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc
index 3762514c1e..b7b40f155e 100644
--- a/src/target/llvm/codegen_cpu.cc
+++ b/src/target/llvm/codegen_cpu.cc
@@ -479,10 +479,9 @@ void CodeGenCPU::InitGlobalContext(bool dynamic_lookup) {
 
 llvm::BasicBlock* CodeGenCPU::CheckCallSuccess(llvm::Value* retcode) {
   // create emit codes that checks and load the function.
-  using llvm::BasicBlock;
-  BasicBlock* fail_block = BasicBlock::Create(*ctx_, "call_fail", function_);
-  BasicBlock* end_block = BasicBlock::Create(*ctx_, "call_end", function_);
-  llvm::Value* succ = builder_->CreateICmpEQ(retcode, 
llvm::ConstantInt::get(t_int_, 0));
+  auto* fail_block = llvm::BasicBlock::Create(*ctx_, "call_fail", function_);
+  auto* end_block = llvm::BasicBlock::Create(*ctx_, "call_end", function_);
+  auto* succ = builder_->CreateICmpEQ(retcode, llvm::ConstantInt::get(t_int_, 
0));
   builder_->CreateCondBr(succ, end_block, fail_block, md_very_likely_branch_);
   builder_->SetInsertPoint(fail_block);
   // return the code.
@@ -519,7 +518,6 @@ void CodeGenCPU::CreateComputeScope(const AttrStmtNode* op) 
{
   // - Make sure the generated compute function is clearly separately(though 
it can get inlined)
   // - Set noalias on all the pointer arguments, some of them are loaded from 
TVMArgs.
   //   This is easier than set the alias scope manually.
-  using llvm::BasicBlock;
   Array vargs = tir::UndefinedVars(op->body, {});
   std::vector arg_values;
   std::vector arg_types;
@@ -539,7 +537,7 @@ void CodeGenCPU::CreateComputeScope(const AttrStmtNode* op) 
{
 
MakeStringRef(value->value), module_.get());
   SetTargetAttributes(fcompute);
 
-  BasicBlock* compute_call_end = 
CheckCallSuccess(builder_->CreateCall(fcompute, arg_values));
+  llvm::BasicBlock* compute_call_end = 
CheckCallSuccess(builder_->CreateCall(fcompute, arg_values));
   // enter compute scope and setup compute function.
   With scope_states_guard(this);
   size_t idx = 0;
@@ -571,7 +569,7 @@ void CodeGenCPU::CreateComputeScope(const AttrStmtNode* op) 
{
   }
 
   function_ = fcompute;
-  BasicBlock* compute_entry = BasicBlock::Create(*ctx_, "entry", function_);
+  auto* compute_entry = llvm::BasicBlock::Create(*ctx_, "entry", function_);
   builder_->SetInsertPoint(compute_entry);
   this->VisitStmt(op->body);
   builder_->CreateRet(ConstInt32(0));
@@ -616,7 +614,6 @@ void CodeGenCPU::UnpackClosureData(TypedPointer cdata, 
const Array& vfields
 }
 
 void CodeGenCPU::CreateParallelLaunch(const Stmt& body, int num_task, 
std::string name) {
-  using llvm::BasicBlock;
   // closure data
   llvm::Function* f =
   llvm::Function::Create(ftype_tvm_parallel_lambda_, 
llvm::Function::PrivateLinkage,
@@ -632,11 +629,11 @@ void CodeGenCPU::CreateParallelLaunch(const Stmt& body, 
int num_task, std::strin
 #else
   auto launch_callee = RuntimeTVMParallelLaunch();
 #endif
-  BasicBlock* par_launch_end = CheckCallSuccess(builder_->CreateCall(
+  llvm::BasicBlock* par_launch_end = CheckCallSuccess(builder_->CreateCall(
   launch_callee,
   {f, builder_->CreatePointerCast(cdata.addr, t_void_p_), 
ConstInt32(num_task)}));
   // Setup the closure function.
-  BasicBlock* lambda_entry = BasicBlock::Create(*ctx_, 
"parallel_closure_entry", f);
+  auto* lambda_entry = llvm::BasicBlock::Create(*ctx_, 
"parallel_closure_entry", f);
   builder_->SetInsertPoint(lambda_entry);
   auto it = f->arg_begin();
   llvm::Value* task_id = &(*it++);
@@ -686,7 +683,6 @@ llvm::Value* CodeGenCPU::CreateStaticHandle() {
 }
 
 void CodeGenCPU::CreateStaticInit(const std::string& init_fname, const Stmt& 
body) {
-  using llvm::BasicBlock;
   // closure data
   llvm::Function* f =
   llvm::Function::Create(ftype_tvm_static_init_callback_, 
llvm::Function::PrivateLinkage,
@@ -702,10 +698,10 @@ void CodeGenCPU::

[tvm] branch main updated: [LLVM/String] Remove conversion operator of String to llvm::StringRef (#11807)

2022-06-22 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 910624a86b [LLVM/String] Remove conversion operator of String to 
llvm::StringRef (#11807)
910624a86b is described below

commit 910624a86bb7618f0039235128b82ac2a4ed549a
Author: Krzysztof Parzyszek 
AuthorDate: Wed Jun 22 18:31:54 2022 -0500

[LLVM/String] Remove conversion operator of String to llvm::StringRef 
(#11807)

* [LLVM/String] Remove conversion operator of String to llvm::StringRef

We should not be declaring LLVM data structures in headers unrelated
to LLVM. There are only a handful of places where such a conversion
was used, it was replaced with a more local solution.

* Rebase to restart CI

* Restart CI
---
 include/tvm/runtime/container/string.h | 13 -
 src/target/llvm/codegen_cpu.cc |  9 -
 src/target/llvm/codegen_hexagon.cc |  7 ---
 src/target/llvm/codegen_llvm.cc| 10 +-
 src/target/llvm/codegen_llvm.h |  6 ++
 src/target/llvm/llvm_common.h  |  5 -
 6 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/include/tvm/runtime/container/string.h 
b/include/tvm/runtime/container/string.h
index bb9e7ff65a..28b0358014 100644
--- a/include/tvm/runtime/container/string.h
+++ b/include/tvm/runtime/container/string.h
@@ -69,11 +69,6 @@
 #include 
 #include 
 
-namespace llvm {
-// String to llvm object compatibility.
-class StringRef;
-}  // namespace llvm
-
 namespace tvm {
 namespace runtime {
 
@@ -266,14 +261,6 @@ class String : public ObjectRef {
*/
   operator std::string() const { return std::string{get()->data, size()}; }
 
-  // LLVM compatibility function, implemented in src/target/llvm/llvm_common.h
-  /*!
-   * \brief Convert String to an llvm::StringRef object
-   *
-   * \return llvm::StringRef
-   */
-  inline operator llvm::StringRef() const;
-
   /*!
* \brief Check if a TVMArgValue can be converted to String, i.e. it can be 
std::string or String
* \param val The value to be checked
diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc
index 2a66ff37c9..ba40c35e04 100644
--- a/src/target/llvm/codegen_cpu.cc
+++ b/src/target/llvm/codegen_cpu.cc
@@ -403,10 +403,10 @@ llvm::Value* CodeGenCPU::CreateCallExtern(Type ret_type, 
String global_symbol,
 #endif
 return builder_->CreateCall(ext_callee, arg_values);
   } else {
-llvm::Function* f = module_->getFunction(global_symbol);
+llvm::Function* f = module_->getFunction(MakeStringRef(global_symbol));
 if (f == nullptr) {
   f = llvm::Function::Create(ftype, llvm::Function::ExternalLinkage,
- global_symbol.operator llvm::StringRef(), 
module_.get());
+ MakeStringRef(global_symbol), module_.get());
 }
 #if TVM_LLVM_VERSION >= 90
 auto ext_callee = llvm::FunctionCallee(f);
@@ -535,9 +535,8 @@ void CodeGenCPU::CreateComputeScope(const AttrStmtNode* op) 
{
   // Linkage ld Error: CALL16 reloc at 0x290 not against global symbol
   const StringImmNode* value = op->value.as();
   ICHECK(value != nullptr);
-  llvm::Function* fcompute =
-  llvm::Function::Create(ftype, llvm::Function::InternalLinkage,
- value->value.operator llvm::StringRef(), 
module_.get());
+  llvm::Function* fcompute = llvm::Function::Create(ftype, 
llvm::Function::InternalLinkage,
+
MakeStringRef(value->value), module_.get());
   SetTargetAttributes(fcompute);
 
   BasicBlock* compute_call_end = 
CheckCallSuccess(builder_->CreateCall(fcompute, arg_values));
diff --git a/src/target/llvm/codegen_hexagon.cc 
b/src/target/llvm/codegen_hexagon.cc
index c007eacfce..0e8b975f9c 100644
--- a/src/target/llvm/codegen_hexagon.cc
+++ b/src/target/llvm/codegen_hexagon.cc
@@ -419,9 +419,10 @@ runtime::Module BuildHexagon(IRModule mod, Target target) {
   Array o_names = {StringImm(o_name)};
   Map extra_args;
   if (target->attrs.count("mcpu")) {
-llvm::StringRef mcpu = Downcast(target->attrs.at("mcpu"));
-ICHECK(mcpu.startswith("hexagon")) << "unexpected -mcpu value in target:" 
<< mcpu.str();
-extra_args.Set("hex_arch", mcpu.drop_front(strlen("hexagon")).str());
+std::string mcpu = Downcast(target->attrs.at("mcpu"));
+ICHECK(llvm::StringRef(mcpu).startswith("hexagon"))
+<< "unexpected -mcpu value in target:" << mcpu;
+extra_args.Set("hex_arch", 
llvm::StringRef(mcpu).drop_front(strlen("hexagon")).str());
   }
   int rc = (*f)(so_name, o_names, extra_args);
   ICHECK(rc == 0) << "Failed to link " 

[tvm] branch main updated: [Hexagon] Implement avg_pool2d slice op (#11417)

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

kparzysz 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 9d98da2736 [Hexagon] Implement avg_pool2d slice op (#11417)
9d98da2736 is described below

commit 9d98da27361429cb558930032f074172bc99b7c3
Author: Jyotsna Verma <73191103+jverma-q...@users.noreply.github.com>
AuthorDate: Wed Jun 15 12:40:37 2022 -0500

[Hexagon] Implement avg_pool2d slice op (#11417)

* Implement avg_pool2d slice op

* Address review comments and fix the STIR schedule

* Fix formatting issues

* Address pylint errors

* Additional formatting issues

* more pylint fixes

* Changed arch version to v68 for now

* Changing arch version back to v69

* Move the test to tests/python/contrib/test_hexagon/topi
---
 python/tvm/topi/hexagon/slice_ops/__init__.py  |  22 ++
 python/tvm/topi/hexagon/slice_ops/avg_pool2d.py| 141 
 python/tvm/topi/hexagon/utils.py   |  52 +++
 .../python/contrib/test_hexagon/infrastructure.py  |  20 ++
 .../test_hexagon/topi/test_avg_pool2d_slice.py | 369 +
 5 files changed, 604 insertions(+)

diff --git a/python/tvm/topi/hexagon/slice_ops/__init__.py 
b/python/tvm/topi/hexagon/slice_ops/__init__.py
new file mode 100644
index 00..b52d410676
--- /dev/null
+++ b/python/tvm/topi/hexagon/slice_ops/__init__.py
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Computes and Schedules for Hexagon slice ops. """
+
+# pylint: disable=wildcard-import
+
+from .avg_pool2d import avg_pool2d_compute, avg_pool2d_STIR_schedule
diff --git a/python/tvm/topi/hexagon/slice_ops/avg_pool2d.py 
b/python/tvm/topi/hexagon/slice_ops/avg_pool2d.py
new file mode 100644
index 00..306be543d8
--- /dev/null
+++ b/python/tvm/topi/hexagon/slice_ops/avg_pool2d.py
@@ -0,0 +1,141 @@
+# 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-variable, unused-argument, 
too-many-locals
+
+""" Compute and schedule for avg_pool2d slice op
+
+Please note the following assumptions made by the implementation:
+
+1) The input must be padded in advance to account for 'padding'. In addition,
+   both input and output must be padded as per the physical buffer layout.
+2) The current implementation assumes 'count_include_pad' to be 'True'. It can 
be
+   modified to support 'False' case but the element count for the pooling 
window
+   must be pre-computed and provided as an input to reduce the run-time 
overhead.
+3) 'padding' is ignored. It must be handled outside of the sliced op.
+4) Please note that this implementation will not work if the output includes 
any
+   physical layout related padding as it can result into out-of-bound access
+   for the input.
+"""
+
+from tvm import te
+from tvm import tir
+from ..utils import get_layout_transform_fn
+
+
+def validate_out_shape(out_shape, in_shape, kernel, stride, dilation):
+"""Validate output shape"""
+_, oh, ow, _ = out_shape
+_, ih, iw, _ = in_shape
+kh, kw = kernel
+sh, sw = stride
+dh, dw = dilation
+if ih < (oh - 1) * sh + dh * (kh - 1) + 1:
+raise RuntimeError(&quo

[tvm] branch main updated: [Hexagon] Add HexagonThreadManager (#11653)

2022-06-13 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 76b9ce9b1f [Hexagon] Add HexagonThreadManager (#11653)
76b9ce9b1f is described below

commit 76b9ce9b1f7d2b7e64b4b9c9d456a02b8a010473
Author: Adam Straw 
AuthorDate: Mon Jun 13 10:22:54 2022 -0700

[Hexagon] Add HexagonThreadManager (#11653)

* Adding initial threadmanager class

* Fixed compile errors

* Moving constant defines inside class

* Updating qurt includes

* use default scope for hexagon buffers

* Updating buffer allocations

* Fixed bug where array of pointers treated as array of structs

* - Updated HexgonDeviceAPI to use HexagonThreadManager
- Updated HexagonThreadManager interface to use TVMStreams
- Added second `Dispatch` interfce in thread manager to use PackedFuncs
- Updated thread manager to use vector for dynamic semaphore allocation
- Added "#if defined(__hexagon__)" in several places to prevent compilation 
errors

* Bug fixes + interface addition + basic thread tests
 - Fixed GetStreams not returning the streams properly
 - Added missing semaphore cleanup to prevent qurt kernel resource leakage
 - new interface functions:
   - Start() : now all worker threads are blocked on initialization until 
ThreadManager->Start() is called
   - WaitOnThreads() : blocking call which waits until all worker thread 
queues are empty
 - added extra debug logging
 - Two new basic thread tests working

* Adding initial ThreadManager tests

* HexagonThreadManager tests and refactor

* remove stack / pipe size member vars

* init pointers in the header file

* move all mem allocs to SpawnThreads

* start_semaphore as object instead of pointer

* fix bug with WaitOnThreads deadlock + Wait/Signal off by one error

* add / refactor Signal / Wait tests

* add SyncFromTo test cases

* add Dispatch test cases

* add pipe fill and overflow cases

* Updating dispatch to return bool and fix pipe overflow problem

* change around min / max values for stack / pipe

* integrate pipe fill / overflow tests back into HTM test suite

* use HexagonBuffer

* assert if stack / pipe sizes fall below min

* Changed semaphore vector to store pointers, not structs (fixes vector 
capacity adjustment invaliding in-use addresses).

* add producer consumer, thread order test cases

* change to unordered_map for semaphores and remove PreallocateSyncs

* tests running on device

* code cleanup for compile warnings

* remove #if defined(__hexagon__) guards

* copyright, format, lint

* add hexagon buffer map class

* remove redundant thread manager tests

* revert Hex Dev API changes for threading

* add comments; remove untested code to dispatch / wrap a packed func

* pass pipe address and not HTM pointer to thread context

* rename to HexagonBufferManager

* cleanup ahead of PR

* use DLOG(INFO)

* refactor GetStreamHandles to return a vector by value

* adjust HexagonBufferManager methods; use thread_manager file names

* style guidelines and debug prints

* reinterpret cast for TVMStreamHandle

* end member variables with underscore

Co-authored-by: Joseph McMahan 
---
 src/runtime/hexagon/hexagon_buffer_manager.h   |  81 ++
 src/runtime/hexagon/hexagon_device_api.cc  |  29 +-
 src/runtime/hexagon/hexagon_device_api.h   |  23 +-
 src/runtime/hexagon/hexagon_thread_manager.cc  | 291 ++
 src/runtime/hexagon/hexagon_thread_manager.h   | 194 
 .../hexagon/hexagon_thread_manager_tests.cc| 324 +
 6 files changed, 901 insertions(+), 41 deletions(-)

diff --git a/src/runtime/hexagon/hexagon_buffer_manager.h 
b/src/runtime/hexagon/hexagon_buffer_manager.h
new file mode 100644
index 00..658a39fac8
--- /dev/null
+++ b/src/runtime/hexagon/hexagon_buffer_manager.h
@@ -0,0 +1,81 @@
+/*
+ * 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

[tvm] branch main updated: [Hexagon] Tighten requirements on inclusion of runtime sources (#11635)

2022-06-13 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

kparzysz 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 2df4524e04 [Hexagon] Tighten requirements on inclusion of runtime 
sources (#11635)
2df4524e04 is described below

commit 2df4524e04cf48f759175a746632efe6ff0a7ea6
Author: Chris Sullivan 
AuthorDate: Mon Jun 13 07:00:34 2022 -0700

[Hexagon] Tighten requirements on inclusion of runtime sources (#11635)

* Tighten requirements on when Hexagon runtime sources
are included in the runtime build. Specifically only include them
when building for hexagon rpc on hardware and do not include them
for x86 (host, simulator) or android builds.

* Remove device_api.cpu binding to hexagon in simulator rpc session.

Co-authored-by: Adam Straw 
Co-authored-by: Karl Koscher 

* if(BUILD_FOR_HEXAGON)

Co-authored-by: Adam Straw 
Co-authored-by: Karl Koscher 
---
 cmake/modules/Hexagon.cmake  | 2 +-
 src/runtime/hexagon/rpc/simulator/session.cc | 4 
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/cmake/modules/Hexagon.cmake b/cmake/modules/Hexagon.cmake
index 03ab62de66..6e9b7dc70c 100644
--- a/cmake/modules/Hexagon.cmake
+++ b/cmake/modules/Hexagon.cmake
@@ -116,7 +116,7 @@ function(add_hexagon_wrapper_paths)
   link_directories("${HEXAGON_TOOLCHAIN}/lib/iss")
 endfunction()
 
-if(BUILD_FOR_HEXAGON OR USE_HEXAGON_RPC)
+if(BUILD_FOR_HEXAGON)
   # Common sources for TVM runtime with Hexagon support
   file_glob_append(RUNTIME_HEXAGON_SRCS
 "${TVMRT_SOURCE_DIR}/hexagon/*.cc"
diff --git a/src/runtime/hexagon/rpc/simulator/session.cc 
b/src/runtime/hexagon/rpc/simulator/session.cc
index 7d88bbb748..0469ad5e6e 100644
--- a/src/runtime/hexagon/rpc/simulator/session.cc
+++ b/src/runtime/hexagon/rpc/simulator/session.cc
@@ -568,10 +568,6 @@ detail::Optional 
SimulatorRPCChannel::GetCPU(const detail::MaybeStri
 }
 
 SimulatorRPCChannel::SimulatorRPCChannel(int stack_size, std::string args) {
-  const auto* api = tvm::runtime::Registry::Get("device_api.hexagon");
-  ICHECK(api != nullptr);
-  tvm::runtime::Registry::Register("device_api.cpu", true).set_body(*api);
-
   const char* sdk_root_env = std::getenv("HEXAGON_SDK_ROOT");
   ICHECK(sdk_root_env != nullptr) << "Please set HEXAGON_SDK_ROOT";
   const char* toolchain_env = std::getenv("HEXAGON_TOOLCHAIN");



[tvm] branch main updated: [Hexagon] Run single RPC server on Android in each testing session (#11547)

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

kparzysz 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 dc522a6ff6 [Hexagon] Run single RPC server on Android in each testing 
session  (#11547)
dc522a6ff6 is described below

commit dc522a6ff65b68532cd1bba43827cd981114df2c
Author: Mehrdad Hessar 
AuthorDate: Fri Jun 10 14:33:24 2022 -0700

[Hexagon] Run single RPC server on Android in each testing session  (#11547)

* Reuse hexagon launcher in test session

* separate random name generation

* revert get_aot_executor

* Fix launcher for simulator case

* add stop server for simulator
---
 python/tvm/contrib/hexagon/build.py| 158 +++--
 python/tvm/contrib/hexagon/pytest_plugin.py|  66 +++--
 python/tvm/contrib/hexagon/session.py  |  90 +++-
 tests/python/contrib/test_hexagon/test_launcher.py |   2 -
 4 files changed, 195 insertions(+), 121 deletions(-)

diff --git a/python/tvm/contrib/hexagon/build.py 
b/python/tvm/contrib/hexagon/build.py
index c659d66bec..7e29f645ce 100644
--- a/python/tvm/contrib/hexagon/build.py
+++ b/python/tvm/contrib/hexagon/build.py
@@ -28,6 +28,7 @@ import stat
 import random
 import string
 import subprocess
+import tempfile
 from typing import Union
 
 import tvm
@@ -36,6 +37,7 @@ from .session import Session
 
 
 HEXAGON_RPC_LIB_DIR = os.environ.get("HEXAGON_RPC_LIB_DIR")
+ANDROID_BASH_FILE_NAME = "android_bash.sh"
 
 
 def _get_hexagon_rpc_lib_dir() -> pathlib.Path:
@@ -116,7 +118,6 @@ class HexagonLauncherRPC(metaclass=abc.ABCMeta):
 self._rpc_info.update(rpc_info)
 self._workspace = self._create_workspace(workspace)
 self._device_key = self.HEXAGON_REMOTE_DEVICE_KEY
-self._serial_number = None
 
 @abc.abstractmethod
 def start_server(self):
@@ -128,6 +129,11 @@ class HexagonLauncherRPC(metaclass=abc.ABCMeta):
 """Stop the RPC server"""
 ...
 
+@abc.abstractmethod
+def cleanup_directory(self):
+"""Cleanup working directory"""
+...
+
 @abc.abstractmethod
 def _copy_to_remote(
 self, local_path: Union[str, pathlib.Path], remote_path: Union[str, 
pathlib.Path]
@@ -144,13 +150,18 @@ class HexagonLauncherRPC(metaclass=abc.ABCMeta):
 ...
 
 @abc.abstractmethod
-def _create_remote_directory(self, remote_path: Union[str, pathlib.Path]):
+def _create_remote_directory(self, remote_path: Union[str, pathlib.Path]) 
-> pathlib.Path:
 """Create a directory in the remote location.
 
 Parameters
 --
 remote_path : str or pathlib.Path
 Name of the directory to be created.
+
+Returns
+---
+pathlib.Path :
+Absolute path of the remote workspace.
 """
 ...
 
@@ -171,10 +182,9 @@ class HexagonLauncherRPC(metaclass=abc.ABCMeta):
 if not workspace:
 base_dir = self._rpc_info["workspace_base"]
 workspace = os.path.join(base_dir, _get_test_directory_name())
-self._create_remote_directory(workspace)
-return pathlib.Path(workspace)
+return self._create_remote_directory(workspace)
 
-def upload(self, local_path: Union[str, pathlib.Path], remote_filename: 
str):
+def upload(self, local_path: Union[str, pathlib.Path], remote_filename: 
str) -> pathlib.Path:
 """Upload a local file to the remote workspace.
 
 Parameters
@@ -183,9 +193,16 @@ class HexagonLauncherRPC(metaclass=abc.ABCMeta):
 Path to the local file to be copied.
 remote_filename : str
 Name of the file in the remote workspace.
+
+Returns
+---
+pathlib.Path :
+Uploaded file remote path.
 """
 assert self._workspace
-self._copy_to_remote(local_path, os.path.join(str(self._workspace), 
remote_filename))
+remote_file_path = self._workspace / remote_filename
+self._copy_to_remote(local_path, str(remote_file_path))
+return remote_file_path
 
 def start_session(self, session_name: str = "hexagon-rpc") -> Session:
 """Connect to the RPC server.
@@ -221,10 +238,7 @@ class HexagonLauncherRPC(metaclass=abc.ABCMeta):
 session and loaded.
 
 If the object passed is a string or pathlib.Path, it must
-be either a bare file name (without any path components),
-or a full path in the remote system. If it is a file name,
-the file must already have been uploaded to the remote,
-and be placed in the remote workspace.
+be a 

[tvm] branch main updated: [Hexagon] Make local symbols visible to loaded modules in RPC server (#11611)

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

kparzysz 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 b00b1229c8 [Hexagon] Make local symbols visible to loaded modules in 
RPC server (#11611)
b00b1229c8 is described below

commit b00b1229c881fa6f2f9fe9e44819c9dc3de09f74
Author: Krzysztof Parzyszek 
AuthorDate: Wed Jun 8 07:24:36 2022 -0500

[Hexagon] Make local symbols visible to loaded modules in RPC server 
(#11611)

The simulator library `libhexagon_rpc_sim.so` contains TVM runtime built
into it, but since it's loaded as a "local" library these symbols are not
visible to shared libraries loaded by subsequent dlopens. (Same applies to
symbols from the C++ runtime.)

To make these symbols visible, dlopen the defining libraries as "global".
(Re-dlopeninig an already loaded library is a well-defined operation.)
---
 src/runtime/hexagon/rpc/simulator/rpc_server.cc | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/runtime/hexagon/rpc/simulator/rpc_server.cc 
b/src/runtime/hexagon/rpc/simulator/rpc_server.cc
index 29373be542..9b4ce3f114 100644
--- a/src/runtime/hexagon/rpc/simulator/rpc_server.cc
+++ b/src/runtime/hexagon/rpc/simulator/rpc_server.cc
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -288,7 +289,16 @@ int DISPATCH_FUNCTION_NAME(void* serverp) {
   return 0;
 }
 
-int main() {
+int main(int argc, char* argv[]) {
+  // Load C++RT and ourselves as "global" to make all the symbols defined
+  // there be visible to any subsequent libraries loaded via dlopen.
+  void* cxx_abi = dlopen("libc++abi.so", RTLD_GLOBAL);
+  ICHECK(cxx_abi != nullptr);
+  void* cxx = dlopen("libc++.so", RTLD_GLOBAL);
+  ICHECK(cxx != nullptr);
+  void* self = dlopen(argv[0], RTLD_GLOBAL);
+  ICHECK(self != nullptr);
+
   const auto* api = tvm::runtime::Registry::Get("device_api.hexagon");
   ICHECK(api != nullptr);
   tvm::runtime::Registry::Register("device_api.cpu", true).set_body(*api);
@@ -308,6 +318,9 @@ int main() {
 // nothing
   }
 
+  dlclose(self);
+  dlclose(cxx);
+  dlclose(cxx_abi);
   return 0;
 }
 



[tvm] branch main updated (774ee969fc -> d490620085)

2022-06-07 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 774ee969fc [relay] add missing virtual d'tor (#11601)
 add d490620085 [Hexagon][CI] Re-enable Hexagon tests in CI (#11613)

No new revisions were added by this update.

Summary of changes:
 python/tvm/contrib/hexagon/_ci_env_check.py | 62 +
 python/tvm/contrib/hexagon/pytest_plugin.py | 10 +
 python/tvm/testing/utils.py |  8 ++--
 3 files changed, 66 insertions(+), 14 deletions(-)
 create mode 100644 python/tvm/contrib/hexagon/_ci_env_check.py



[tvm] branch main updated (12440895e4 -> 81702192b4)

2022-06-07 Thread kparzysz
This is an automated email from the ASF dual-hosted git repository.

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


from 12440895e4 [MetaSchedule] Add Testing Script with ONNX Support (#11587)
 add 81702192b4 [MetaSchedule] Resolve dependencies between header files 
(#11604)

No new revisions were added by this update.

Summary of changes:
 include/tvm/meta_schedule/apply_history_best.h |  9 ++-
 include/tvm/meta_schedule/arg_info.h   |  3 +
 include/tvm/meta_schedule/builder.h|  8 +++
 include/tvm/meta_schedule/cost_model.h | 34 ---
 include/tvm/meta_schedule/database.h   |  7 +++
 include/tvm/meta_schedule/extracted_task.h |  7 ++-
 include/tvm/meta_schedule/feature_extractor.h  | 13 ++--
 include/tvm/meta_schedule/measure_callback.h   | 11 ++--
 include/tvm/meta_schedule/measure_candidate.h  | 67 +
 include/tvm/meta_schedule/mutator.h| 18 +++---
 include/tvm/meta_schedule/postproc.h   | 15 ++---
 include/tvm/meta_schedule/runner.h |  6 ++
 include/tvm/meta_schedule/schedule_rule.h  | 20 +++
 include/tvm/meta_schedule/search_strategy.h| 69 --
 include/tvm/meta_schedule/space_generator.h| 21 +++
 include/tvm/meta_schedule/task_scheduler.h | 47 ---
 include/tvm/meta_schedule/tune_context.h   |  8 +++
 src/meta_schedule/cost_model/cost_model.cc | 24 
 .../feature_extractor/feature_extractor.cc |  6 ++
 .../measure_callback/measure_callback.cc   |  9 +++
 src/meta_schedule/mutator/mutator.cc   | 12 
 src/meta_schedule/postproc/postproc.cc | 11 
 src/meta_schedule/schedule_rule/schedule_rule.cc   | 12 
 .../search_strategy/search_strategy.cc | 27 -
 .../space_generator/space_generator.cc | 12 
 src/meta_schedule/task_scheduler/task_scheduler.cc | 37 
 26 files changed, 344 insertions(+), 169 deletions(-)
 create mode 100644 include/tvm/meta_schedule/measure_candidate.h



  1   2   >