[I] Several issues were generated in building the source code with LLVM 18 [tvm]
xwentian2020 opened a new issue, #16488: URL: https://github.com/apache/tvm/issues/16488 A few issues were found in building TVM 0.13.0 by using LLVM 18 in Ubuntu22.04, and the way presented in cmake/config.cmake file was tried to build the source code. llvm::CGFT_ObjectFile and llvm::CGFT_AssemblyFile in several files (codegen_amdgpu.cc codegen_hexagon.cc, codegen_nvptx.cc) should be replaed with llvm::CodeGenFileType::ObjectFile and llvm::CodeGenFileType::AssemblyFile. BTW, in the file llvm_instance.cc, changes should be made as well in some code snippets which used llvm::CodeGenOpt::Level::None and similar statements. llvm::CodeGenOptLevel::None should be used instead in building the source code of TVM by LLVM 18.0. FYI. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
(tvm) branch nightly updated (90320b2424 -> fd1f40f989)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch nightly in repository https://gitbox.apache.org/repos/asf/tvm.git from 90320b2424 [Frontend][PaddlePaddle] Fixed the bug that prevented the model from being successfully converted to microTVM on MacOS (#16478) add e7125a7af2 [Unity][Frontend] Add Sigmoid and Square Op (#16483) add 5092c003de [BugTIR] fix thread_sync occurs in letstmt (#16454) add ff9ebadf6a [wasm] Enlarge initial memory for emcc (#16485) add 147ed5e27d [Unity][CodeGen] RunCodegen based on externally-exposed functions (#16422) add fd1f40f989 [Unity][MSC][Refactor] Reconstruct BYOC and runner (#16467) No new revisions were added by this update. Summary of changes: python/tvm/contrib/emcc.py | 2 +- python/tvm/contrib/msc/core/frontend/translate.py | 28 +- python/tvm/contrib/msc/core/ir/graph.py| 13 + python/tvm/contrib/msc/core/runtime/hook.py| 196 +++ python/tvm/contrib/msc/core/runtime/runner.py | 634 + .../contrib/msc/core/tools/distill/distiller.py| 15 +- python/tvm/contrib/msc/core/tools/prune/pruner.py | 82 +-- python/tvm/contrib/msc/core/tools/tool.py | 83 ++- python/tvm/contrib/msc/core/tools/track/method.py | 10 +- python/tvm/contrib/msc/core/tools/track/tracker.py | 12 +- python/tvm/contrib/msc/core/transform/pattern.py | 97 +++- python/tvm/contrib/msc/core/transform/transform.py | 4 +- python/tvm/contrib/msc/core/utils/__init__.py | 1 + python/tvm/contrib/msc/core/utils/arguments.py | 228 python/tvm/contrib/msc/core/utils/dataset.py | 6 +- python/tvm/contrib/msc/core/utils/expr.py | 23 +- python/tvm/contrib/msc/core/utils/file.py | 55 ++ python/tvm/contrib/msc/core/utils/info.py | 240 ++-- python/tvm/contrib/msc/core/utils/log.py | 2 +- python/tvm/contrib/msc/core/utils/message.py | 2 +- python/tvm/contrib/msc/core/utils/register.py | 41 +- .../msc/framework/tensorflow/runtime/runner.py | 91 ++- .../msc/framework/tensorrt/codegen/codegen.py | 48 +- .../msc/framework/tensorrt/runtime/runner.py | 47 +- .../msc/framework/tensorrt/transform/pattern.py| 26 +- .../contrib/msc/framework/torch/runtime/runner.py | 132 - .../msc/framework/torch/tools/distill/distiller.py | 4 +- .../contrib/msc/framework/tvm/runtime/runner.py| 157 - .../msc/framework/tvm/tools/track/tracker.py | 5 +- python/tvm/contrib/msc/pipeline/manager.py | 569 -- python/tvm/ir/module.py| 9 + python/tvm/relax/frontend/nn/op.py | 44 ++ python/tvm/relax/transform/transform.py| 3 +- src/contrib/msc/core/codegen/codegen_utils.h | 9 +- src/contrib/msc/core/codegen/py_codegen.h | 2 +- src/contrib/msc/core/ir/graph.cc | 38 ++ src/contrib/msc/core/ir/graph.h| 2 + src/contrib/msc/core/ir/graph_builder.cc | 348 +++ src/contrib/msc/core/ir/graph_builder.h| 49 +- src/contrib/msc/core/transform/fuse_tuple.cc | 36 +- src/contrib/msc/core/transform/inline_params.cc| 192 +++ src/contrib/msc/core/transform/layout_utils.cc | 25 +- src/contrib/msc/core/transform/set_byoc_attrs.cc | 39 +- src/contrib/msc/core/transform/set_expr_name.cc| 105 ++-- .../msc/framework/tensorflow/codegen_utils.h | 7 +- src/contrib/msc/framework/tensorrt/codegen.cc | 10 +- .../msc/framework/tensorrt/transform_tensorrt.cc | 28 +- src/contrib/msc/framework/torch/codegen_utils.h| 7 +- src/ir/module.cc | 34 ++ src/relax/transform/run_codegen.cc | 40 +- src/tir/transforms/storage_access.cc | 14 + src/tir/transforms/storage_access.h| 1 + tests/python/contrib/test_msc/test_manager.py | 16 +- tests/python/contrib/test_msc/test_runner.py | 22 +- tests/python/contrib/test_msc/test_tools.py| 18 +- tests/python/contrib/test_msc/test_transform.py| 20 +- .../contrib/test_msc/test_translate_tensorrt.py| 10 +- tests/python/relax/test_frontend_nn_op.py | 27 + tests/python/relax/test_transform_codegen_pass.py | 43 +- .../test_tir_transform_thread_sync.py | 77 +++ 60 files changed, 2884 insertions(+), 1244 deletions(-) create mode 100644 python/tvm/contrib/msc/core/runtime/hook.py create mode 100644 python/tvm/contrib/msc/core/utils/arguments.py create mode 100644 src/contrib/msc/core/transform/inline_params.cc
Re: [PR] [Unity][MSC][Refactor] Reconstruct BYOC and runner [tvm]
Hzfengsy merged PR #16467: URL: https://github.com/apache/tvm/pull/16467 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [Unity][Relax] Avoid removing `PrimFunc`s that are used for in-place calls in `FuseTIR` [tvm]
slyubomirsky closed pull request #16462: [Unity][Relax] Avoid removing `PrimFunc`s that are used for in-place calls in `FuseTIR` URL: https://github.com/apache/tvm/pull/16462 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [Unity][Relax] Avoid removing `PrimFunc`s that are used for in-place calls in `FuseTIR` [tvm]
slyubomirsky commented on PR #16462: URL: https://github.com/apache/tvm/pull/16462#issuecomment-1915996161 No longer necessary thanks to [16487](https://github.com/apache/tvm/pull/16487) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[PR] [Unity][Transform] Handle `call_tir_inplace` in `FuseTIR` [tvm]
slyubomirsky opened a new pull request, #16487: URL: https://github.com/apache/tvm/pull/16487 This PR handles in-place `PrimFunc`s in `FuseTIR`, namely by propagating the in-place indices. This required a few updates in `FuseTIR` but nothing very heavy-duty. It will also be necessary to update `FuseOps` to get examples like that in [this thread](https://discuss.tvm.apache.org/t/discuss-inplace-and-fusion-opportunities-in-llm-runtime/16292) to work. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
(tvm) branch main updated: [Unity][CodeGen] RunCodegen based on externally-exposed functions (#16422)
This is an automated email from the ASF dual-hosted git repository. wuwei 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 147ed5e27d [Unity][CodeGen] RunCodegen based on externally-exposed functions (#16422) 147ed5e27d is described below commit 147ed5e27d76432ea02ce1cd590ba2cbbd76378e Author: Eric Lunderberg AuthorDate: Mon Jan 29 20:51:34 2024 -0600 [Unity][CodeGen] RunCodegen based on externally-exposed functions (#16422) * [IR] Add utility methods to IRModule * `IRModule.clone`: Clone the module. While in C++, a module can be copied using `IRModule::CopyOnWrite()`, copying a module in Python required passing all members into the `IRModule` initializer. The `IRModule.clone` method provides an easier way to copy an `IRModule` from python. * `IRModule.__delitem__`: Remove a function from the module. This exposes the C++ method `IRModuleNode::Remove` for use in the python API. This uses the python `del` keyword, similar to a native python list. Similar to the existing `IRModule.__getitem__`, this can be called with either a `GlobalVar` or a python string. * `IRModule.__contains__`: Check if a function is in the module. This allows the pythone keyword `in` to check if a module contains a specific function. Similar to the existing `IRModule.__getitem__`, this can be called either with a `GlobalVar` (`if gvar in mod`) or with a python string (`if "function_name" in mod`). * [Unity][CodeGen] RunCodegen based on externally-exposed functions Prior to this commit, `relax.transform.RunCodegen` required a list of entry functions for a module, defaulting to `"main"` if not specified. The list of entry functions is duplicate information that could be inferred from the module, and should not be required from the user. This commit updates `RunCodegen` to treat all externally-exposed functions as entry points, in the same manner as `DeadCodeElimination`. For backwards compatibility, the `entry_functions` argument is still accepted, and is used to augment the list of externally-exposed functions. --- python/tvm/ir/module.py | 9 + python/tvm/relax/transform/transform.py | 3 +- src/ir/module.cc | 34 ++ src/relax/transform/run_codegen.cc| 40 + tests/python/relax/test_transform_codegen_pass.py | 43 +++ 5 files changed, 115 insertions(+), 14 deletions(-) diff --git a/python/tvm/ir/module.py b/python/tvm/ir/module.py index a3e097947c..ea3ef6d883 100644 --- a/python/tvm/ir/module.py +++ b/python/tvm/ir/module.py @@ -80,6 +80,9 @@ class IRModule(Node, Scriptable): global_infos, ) +def clone(self) -> "IRModule": +return _ffi_api.Module_Clone(self) + def functions_items(self): """Get items in self.functions.items() in alphabetical order. @@ -138,6 +141,12 @@ class IRModule(Node, Scriptable): return _ffi_api.Module_Lookup(self, var) return _ffi_api.Module_LookupDef(self, var) +def __delitem__(self, var: Union[str, _expr.GlobalVar]): +_ffi_api.Module_Remove(self, var) + +def __contains__(self, var: Union[str, _expr.GlobalVar]) -> bool: +return _ffi_api.Module_Contains(self, var) + def update(self, other): """Insert functions in another Module to current one. diff --git a/python/tvm/relax/transform/transform.py b/python/tvm/relax/transform/transform.py index 1f390adb2e..e360c09392 100644 --- a/python/tvm/relax/transform/transform.py +++ b/python/tvm/relax/transform/transform.py @@ -574,7 +574,8 @@ def RunCodegen( The registered pass to remove unused functions. """ if entry_functions is None: -entry_functions = ["main"] +entry_functions = [] + # enable cutlass byoc registries # pylint: disable=unused-import,import-outside-toplevel from tvm.contrib import cutlass as _cutlass diff --git a/src/ir/module.cc b/src/ir/module.cc index 156158a85f..2e60441e94 100644 --- a/src/ir/module.cc +++ b/src/ir/module.cc @@ -413,6 +413,12 @@ TVM_REGISTER_GLOBAL("ir.IRModule") return IRModule(funcs, types, {}, {}, dict_attrs, global_infos); }); +TVM_REGISTER_GLOBAL("ir.Module_Clone").set_body_typed([](IRModule mod) -> IRModule { + IRModule clone = mod; + clone.CopyOnWrite(); + return clone; +}); + TVM_REGISTER_GLOBAL("ir.Module_Add") .set_body_typed([](IRModule mod, GlobalVar var, ObjectRef val, bool update) -> IRModule { ICHECK(val->IsInstance()); @@ -423,6 +429,34 @@ TVM_REGISTER_GLOBAL("ir.Module_Add") return mod; }); +TVM_REGISTER_GLOBAL("ir.Module_Remove") +.set_body_typed([](IRModule mod,
Re: [PR] [Unity][CodeGen] RunCodegen based on externally-exposed functions [tvm]
vinx13 merged PR #16422: URL: https://github.com/apache/tvm/pull/16422 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
(tvm) branch main updated: [wasm] Enlarge initial memory for emcc (#16485)
This is an automated email from the ASF dual-hosted git repository. wuwei 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 ff9ebadf6a [wasm] Enlarge initial memory for emcc (#16485) ff9ebadf6a is described below commit ff9ebadf6ae6bdf2fbfe5eb220d770b0ed9550cd Author: Wuwei Lin AuthorDate: Mon Jan 29 15:59:21 2024 -0800 [wasm] Enlarge initial memory for emcc (#16485) --- python/tvm/contrib/emcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tvm/contrib/emcc.py b/python/tvm/contrib/emcc.py index 7f0b16683d..d4624a3469 100644 --- a/python/tvm/contrib/emcc.py +++ b/python/tvm/contrib/emcc.py @@ -49,7 +49,7 @@ def create_tvmjs_wasm(output, objects, options=None, cc="emcc"): cmd += ["-s", "ERROR_ON_UNDEFINED_SYMBOLS=0"] cmd += ["-s", "STANDALONE_WASM=1"] cmd += ["-s", "ALLOW_MEMORY_GROWTH=1"] -cmd += ["-s", "TOTAL_MEMORY=80MB"] +cmd += ["-s", "TOTAL_MEMORY=160MB"] objects = [objects] if isinstance(objects, str) else objects
Re: [PR] [wasm] Enlarge initial memory for emcc [tvm]
vinx13 merged PR #16485: URL: https://github.com/apache/tvm/pull/16485 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[PR] [Runtime] KV cache providing workspace for attn kernel [tvm]
MasterJH5574 opened a new pull request, #16486: URL: https://github.com/apache/tvm/pull/16486 This PR supports passing pre-allocated workspace to attention kernels, so that runtime repetitive allocation or workspaces can be eliminated. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
(tvm) branch main updated: [BugTIR] fix thread_sync occurs in letstmt (#16454)
This is an automated email from the ASF dual-hosted git repository. wuwei 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 5092c003de [BugTIR] fix thread_sync occurs in letstmt (#16454) 5092c003de is described below commit 5092c003de6424332d9179ddd405540092b96742 Author: Wei Tao <1136862...@qq.com> AuthorDate: Tue Jan 30 02:05:22 2024 +0800 [BugTIR] fix thread_sync occurs in letstmt (#16454) * [BugTIR] fix thread_sync occurs in letstmt * modify visit letstmt * typo * remove unecessary clear --- src/tir/transforms/storage_access.cc | 14 src/tir/transforms/storage_access.h| 1 + .../test_tir_transform_thread_sync.py | 77 ++ 3 files changed, 92 insertions(+) diff --git a/src/tir/transforms/storage_access.cc b/src/tir/transforms/storage_access.cc index cbc7f07cae..8c7a7035de 100644 --- a/src/tir/transforms/storage_access.cc +++ b/src/tir/transforms/storage_access.cc @@ -94,6 +94,20 @@ void StorageAccessVisitor::VisitStmt_(const EvaluateNode* op) { allow_append_ = false; } +void StorageAccessVisitor::VisitStmt_(const LetStmtNode* op) { + allow_append_ = true; + ICHECK_EQ(curr_stmt_.access.size(), 0U); + curr_stmt_.stmt = op; + this->VisitExpr(op->value); + // push to the scope + scope_.back().push_back(curr_stmt_); + // clear access entry. + curr_stmt_.access.clear(); + allow_append_ = false; + // traverse body block + this->VisitStmt(op->body); +} + void StorageAccessVisitor::VisitStmt_(const AttrStmtNode* op) { if (op->attr_key == attr::double_buffer_write) { ICHECK(double_buffer_write_ == nullptr); diff --git a/src/tir/transforms/storage_access.h b/src/tir/transforms/storage_access.h index 119e595f59..a0e03b35cd 100644 --- a/src/tir/transforms/storage_access.h +++ b/src/tir/transforms/storage_access.h @@ -84,6 +84,7 @@ class StorageAccessVisitor : public StmtExprVisitor { void VisitExpr_(const BufferLoadNode* op) final; void VisitStmt_(const BufferStoreNode* op) final; void VisitStmt_(const EvaluateNode* op) final; + void VisitStmt_(const LetStmtNode* op) final; void VisitStmt_(const AttrStmtNode* op) final; void VisitStmt_(const ForNode* op) final; void VisitStmt_(const IfThenElseNode* op) final; diff --git a/tests/python/tir-transform/test_tir_transform_thread_sync.py b/tests/python/tir-transform/test_tir_transform_thread_sync.py index 2cfc65aae0..5c43d8d96a 100644 --- a/tests/python/tir-transform/test_tir_transform_thread_sync.py +++ b/tests/python/tir-transform/test_tir_transform_thread_sync.py @@ -160,8 +160,85 @@ def test_sync_shared_dyn(): tvm.ir.assert_structural_equal(mod["main"], expected) +@tvm.testing.requires_cuda +def test_sync_let_stmt(): +@T.prim_func(private=True) +def func(A: T.Buffer((16 * 512), "float32")): +blockIdx_x = T.launch_thread("blockIdx.x", 16) +A_shared = T.allocate([512], "float32", "shared") +in_thread_A_temp = T.allocate([1], "float32", "local") +cross_thread_A_temp = T.allocate([1], "float32", "local") +threadIdx_x = T.launch_thread("threadIdx.x", 128) +A_shared_1 = T.Buffer((512,), data=A_shared, scope="shared") +for ax0 in range(512): +A_shared_1[ax0] = A[blockIdx_x * 512 + ax0] +in_thread_A_temp_1 = T.Buffer((1,), data=in_thread_A_temp, scope="local") +in_thread_A_temp_1[0] = T.float32(0) +with T.LetStmt(in_thread_A_temp_1[0] + A_shared_1[threadIdx_x]) as A_temp: +in_thread_A_temp_1[0] = A_temp +with T.LetStmt(in_thread_A_temp_1[0] + A_shared_1[threadIdx_x + 128]) as A_temp: +in_thread_A_temp_1[0] = A_temp +with T.LetStmt(in_thread_A_temp_1[0] + A_shared_1[threadIdx_x + 256]) as A_temp: +in_thread_A_temp_1[0] = A_temp +with T.LetStmt(in_thread_A_temp_1[0] + A_shared_1[threadIdx_x + 384]) as A_temp: +in_thread_A_temp_1[0] = A_temp +cross_thread_A_temp_1 = T.Buffer((1,), data=cross_thread_A_temp, scope="local") +with T.attr( +T.comm_reducer(lambda x0, y0: x0 + y0, [T.float32(0)]), +"reduce_scope", +T.reinterpret("handle", T.uint64(0)), +): +T.tvm_thread_allreduce( +T.uint32(1), +in_thread_A_temp_1[0], +T.bool(True), +cross_thread_A_temp_1[0], +threadIdx_x, +) + +@T.prim_func(private=True) +def expected(A: T.Buffer((8192,), "float32")): +blockIdx_x = T.launch_thread("blockIdx.x", 16) +A_shared_1 = T.allocate([512], "float32", "shared") +in_thread_A_temp_1 = T.allocate([1], "float32", "local") +cross_thread_A_temp_1 = T.allocate([1], "float32", "local") +threadIdx_x = T.launch_thread("threadIdx.x", 128) +
Re: [PR] [BugTIR] fix thread_sync occurs in letstmt [tvm]
vinx13 merged PR #16454: URL: https://github.com/apache/tvm/pull/16454 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Update flash attention to integrate flash decoding with paged KV cache [tvm]
vinx13 commented on PR #16474: URL: https://github.com/apache/tvm/pull/16474#issuecomment-1915215166 we can move gpu builder to larger cpu instance if needed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
(tvm) branch main updated: [Unity][Frontend] Add Sigmoid and Square Op (#16483)
This is an automated email from the ASF dual-hosted git repository. yongwww 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 e7125a7af2 [Unity][Frontend] Add Sigmoid and Square Op (#16483) e7125a7af2 is described below commit e7125a7af2ad940f8d00c00bcc3836411f582ecd Author: Siyuan Feng AuthorDate: Tue Jan 30 01:03:16 2024 +0800 [Unity][Frontend] Add Sigmoid and Square Op (#16483) This PR adds two new ops to the frontend: Sigmoid and Square. --- python/tvm/relax/frontend/nn/op.py| 44 +++ tests/python/relax/test_frontend_nn_op.py | 27 +++ 2 files changed, 71 insertions(+) diff --git a/python/tvm/relax/frontend/nn/op.py b/python/tvm/relax/frontend/nn/op.py index ac5858d5cd..720e3dd3b4 100644 --- a/python/tvm/relax/frontend/nn/op.py +++ b/python/tvm/relax/frontend/nn/op.py @@ -843,6 +843,31 @@ def gelu(x: Tensor, approximate: Optional[str] = None, name: str = "gelu") -> Te return wrap_nested(gelu_out, name) +def sigmoid(x: Tensor, name: str = "sigmoid") -> Tensor: +r"""Computes sigmoid. + +.. math:: \text{sigmoid}(x) = \frac{1}{1 + \exp(-x)} + +Parameters +-- +data: Tensor +The input data to the operator. + +name : str +Name hint. + +Returns +--- +result : Tensor +The computed result. + +Note + +The input tensor is required to have float dtype +""" +return wrap_nested(_op.sigmoid(x._expr), name) + + def softmax(x: Tensor, axis: int = -1, name: str = "softmax") -> Tensor: r"""Computes softmax. @@ -1268,6 +1293,25 @@ def pad( return wrap_nested(_op.nn.pad(x._expr, pad_width=pad, pad_value=value, pad_mode=mode), name) +def square(x: Tensor, name: str = "square") -> Tensor: +"""Computes the element-wise square of the input tensor. + +Parameters +-- +x : Tensor +The input tensor. + +name : str +Name hint. + +Returns +--- +result : Tensor +The computed result. +""" +return wrap_nested(_op.square(x._expr), name) + + def get_timestep_embedding( x: Tensor, embedding_dim: int, diff --git a/tests/python/relax/test_frontend_nn_op.py b/tests/python/relax/test_frontend_nn_op.py index 43f4a9efc0..ed2e3753b2 100644 --- a/tests/python/relax/test_frontend_nn_op.py +++ b/tests/python/relax/test_frontend_nn_op.py @@ -26,6 +26,31 @@ from tvm.script import tir as T # mypy: disable-error-code="attr-defined,valid-type,name-defined" +def test_unary(): +class Model(Module): +def test(self, x: Tensor): +z0 = op.square(x) +return (x,) + +# fmt: off +@R.function +def test(x: R.Tensor((1, 10), dtype="float32"), _io: R.Object): +R.func_attr({"num_input": 2}) +with R.dataflow(): +square: R.Tensor((1, 10), dtype="float32") = R.square(x) +gv1 = (x,), (_io,) +R.output(gv1) +return gv1 +# fmt: on + +m = Model() +irmodule, _ = m.export_tvm( +spec={"test": {"x": spec.Tensor([1, 10], "float32")}}, +debug=True, +) +tvm.ir.assert_structural_equal(irmodule["test"], test) + + def test_binary(): class Model(Module): def test(self, x: Tensor, y: Tensor): @@ -298,6 +323,7 @@ def test_nn(): relu_out = op.relu(x) silu_out = op.silu(x) gelu_out = op.gelu(x) +sigmoid_out = op.sigmoid(x) softmax_out = op.softmax(x, axis=2) rms_norm_out = op.rms_norm(x, weight, axes=[-2, -1]) rms_norm_with_bias_out = op.rms_norm(x, weight, axes=[-2, -1]) @@ -316,6 +342,7 @@ def test_nn(): relu: R.Tensor((2, 3, 4, 5), dtype="float32") = R.nn.relu(x) silu: R.Tensor((2, 3, 4, 5), dtype="float32") = R.nn.silu(x) gelu: R.Tensor((2, 3, 4, 5), dtype="float32") = R.nn.gelu(x) +sigmoid: R.Tensor((2, 3, 4, 5), dtype="float32") = R.sigmoid(x) softmax: R.Tensor((2, 3, 4, 5), dtype="float32") = R.nn.softmax(x, axis=2) rms_norm: R.Tensor((2, 3, 4, 5), dtype="float32") = R.nn.rms_norm( x, weight, axes=[-2, -1], epsilon=1.0001e-05
Re: [PR] [Unity][Frontend] Add Sigmoid and Square Op [tvm]
yongwww merged PR #16483: URL: https://github.com/apache/tvm/pull/16483 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [SVE] Add vscale builtin [tvm]
ekalda commented on PR #16484: URL: https://github.com/apache/tvm/pull/16484#issuecomment-1915068044 cc @lhutton1 @neildhickey -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[PR] [SVE] Add vscale builtin [tvm]
ekalda opened a new pull request, #16484: URL: https://github.com/apache/tvm/pull/16484 Add a `vscale` builtin and lowering to `llvm.vscale`. This will be used in subsequent patches for expressing scalable vectors in TIR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [Target] Use LLVM target parser for determining Arm(R) A-Profile Architecture features [tvm]
lhutton1 commented on code in PR #16425: URL: https://github.com/apache/tvm/pull/16425#discussion_r1469390515 ## src/target/llvm/llvm_instance.cc: ## @@ -199,32 +199,37 @@ std::ostream& operator<<(std::ostream& os, const LLVMTargetInfo::Option& opt) { return os; } -LLVMTargetInfo::LLVMTargetInfo(LLVMInstance& instance, const Target& target) { - triple_ = target->GetAttr("mtriple").value_or("default"); +LLVMTargetInfo::LLVMTargetInfo(LLVMInstance& instance, const Target& target) +: LLVMTargetInfo(instance, target->Export()) {} +LLVMTargetInfo::LLVMTargetInfo(LLVMInstance& instance, const TargetJSON& target) { + triple_ = Downcast(target.Get("mtriple").value_or(String("default"))); if (triple_.empty() || triple_ == "default") { triple_ = llvm::sys::getDefaultTargetTriple(); } - cpu_ = target->GetAttr("mcpu").value_or(defaults::cpu); + cpu_ = Downcast(target.Get("mcpu").value_or(String(defaults::cpu))); - if (const Optional>& v = target->GetAttr>("mattr")) { + if (const auto& v = Downcast>>(target.Get("mattr"))) { for (const String& s : v.value()) { attrs_.push_back(s); } } // llvm module target - if (target->kind->name == "llvm") { + if (Downcast(target.Get("kind")) == "llvm") { // legalize -mcpu with the target -mtriple auto arches = GetAllLLVMTargetArches(); bool has_arch = std::any_of(arches.begin(), arches.end(), [&](const auto& var) { return var == cpu_; }); if (!has_arch) { - LOG(FATAL) << "LLVM cpu architecture `-mcpu=" << cpu_ - << "` is not valid in `-mtriple=" << triple_ << "`"; + // Flag an error, but don't abort. This mimicks the behaviour of 'llc' to + // give the code a chance to run with a less-specific target. + LOG(ERROR) << "LLVM cpu architecture `-mcpu=" << cpu_ + << "` is not valid in `-mtriple=" << triple_ << "`" + << ", cpu architecture ignored"; Review Comment: The result of `GetLLVMSubtargetInfo(triple_, "", "")->getCPU().data()` always seems to be generic, so I stuck to hardcoding that for now -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[PR] [Unity][Frontend] Add Sigmoid and Square Op [tvm]
Hzfengsy opened a new pull request, #16483: URL: https://github.com/apache/tvm/pull/16483 This PR adds two new ops to the frontend: Sigmoid and Square. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org