You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2023/05/08 02:34:16 UTC
[tvm] branch unity updated (a86a6cbb61 -> 96aca9d85f)
This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a change to branch unity
in repository https://gitbox.apache.org/repos/asf/tvm.git
discard a86a6cbb61 [Unity] Fix Unary Op Legalization (#14789)
add 1a171396fa [Torch] fix typo in new_full (#14699)
add f5ab3f05eb [TIR] [Analysis] Calculate allocated memory at module level (#14711)
add 6314b256cd [ci] Add PLATFORM env var to builds (#14713)
add 486c49895d [TIR] [Hexagon] Add get_vtcm_allocation_sizes with lowering (#14720)
add 1a70083711 [microNPU][ETHOSU] Softmax int8 legalization support (#14629)
add d32dea800b [METAL] Update metal runtime to directly store kernel map (#14727)
add f9ae487aee [Keras][Bugfix] fix a bug about alpha attribute in LeakyReLU which lead to passes conflict (#14707)
add c254b75705 [AutoTVM] Added Droplet algorithm in TVM (#14683)
add 30b34d2521 [TIR] More flexible buffer compaction (#14021)
add e2e1696c74 [Relay] Handle pad value coming from Tensor instead of scalar (#14735)
add a8d26f4452 [Relay][Bugfix] Fix stride in LpPool for default (#14740)
add 9530a8de1e [PyTorch] Add aten::new_zeros (#14747)
add c1e88b365a [Relay] Simplify the square of a binomial (#14580)
add d1e1b4c8b2 [bugfix][relay] Fix alpha attribute with None in ELU (#14742)
add cc8cce50fa [TOPI] Vectorize depthwise conv2d output operator (#14519)
add 4d37a0a078 [CI] Upgrade CI (#14635)
add f1033adf04 [TIR] Keep block annotations from tensorization (#14741)
add 706a5b2dd5 [Target][Minor] Add A6000 Target Tag (#14762)
add eca6edf7fa [CI] sccache support while using ci.py under multi user environments (#14666)
add 133807fb77 [COMMUNITY] Add new key for release signing (#14772)
add aa7d2bff6b [CI] Modify test cases to accommodate the CI upgrades (#14651)
add 129492650e [Arith] Implement statistics counters for RewriteSimplifier (#14532)
add ddd2e81e49 [TVMScript] Preserve LetStmt of constants (#14531)
add a954742fba [TIR][Driver] Move ShouldAnnotateEntryFunc logic into transform (#14562)
add 6c53d85f79 [CI] Fix doc deploy issue (#14780)
add ca7c3d1066 [Runtime] Added __str__ for tvm._ffi.runtime_ctypes.TVMArray (#14775)
add 298a0a4834 [Bugfix][MetaSchedule] RPC port needs to be an integer (#14781)
add c224a12e47 [Bugfix][Codegen][CUDA] Wrong casting in ASM (#14782)
add 20ded77c25 fix: use arm on demand instead of spot (#14779)
add bf1be357ae [MetaSchedule] Clear screen only when specified (#14785)
add 571eff9223 [BugFix][Relay] fix `scatter_nd` type relation (#14773)
add c265cdae97 [TVMScript] Add `__name__` attr for parsed PrimFunc and IRModule (#14786)
add f9890335da More clear ref of thirdparty license (#14790)
add 01324ef97c [MetaSchedule] Add an API to dump a pruned database (#14783)
add e08caef289 [MetaSchedule] Enhance `tune_tir` to tune IRModule of TIR Collections (#14784)
add f7eed214d1 [MERGE] Merge main into unity 2023-05-07
add 4795988944 Use latest lint image
add e1c2ed4863 [LINT] Fix clang-format script for newest clang-format
add d837fd0738 [MERGE] Fix lint after lint image upgrade
new 96aca9d85f [Unity] Fix Unary Op Legalization (#14789)
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (a86a6cbb61)
\
N -- N -- N refs/heads/unity (96aca9d85f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
KEYS | 59 +
LICENSE | 1 +
apps/bundle_deploy/demo.cc | 2 +-
apps/bundle_deploy/test.cc | 2 +-
apps/microtvm/reference-vm/base-box-tool.py | 2 +-
.../reference-vm/base-box/base_box_setup_common.sh | 6 +-
.../src/host_driven/fvp/semihost.c | 4 +-
ci/jenkins/docker-images.ini | 20 +-
ci/jenkins/generated/arm_jenkinsfile.groovy | 27 +-
ci/jenkins/generated/cortexm_jenkinsfile.groovy | 35 +-
ci/jenkins/generated/cpu_jenkinsfile.groovy | 23 +-
ci/jenkins/generated/docker_jenkinsfile.groovy | 4 +-
ci/jenkins/generated/gpu_jenkinsfile.groovy | 37 +-
ci/jenkins/generated/hexagon_jenkinsfile.groovy | 27 +-
ci/jenkins/generated/i386_jenkinsfile.groovy | 17 +-
ci/jenkins/generated/lint_jenkinsfile.groovy | 4 +-
.../generated/minimal_cross_isa_jenkinsfile.groovy | 13 +-
ci/jenkins/generated/minimal_jenkinsfile.groovy | 13 +-
ci/jenkins/generated/riscv_jenkinsfile.groovy | 17 +-
ci/jenkins/generated/wasm_jenkinsfile.groovy | 11 +-
ci/jenkins/templates/arm_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/templates/cortexm_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/templates/cpu_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/templates/gpu_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/templates/hexagon_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/templates/i386_jenkinsfile.groovy.j2 | 1 +
.../minimal_cross_isa_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/templates/minimal_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/templates/riscv_jenkinsfile.groovy.j2 | 5 +-
ci/jenkins/templates/utils/base.groovy.j2 | 2 +-
ci/jenkins/templates/utils/macros.j2 | 11 +-
ci/jenkins/templates/wasm_jenkinsfile.groovy.j2 | 1 +
ci/jenkins/unity_jenkinsfile.groovy | 2 +-
ci/scripts/jenkins/s3.py | 5 +-
cmake/modules/contrib/VitisAI.cmake | 2 +-
docker/Dockerfile.ci_arm | 6 +-
docker/Dockerfile.ci_cortexm | 10 +-
docker/Dockerfile.ci_cpu | 15 +-
docker/Dockerfile.ci_gpu | 10 +-
docker/Dockerfile.ci_i386 | 20 +-
docker/Dockerfile.ci_jekyll | 2 +-
docker/Dockerfile.ci_lint | 15 +-
docker/Dockerfile.ci_minimal | 18 +-
docker/Dockerfile.ci_riscv | 10 +-
docker/Dockerfile.ci_wasm | 10 +-
docker/Dockerfile.conda_cpu | 2 +-
docker/Dockerfile.demo_android | 12 +-
docker/Dockerfile.demo_opencl | 2 +-
docker/Dockerfile.demo_rocm | 10 +-
docker/Dockerfile.demo_vitis_ai | 4 +-
docker/Dockerfile.docs | 2 +-
..._install_core.sh => ubuntu2004_install_core.sh} | 5 +-
docker/install/ubuntu2004_install_llvm.sh | 35 -
docker/install/ubuntu2004_install_python.sh | 2 +-
...age.sh => ubuntu2004_install_python_package.sh} | 1 -
...nstall_redis.sh => ubuntu2004_install_redis.sh} | 3 +-
...=> ubuntu2204_install_aarch64_cross_compile.sh} | 14 +-
..._install_llvm.sh => ubuntu2204_install_llvm.sh} | 38 +-
...l_llvm.sh => ubuntu2204_manual_install_llvm.sh} | 2 +-
...buntu2204_manual_install_llvm_cross_aarch64.sh} | 2 +-
docker/install/ubuntu_install_boost.sh | 6 +-
...ng_format.sh => ubuntu_install_clang_format.sh} | 6 +-
docker/install/ubuntu_install_cmake_source.sh | 3 +-
docker/install/ubuntu_install_dgl.sh | 2 +-
docker/install/ubuntu_install_emscripten.sh | 4 +-
.../install/ubuntu_install_ethosn_driver_stack.sh | 12 +-
.../install/ubuntu_install_ethosu_driver_stack.sh | 4 +-
docker/install/ubuntu_install_golang.sh | 2 +-
docker/install/ubuntu_install_jax.sh | 10 +-
docker/install/ubuntu_install_libtorch.sh | 4 +-
docker/install/ubuntu_install_llvm.sh | 26 +-
docker/install/ubuntu_install_llvm_from_source.sh | 2 +-
docker/install/ubuntu_install_onnx.sh | 4 +-
docker/install/ubuntu_install_python.sh | 8 +-
docker/install/ubuntu_install_rocm.sh | 6 +-
.../install/ubuntu_install_tensorflow_aarch64.sh | 1 +
docker/install/ubuntu_install_tflite.sh | 2 +-
docker/install/ubuntu_install_vela.sh | 2 +-
docker/install/ubuntu_install_verilator.sh | 2 +-
docker/install/ubuntu_install_zephyr.sh | 6 +-
docs/Doxyfile | 30 +-
docs/legacy_redirect.py | 4 -
gallery/how_to/deploy_models/deploy_ssd_gluoncv.py | 132 --
.../tune_conv2d_layer_cuda.py | 8 +-
.../tune_with_autoscheduler/tune_sparse_x86.py | 77 +-
.../how_to/tune_with_autotvm/tune_conv2d_cuda.py | 22 +-
gallery/how_to/work_with_relay/build_gcn.py | 66 +-
include/tvm/arith/analyzer.h | 21 +
include/tvm/auto_scheduler/transform_step.h | 2 -
include/tvm/ir/attrs.h | 1 -
include/tvm/ir/transform.h | 2 -
include/tvm/meta_schedule/database.h | 8 +-
include/tvm/node/reflection.h | 1 -
include/tvm/node/structural_hash.h | 2 -
include/tvm/runtime/container/adt.h | 3 -
include/tvm/runtime/crt/microtvm_rpc_server.h | 1 +
include/tvm/runtime/vm/vm.h | 1 -
include/tvm/target/target.h | 1 -
include/tvm/target/virtual_device.h | 1 -
include/tvm/te/schedule.h | 1 -
include/tvm/tir/analysis.h | 28 +-
include/tvm/tir/op.h | 16 +-
include/tvm/tir/transform.h | 5 +-
include/tvm/topi/transform.h | 1 -
licenses/{LICENSE.libcrc.txt => LICENSE.cnpy.txt} | 12 +-
python/tvm/_ffi/_ctypes/packed_func.py | 3 +-
python/tvm/_ffi/runtime_ctypes.py | 13 +
python/tvm/arith/analyzer.py | 10 +
python/tvm/autotvm/database.py | 2 +-
python/tvm/autotvm/env.py | 1 +
python/tvm/autotvm/graph_tuner/pbqp_tuner.py | 2 +-
python/tvm/autotvm/task/space.py | 2 +-
python/tvm/autotvm/task/topi_integration.py | 4 +
python/tvm/autotvm/tophub.py | 2 +-
python/tvm/autotvm/tuner/__init__.py | 1 +
python/tvm/autotvm/tuner/droplet_turner.py | 127 ++
python/tvm/contrib/cutlass/build.py | 2 +-
python/tvm/contrib/cutlass/gemm_operation.py | 2 +-
python/tvm/contrib/debugger/debug_executor.py | 2 +-
python/tvm/contrib/debugger/debug_result.py | 1 +
python/tvm/contrib/download.py | 1 +
.../contrib/ethosu/cascader/cascader_options.py | 1 +
python/tvm/contrib/hexagon/build.py | 1 +
python/tvm/contrib/hexagon/hexagon_profiler.py | 1 +
python/tvm/contrib/hexagon/session.py | 5 +-
python/tvm/contrib/hexagon/tools.py | 2 +-
python/tvm/contrib/pipeline_executor_build.py | 1 +
python/tvm/contrib/relay_viz/interface.py | 2 +-
python/tvm/contrib/tedd.py | 2 +-
python/tvm/contrib/torch/as_torch.py | 3 +-
python/tvm/contrib/tvmjs.py | 2 +-
python/tvm/driver/tvmc/main.py | 4 +-
python/tvm/driver/tvmc/micro.py | 1 +
python/tvm/driver/tvmc/model.py | 1 +
python/tvm/driver/tvmc/runner.py | 3 +-
python/tvm/ir/function.py | 2 +
python/tvm/meta_schedule/database/database.py | 12 +
.../feature_extractor/per_store_feature.py | 1 +
python/tvm/meta_schedule/profiler.py | 1 +
python/tvm/meta_schedule/runner/config.py | 11 +-
.../space_generator/space_generator.py | 2 +
.../meta_schedule/testing/dataset_extract_tasks.py | 2 +-
.../testing/dataset_sample_candidates.py | 2 +-
python/tvm/meta_schedule/testing/torchbench/run.py | 1 +
.../tvm/meta_schedule/testing/torchbench/utils.py | 1 +
python/tvm/meta_schedule/testing/tune_te.py | 1 -
python/tvm/meta_schedule/tir_integration.py | 71 +-
python/tvm/micro/debugger.py | 1 +
python/tvm/micro/model_library_format.py | 1 +
python/tvm/micro/project_api/client.py | 1 +
python/tvm/micro/project_api/server.py | 3 +-
python/tvm/relax/analysis/analysis.py | 2 +-
python/tvm/relax/block_builder.py | 2 +-
python/tvm/relax/frontend/torch/dynamo.py | 2 +-
python/tvm/relax/testing/relay_translator.py | 3 +-
python/tvm/relax/testing/runtime_builtin.py | 2 +
python/tvm/relax/training/trainer.py | 4 +-
python/tvm/relax/utils.py | 2 +-
.../tvm/relay/backend/contrib/ethosu/__init__.py | 1 +
.../tvm/relay/backend/contrib/ethosu/legalize.py | 5 +-
.../backend/contrib/ethosu/softmax_rewriter.py | 516 ++++++
.../relay/backend/contrib/ethosu/te/depthwise.py | 2 +-
.../backend/contrib/ethosu/te/unary_elementwise.py | 3 +-
.../backend/contrib/ethosu/tir/convolution.py | 2 +-
.../tvm/relay/backend/contrib/ethosu/tir/passes.py | 10 +-
.../backend/contrib/ethosu/tir_to_cs_translator.py | 17 +-
python/tvm/relay/backend/contrib/ethosu/util.py | 1 +
python/tvm/relay/backend/contrib/uma/api/utils.py | 1 +
python/tvm/relay/backend/contrib/uma/backend.py | 3 +-
python/tvm/relay/backend/interpreter.py | 2 +-
python/tvm/relay/dataflow_pattern/__init__.py | 2 +-
python/tvm/relay/debug.py | 2 +-
python/tvm/relay/frontend/caffe.py | 4 +-
python/tvm/relay/frontend/keras.py | 4 +
python/tvm/relay/frontend/mxnet.py | 1 +
python/tvm/relay/frontend/nnvm_common.py | 2 +-
python/tvm/relay/frontend/oneflow.py | 2 +-
python/tvm/relay/frontend/onnx.py | 4 +-
python/tvm/relay/frontend/paddlepaddle.py | 4 +-
python/tvm/relay/frontend/pytorch.py | 26 +-
python/tvm/relay/frontend/tensorflow2.py | 3 +-
python/tvm/relay/frontend/tflite.py | 3 +-
python/tvm/relay/frontend/tflite_flexbuffer.py | 1 +
python/tvm/relay/op/contrib/clml.py | 2 +-
python/tvm/relay/op/contrib/dnnl.py | 2 +-
python/tvm/relay/op/contrib/ethosu.py | 64 +-
python/tvm/relay/testing/inception_v3.py | 2 +-
python/tvm/relay/testing/tflite.py | 4 +-
python/tvm/relay/transform/recast.py | 1 +
python/tvm/rpc/client.py | 1 +
python/tvm/script/parser/ir/entry.py | 4 +-
python/tvm/script/parser/tir/entry.py | 4 +-
python/tvm/script/parser/tir/parser.py | 4 +-
python/tvm/te/hybrid/utils.py | 1 +
python/tvm/testing/aot.py | 3 +-
python/tvm/testing/plugin.py | 1 +
python/tvm/testing/utils.py | 4 +-
python/tvm/tir/analysis/analysis.py | 34 +-
python/tvm/tir/function.py | 1 +
python/tvm/tir/schedule/_type_checker.py | 1 +
python/tvm/tir/schedule/state.py | 1 +
python/tvm/tir/schedule/testing.py | 1 +
python/tvm/tir/stmt.py | 1 +
python/tvm/tir/transform/transform.py | 12 +-
python/tvm/topi/adreno/utils.py | 2 +-
python/tvm/topi/arm_cpu/bitserial_dense.py | 2 +-
python/tvm/topi/arm_cpu/depthwise_conv2d.py | 11 +-
.../topi/arm_cpu/mprofile/dsp/micro_kernel/gemm.py | 2 +-
python/tvm/topi/cuda/dense.py | 3 +-
python/tvm/topi/cuda/dense_tensorcore.py | 3 +-
python/tvm/topi/hexagon/injective.py | 4 +-
python/tvm/topi/hexagon/pad.py | 3 +-
python/tvm/topi/hexagon/slice_ops/avg_pool2d.py | 2 +-
python/tvm/topi/hexagon/slice_ops/max_pool2d.py | 2 +-
python/tvm/topi/hexagon/tensor_intrin.py | 2 +-
python/tvm/topi/hexagon/utils.py | 52 +-
python/tvm/topi/nn/depthwise_conv2d.py | 2 +-
python/tvm/topi/nn/softmax.py | 2 +-
python/tvm/topi/x86/bitserial_dense.py | 2 +-
python/tvm/topi/x86/concat.py | 2 +-
rust/.rustfmt.toml | 2 +-
src/arith/analyzer.cc | 7 +
src/arith/rewrite_simplify.cc | 35 +
src/arith/rewrite_simplify.h | 62 +-
src/driver/driver_api.cc | 11 +-
src/meta_schedule/database/database.cc | 25 +
src/meta_schedule/database/json_database.cc | 4 -
src/meta_schedule/database/memory_database.cc | 4 -
src/meta_schedule/module_equality.cc | 3 +
src/meta_schedule/module_equality.h | 1 +
src/meta_schedule/postproc/verify_vtcm_limit.cc | 44 +-
src/meta_schedule/utils.h | 16 +-
src/relay/op/nn/pad.cc | 2 +-
src/relay/op/tensor/transform.cc | 6 +-
src/relay/transforms/simplify_expr.cc | 82 +
src/runtime/crt/common/crt_runtime_api.c | 6 +-
src/runtime/metal/metal_module.h | 11 +-
src/runtime/metal/metal_module.mm | 106 +-
src/target/opt/build_metal_off.cc | 7 +-
src/target/source/codegen_cuda.cc | 4 +-
src/target/source/codegen_metal.cc | 31 +-
src/target/tag.cc | 7 +
src/tir/analysis/block_access_region_detector.cc | 10 +-
src/tir/analysis/calculate_allocated_memory.cc | 69 +-
src/tir/analysis/control_flow_graph.cc | 7 +-
src/tir/analysis/control_flow_graph.h | 6 +-
src/tir/schedule/primitive.h | 5 +-
src/tir/schedule/primitive/block_annotate.cc | 1 +
src/tir/schedule/primitive/blockize_tensorize.cc | 9 +
src/tir/transforms/compact_buffer_region.cc | 487 ++++--
src/tir/transforms/ir_utils.cc | 101 +-
src/tir/transforms/ir_utils.h | 44 +-
src/tir/transforms/lower_opaque_block.cc | 34 +-
src/tir/transforms/primfunc_utils.cc | 47 +-
src/tir/transforms/remove_no_op.cc | 18 +-
tests/cpp/llvm_codegen_test.cc | 9 +-
tests/crt/framing_test.cc | 4 +-
tests/lint/cppdocs.sh | 2 +-
tests/lint/git-clang-format.sh | 22 +-
tests/lint/pylintrc | 78 +-
tests/python/contrib/test_cudnn.py | 2 +-
tests/python/contrib/test_ethosu/test_codegen.py | 18 +
tests/python/contrib/test_ethosu/test_legalize.py | 120 ++
.../test_hexagon/test_benchmark_maxpool2d.py | 4 +-
.../test_hexagon/test_fixed_point_conversion.py | 2 +-
.../contrib/test_hexagon/test_vtcm_bandwidth.py | 2 +-
.../contrib/test_hexagon/topi/test_resize2d.py | 1 +
tests/python/frontend/caffe2/test_graph.py | 2 +-
tests/python/frontend/coreml/test_forward.py | 11 +-
tests/python/frontend/keras/test_forward.py | 34 +-
tests/python/frontend/oneflow/test_forward.py | 3 +-
.../python/frontend/oneflow/test_vision_models.py | 9 +-
tests/python/frontend/onnx/test_forward.py | 14 +-
tests/python/frontend/pytorch/test_forward.py | 48 +-
tests/python/frontend/pytorch/test_fx_quant.py | 8 +-
tests/python/frontend/tensorflow/test_forward.py | 23 +-
tests/python/frontend/tflite/test_forward.py | 14 +-
.../relay/aot/test_crt_forward_declarations.py | 2 +-
tests/python/relay/test_op_level2.py | 19 +
tests/python/relay/test_op_level3.py | 20 +
tests/python/relay/test_pass_simplify_expr.py | 99 +-
tests/python/topi/python/test_topi_math.py | 4 +-
tests/python/unittest/test_arith_domain_touched.py | 2 +-
.../python/unittest/test_autotvm_droplet_tuner.py | 57 +
tests/python/unittest/test_crt.py | 2 +-
.../test_meta_schedule_relay_integration.py | 17 +
tests/python/unittest/test_runtime_rpc.py | 1 +
...test_tir_analysis_calculate_allocated_memory.py | 69 +-
tests/python/unittest/test_tir_buffer.py | 23 -
.../python/unittest/test_tir_schedule_tensorize.py | 40 +-
.../test_tir_transform_compact_buffer_region.py | 1730 +++++++++++---------
.../unittest/test_tir_transform_remove_no_op.py | 16 +
tests/python/unittest/test_tvmscript_parser_ir.py | 1 +
tests/python/unittest/test_tvmscript_parser_tir.py | 16 +-
.../python/unittest/test_tvmscript_syntax_sugar.py | 19 +-
tests/scripts/ci.py | 1 +
tests/scripts/task_build.py | 16 +-
tests/scripts/task_config_build_arm.sh | 2 +-
tests/scripts/task_config_build_cortexm.sh | 2 +-
tests/scripts/task_config_build_i386.sh | 2 +-
.../scripts/task_config_build_minimal_cross_isa.sh | 2 +-
tests/scripts/task_config_build_riscv.sh | 2 +-
tests/scripts/task_config_build_wasm.sh | 2 +-
tests/scripts/task_python_docs.sh | 1 +
vta/python/vta/testing/simulator.py | 1 +
vta/python/vta/top/bitpack.py | 2 +-
vta/python/vta/top/graphpack.py | 2 +-
307 files changed, 4224 insertions(+), 2059 deletions(-)
copy docker/install/{ubuntu_install_core.sh => ubuntu2004_install_core.sh} (95%)
mode change 100755 => 100644
delete mode 100755 docker/install/ubuntu2004_install_llvm.sh
copy docker/install/{ubuntu_install_python_package.sh => ubuntu2004_install_python_package.sh} (99%)
mode change 100755 => 100644
copy docker/install/{ubuntu_install_redis.sh => ubuntu2004_install_redis.sh} (93%)
mode change 100755 => 100644
rename docker/install/{ubuntu1804_install_aarch64_cross_compile.sh => ubuntu2204_install_aarch64_cross_compile.sh} (65%)
rename docker/install/{ubuntu1804_install_llvm.sh => ubuntu2204_install_llvm.sh} (55%)
mode change 100755 => 100644
rename docker/install/{ubuntu1804_manual_install_llvm.sh => ubuntu2204_manual_install_llvm.sh} (94%)
rename docker/install/{ubuntu1804_manual_install_llvm_cross_aarch64.sh => ubuntu2204_manual_install_llvm_cross_aarch64.sh} (97%)
rename docker/install/{ubuntu1804_install_clang_format.sh => ubuntu_install_clang_format.sh} (88%)
mode change 100755 => 100644
delete mode 100644 gallery/how_to/deploy_models/deploy_ssd_gluoncv.py
copy licenses/{LICENSE.libcrc.txt => LICENSE.cnpy.txt} (87%)
create mode 100644 python/tvm/autotvm/tuner/droplet_turner.py
create mode 100644 python/tvm/relay/backend/contrib/ethosu/softmax_rewriter.py
create mode 100644 tests/python/unittest/test_autotvm_droplet_tuner.py
[tvm] 01/01: [Unity] Fix Unary Op Legalization (#14789)
Posted by tq...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch unity
in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 96aca9d85fd178bdfcd68ddd909d24624d286b1b
Author: Siyuan Feng <Hz...@sjtu.edu.cn>
AuthorDate: Mon May 8 10:28:33 2023 +0800
[Unity] Fix Unary Op Legalization (#14789)
This PR adds support for unary ops legalization, which is missing currently.
And clean up the test cases.
---
python/tvm/relax/transform/legalize_ops/unary.py | 13 +-
python/tvm/script/parser/core/parser.py | 15 +
.../relax/test_transform_legalize_ops_unary.py | 1251 +-------------------
3 files changed, 86 insertions(+), 1193 deletions(-)
diff --git a/python/tvm/relax/transform/legalize_ops/unary.py b/python/tvm/relax/transform/legalize_ops/unary.py
index 9d19abe16e..104a874679 100644
--- a/python/tvm/relax/transform/legalize_ops/unary.py
+++ b/python/tvm/relax/transform/legalize_ops/unary.py
@@ -21,18 +21,27 @@ from .common import _call_topi_without_attr, register_legalize
# To avoid conflict of IRModule function name and libc function name, we add
# "tir_" as the prefix of the generated PrimFunc name.
register_legalize("relax.abs", _call_topi_without_attr(topi.abs, "tir_abs"))
+register_legalize("relax.acos", _call_topi_without_attr(topi.acos, "tir_acos"))
+register_legalize("relax.acosh", _call_topi_without_attr(topi.acosh, "tir_acosh"))
+register_legalize("relax.asin", _call_topi_without_attr(topi.asin, "tir_asin"))
+register_legalize("relax.asinh", _call_topi_without_attr(topi.asinh, "tir_asinh"))
+register_legalize("relax.atan", _call_topi_without_attr(topi.atan, "tir_atan"))
+register_legalize("relax.atanh", _call_topi_without_attr(topi.atanh, "tir_atanh"))
register_legalize("relax.ceil", _call_topi_without_attr(topi.ceil, "tir_ceil"))
register_legalize("relax.cos", _call_topi_without_attr(topi.cos, "tir_cos"))
-register_legalize("relax.log", _call_topi_without_attr(topi.log, "tir_log"))
+register_legalize("relax.cosh", _call_topi_without_attr(topi.cosh, "tir_cosh"))
register_legalize("relax.exp", _call_topi_without_attr(topi.exp, "tir_exp"))
register_legalize("relax.floor", _call_topi_without_attr(topi.floor, "tir_floor"))
+register_legalize("relax.log", _call_topi_without_attr(topi.log, "tir_log"))
register_legalize("relax.negative", _call_topi_without_attr(topi.negative, "tir_negative"))
register_legalize("relax.round", _call_topi_without_attr(topi.round, "tir_round"))
register_legalize("relax.rsqrt", _call_topi_without_attr(topi.rsqrt, "tir_rsqrt"))
register_legalize("relax.sigmoid", _call_topi_without_attr(topi.sigmoid, "tir_sigmoid"))
register_legalize("relax.sign", _call_topi_without_attr(topi.sign, "tir_sign"))
-register_legalize("relax.sinh", _call_topi_without_attr(topi.sinh, "tir_sinh"))
register_legalize("relax.sin", _call_topi_without_attr(topi.sin, "tir_sin"))
+register_legalize("relax.sinh", _call_topi_without_attr(topi.sinh, "tir_sinh"))
+register_legalize("relax.square", _call_topi_without_attr(lambda x: x * x, "tir_square"))
register_legalize("relax.sqrt", _call_topi_without_attr(topi.sqrt, "tir_sqrt"))
+register_legalize("relax.tan", _call_topi_without_attr(topi.tan, "tir_tan"))
register_legalize("relax.tanh", _call_topi_without_attr(topi.tanh, "tir_tanh"))
register_legalize("relax.clip", _call_topi_without_attr(topi.clip, "tir_clip"))
diff --git a/python/tvm/script/parser/core/parser.py b/python/tvm/script/parser/core/parser.py
index 6c08680a6c..380b428c4d 100644
--- a/python/tvm/script/parser/core/parser.py
+++ b/python/tvm/script/parser/core/parser.py
@@ -687,3 +687,18 @@ class Parser(doc.NodeVisitor):
The visiting result.
"""
return _dispatch(self, "Return")(self, node)
+
+ def visit_Nonlocal(self, node: doc.Nonlocal) -> Any: # pylint: disable=invalid-name
+ """The general nonlocal visiting method.
+
+ Parameters
+ ----------
+ node : doc.Nonlocal
+ The doc AST nonlocal node.
+
+ Returns
+ -------
+ res : Any
+ The visiting result.
+ """
+ return _dispatch(self, "Nonlocal")(self, node)
diff --git a/tests/python/relax/test_transform_legalize_ops_unary.py b/tests/python/relax/test_transform_legalize_ops_unary.py
index 398fffdbdb..7d8a0fe9d7 100644
--- a/tests/python/relax/test_transform_legalize_ops_unary.py
+++ b/tests/python/relax/test_transform_legalize_ops_unary.py
@@ -15,1229 +15,98 @@
# specific language governing permissions and limitations
# under the License.
+from typing import Callable
+
+import pytest
import tvm
+from tvm import topi
import tvm.testing
from tvm.relax.transform import LegalizeOps
+import tvm.script
from tvm.script import ir as I
from tvm.script import relax as R
from tvm.script import tir as T
-def test_abs():
- # fmt: off
- @tvm.script.ir_module
- class Abs:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.abs(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), dtype="float32")) -> R.Tensor((2, 3), dtype="float32"):
- gv = R.call_tir(Expected.tir_abs, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_abs(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32"),):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.fabs(rxplaceholder[v_i0, v_i1], dtype="float32")
- # fmt: on
-
- mod = LegalizeOps()(Abs)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_abs_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Abs:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.abs(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), dtype="float32")) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_abs, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_abs(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.fabs(rxplaceholder[v_i0, v_i1], dtype="float32")
- # fmt: on
-
- mod = LegalizeOps()(Abs)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_ceil():
- # fmt: off
- @tvm.script.ir_module
- class Ceil:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.ceil(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_ceil(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.ceil(rxplaceholder[v_i0, v_i1])
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="float32")) -> R.Tensor((2, 3), dtype="float32"):
- gv = R.call_tir(Expected.tir_ceil, (x,), out_sinfo=R.Tensor((2, 3), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Ceil)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_ceil_int():
- # fmt: off
- @tvm.script.ir_module
- class Ceil:
- @R.function
- def main(x: R.Tensor((2, 3), "int32")) -> R.Tensor((2, 3), "int32"):
- gv: R.Tensor((2, 3), "int32") = R.ceil(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_ceil(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "int32"), compute: T.Buffer((T.int64(2), T.int64(3)), "int32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = rxplaceholder[v_i0, v_i1]
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="int32")) -> R.Tensor((2, 3), dtype="int32"):
- gv = R.call_tir(Expected.tir_ceil, (x,), out_sinfo=R.Tensor((2, 3), dtype="int32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Ceil)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_ceil_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Ceil:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.ceil(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_ceil(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, (m, n))
- compute = T.match_buffer(var_compute, (m, n))
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.ceil(rxplaceholder[v_i0, v_i1])
-
- @R.function
- def main(x: R.Tensor(("m", "n"), dtype="float32")) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_ceil, (x,), out_sinfo=R.Tensor((m, n), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Ceil)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_cos():
- # fmt: off
+def _test_static_shape(name: str, relax_op: Callable, te_func: Callable, dtype: str):
@tvm.script.ir_module
- class Cos:
+ class Before:
@R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.cos(x)
+ def main(x: R.Tensor((2, 3), dtype)):
+ nonlocal dtype
+ gv = relax_op(x)
return gv
@tvm.script.ir_module
class Expected:
@R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_cos, (x,), R.Tensor((2, 3), dtype="float32"))
+ def main(x: R.Tensor((2, 3), dtype)):
+ nonlocal dtype
+ gv = R.emit_te(te_func, x, primfunc_name_hint=f"tir_{name}")
return gv
- @T.prim_func
- def tir_cos(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.cos(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Cos)
+ mod = LegalizeOps()(Before)
tvm.ir.assert_structural_equal(mod, Expected)
-def test_cos_symbolic():
- # fmt: off
+def _test_symbolic_shape(name: str, relax_op: Callable, te_func: Callable, dtype: str):
@tvm.script.ir_module
- class Cos:
+ class Before:
@R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.cos(x)
+ def main(x: R.Tensor(("m", "n"), dtype)):
+ nonlocal dtype
+ gv = relax_op(x)
return gv
@tvm.script.ir_module
class Expected:
@R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_cos, (x,), R.Tensor((m, n), dtype="float32"))
+ def main(x: R.Tensor(("m", "n"), dtype)):
+ nonlocal dtype
+ gv = R.emit_te(te_func, x, primfunc_name_hint=f"tir_{name}")
return gv
- @T.prim_func
- def tir_cos(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.cos(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Cos)
+ mod = LegalizeOps()(Before)
tvm.ir.assert_structural_equal(mod, Expected)
-def test_exp():
- # fmt: off
- @tvm.script.ir_module
- class Exp:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.exp(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), dtype="float32")) -> R.Tensor((2, 3), dtype="float32"):
- gv = R.call_tir(Expected.tir_exp, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_exp(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32"),):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.exp(rxplaceholder[v_i0, v_i1], dtype="float32")
- # fmt: on
-
- mod = LegalizeOps()(Exp)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_exp_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Exp:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.exp(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), dtype="float32")) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_exp, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_exp(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.exp(rxplaceholder[v_i0, v_i1], dtype="float32")
- # fmt: on
-
- mod = LegalizeOps()(Exp)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_floor():
- # fmt: off
- @tvm.script.ir_module
- class Floor:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.floor(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_floor(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.floor(rxplaceholder[v_i0, v_i1])
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="float32")) -> R.Tensor((2, 3), dtype="float32"):
- gv = R.call_tir(Expected.tir_floor, (x,), out_sinfo=R.Tensor((2, 3), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Floor)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_floor_int():
- # fmt: off
- @tvm.script.ir_module
- class Floor:
- @R.function
- def main(x: R.Tensor((2, 3), "int32")) -> R.Tensor((2, 3), "int32"):
- gv: R.Tensor((2, 3), "int32") = R.floor(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_floor(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "int32"), compute: T.Buffer((T.int64(2), T.int64(3)), "int32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = rxplaceholder[v_i0, v_i1]
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="int32")) -> R.Tensor((2, 3), dtype="int32"):
- gv = R.call_tir(Expected.tir_floor, (x,), out_sinfo=R.Tensor((2, 3), dtype="int32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Floor)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_floor_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Floor:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.floor(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_floor(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, (m, n))
- compute = T.match_buffer(var_compute, (m, n))
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.floor(rxplaceholder[v_i0, v_i1])
-
- @R.function
- def main(x: R.Tensor(("m", "n"), dtype="float32")) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_floor, (x,), out_sinfo=R.Tensor((m, n), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Floor)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_log():
- # fmt: off
- @tvm.script.ir_module
- class Log:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.log(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_log, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_log(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.log(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Log)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_log_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Log:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.log(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_log, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_log(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.log(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Log)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_negative():
- # fmt: off
- @tvm.script.ir_module
- class Negative:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.negative(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_negative, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_negative(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = rxplaceholder[i0_1, i1_1] * T.float32(-1)
- # fmt: on
-
- mod = LegalizeOps()(Negative)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_negative_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Negative:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.negative(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_negative, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_negative(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = rxplaceholder[i0_1, i1_1] * T.float32(-1)
- # fmt: on
-
- mod = LegalizeOps()(Negative)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_round():
- # fmt: off
- @tvm.script.ir_module
- class Round:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.round(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @T.prim_func
- def tir_round(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.round(rxplaceholder[v_i0, v_i1])
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="float32")) -> R.Tensor((2, 3), dtype="float32"):
- gv = R.call_tir(Expected.tir_round, (x,), out_sinfo=R.Tensor((2, 3), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Round)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_round_int():
- # fmt: off
- @tvm.script.ir_module
- class Round:
- @R.function
- def main(x: R.Tensor((2, 3), "int32")) -> R.Tensor((2, 3), "int32"):
- gv: R.Tensor((2, 3), "int32") = R.round(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @T.prim_func
- def tir_round(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "int32"), compute: T.Buffer((T.int64(2), T.int64(3)), "int32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = rxplaceholder[v_i0, v_i1]
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="int32")) -> R.Tensor((2, 3), dtype="int32"):
- gv = R.call_tir(Expected.tir_round, (x,), out_sinfo=R.Tensor((2, 3), dtype="int32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Round)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_round_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Round:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.round(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @T.prim_func
- def tir_round(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, (m, n))
- compute = T.match_buffer(var_compute, (m, n))
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.round(rxplaceholder[v_i0, v_i1])
-
- @R.function
- def main(x: R.Tensor(("m", "n"), dtype="float32")) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_round, (x,), out_sinfo=R.Tensor((m, n), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Round)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_rsqrt():
- # fmt: off
- @tvm.script.ir_module
- class Rsqrt:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.rsqrt(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_rsqrt, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_rsqrt(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.rsqrt(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Rsqrt)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_rsqrt_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Rsqrt:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.rsqrt(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_rsqrt, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_rsqrt(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.rsqrt(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Rsqrt)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sigmoid():
- # fmt: off
- @tvm.script.ir_module
- class Sigmoid:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.sigmoid(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_sigmoid, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sigmoid(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.sigmoid(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Sigmoid)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sigmoid_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Sigmoid:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.sigmoid(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_sigmoid, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sigmoid(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.sigmoid(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Sigmoid)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sign():
- # fmt: off
- @tvm.script.ir_module
- class Sign:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.sign(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_sign(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), T_sign: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for ax0, ax1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("T_sign"):
- v_ax0, v_ax1 = T.axis.remap("SS", [ax0, ax1])
- T.reads(rxplaceholder[v_ax0, v_ax1])
- T.writes(T_sign[v_ax0, v_ax1])
- T_sign[v_ax0, v_ax1] = T.Select(T.float32(0) < rxplaceholder[v_ax0, v_ax1], T.float32(1), T.Select(rxplaceholder[v_ax0, v_ax1] < T.float32(0), T.float32(-1), T.float32(0)))
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="float32")) -> R.Tensor((2, 3), dtype="float32"):
- gv = R.call_tir(Expected.tir_sign, (x,), out_sinfo=R.Tensor((2, 3), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Sign)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sign_int():
- # fmt: off
- @tvm.script.ir_module
- class Sign:
- @R.function
- def main(x: R.Tensor((2, 3), "int32")) -> R.Tensor((2, 3), "int32"):
- gv: R.Tensor((2, 3), "int32") = R.sign(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_sign(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "int32"), T_sign: T.Buffer((T.int64(2), T.int64(3)), "int32")):
- T.func_attr({"tir.noalias": True})
- for ax0, ax1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("T_sign"):
- v_ax0, v_ax1 = T.axis.remap("SS", [ax0, ax1])
- T.reads(rxplaceholder[v_ax0, v_ax1])
- T.writes(T_sign[v_ax0, v_ax1])
- T_sign[v_ax0, v_ax1] = T.Select(T.int64(0) < T.Cast("int64", rxplaceholder[v_ax0, v_ax1]), 1, T.Select(T.Cast("int64", rxplaceholder[v_ax0, v_ax1]) < T.int64(0), -1, 0))
-
- @R.function
- def main(x: R.Tensor((2, 3), dtype="int32")) -> R.Tensor((2, 3), dtype="int32"):
- gv = R.call_tir(Expected.tir_sign, (x,), out_sinfo=R.Tensor((2, 3), dtype="int32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Sign)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sign_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Sign:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.sign(x)
- return gv
-
- @I.ir_module
- class Expected:
- @T.prim_func
- def tir_sign(var_rxplaceholder: T.handle, var_T_sign: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, (m, n))
- T_sign = T.match_buffer(var_T_sign, (m, n))
- for ax0, ax1 in T.grid(m, n):
- with T.block("T_sign"):
- v_ax0, v_ax1 = T.axis.remap("SS", [ax0, ax1])
- T.reads(rxplaceholder[v_ax0, v_ax1])
- T.writes(T_sign[v_ax0, v_ax1])
- T_sign[v_ax0, v_ax1] = T.Select(T.float32(0) < rxplaceholder[v_ax0, v_ax1], T.float32(1), T.Select(rxplaceholder[v_ax0, v_ax1] < T.float32(0), T.float32(-1), T.float32(0)))
-
- @R.function
- def main(x: R.Tensor(("m", "n"), dtype="float32")) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_sign, (x,), out_sinfo=R.Tensor((m, n), dtype="float32"))
- return gv
- # fmt: on
-
- mod = LegalizeOps()(Sign)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sin():
- # fmt: off
- @tvm.script.ir_module
- class Sin:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.sin(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_sin, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sin(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.sin(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Sin)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sin_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Sin:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.sin(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_sin, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sin(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.sin(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Sin)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sinh():
- # fmt: off
- @tvm.script.ir_module
- class Sinh:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.sinh(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), dtype="float32")) -> R.Tensor((2, 3), dtype="float32"):
- cls = Expected
- gv = R.call_tir(cls.tir_sinh, (x,), out_sinfo=R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sinh(
- rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"),
- compute: T.Buffer((T.int64(2), T.int64(3)), "float32"),
- ):
- T.func_attr({"tir.noalias": T.bool(True)})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.sinh(rxplaceholder[v_i0, v_i1])
- # fmt: on
-
- mod = LegalizeOps()(Sinh)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sinh_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Sinh:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.sinh(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(
- x: R.Tensor(("m", "n"), dtype="float32")
- ) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- cls = Expected
- gv = R.call_tir(cls.tir_sinh, (x,), out_sinfo=R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sinh(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": T.bool(True)})
- m, n = T.int64(), T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, (m, n))
- compute = T.match_buffer(var_compute, (m, n))
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[v_i0, v_i1])
- T.writes(compute[v_i0, v_i1])
- compute[v_i0, v_i1] = T.sinh(rxplaceholder[v_i0, v_i1])
- # fmt: on
-
- mod = LegalizeOps()(Sinh)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sqrt():
- # fmt: off
- @tvm.script.ir_module
- class Sqrt:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.sqrt(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_sqrt, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sqrt(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.sqrt(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Sqrt)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_sqrt_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Sqrt:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.sqrt(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_sqrt, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_sqrt(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.sqrt(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Sqrt)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_tanh():
- # fmt: off
- @tvm.script.ir_module
- class Tanh:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv: R.Tensor((2, 3), "float32") = R.tanh(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor((2, 3), "float32"):
- gv = R.call_tir(Expected.tir_tanh, (x,), R.Tensor((2, 3), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_tanh(rxplaceholder: T.Buffer((T.int64(2), T.int64(3)), "float32"), compute: T.Buffer((T.int64(2), T.int64(3)), "float32")):
- T.func_attr({"tir.noalias": True})
- for i0, i1 in T.grid(T.int64(2), T.int64(3)):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.tanh(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Tanh)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_tanh_symbolic():
- # fmt: off
- @tvm.script.ir_module
- class Tanh:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.tanh(x)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_tanh, (x,), R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_tanh(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- i0_1, i1_1 = T.axis.remap("SS", [i0, i1])
- T.reads(rxplaceholder[i0_1, i1_1])
- T.writes(compute[i0_1, i1_1])
- compute[i0_1, i1_1] = T.tanh(rxplaceholder[i0_1, i1_1])
- # fmt: on
-
- mod = LegalizeOps()(Tanh)
- tvm.ir.assert_structural_equal(mod, Expected)
-
-
-def test_clip_symbolic():
- @tvm.script.ir_module
- class Clip:
- @R.function
- def main(x: R.Tensor(("m", "n"), "float32")) -> R.Tensor(("m", "n"), "float32"):
- m = T.int64()
- n = T.int64()
- gv: R.Tensor((m, n), "float32") = R.clip(x, 5, 8)
- return gv
-
- @tvm.script.ir_module
- class Expected:
- @R.function
- def main(x: R.Tensor(("m", "n"), dtype="float32")) -> R.Tensor(("m", "n"), dtype="float32"):
- m = T.int64()
- n = T.int64()
- gv = R.call_tir(Expected.tir_clip, (x,), out_sinfo=R.Tensor((m, n), dtype="float32"))
- return gv
-
- @T.prim_func
- def tir_clip(var_rxplaceholder: T.handle, var_compute: T.handle):
- T.func_attr({"tir.noalias": True})
- m = T.int64()
- n = T.int64()
- rxplaceholder = T.match_buffer(var_rxplaceholder, [m, n], dtype="float32")
- compute = T.match_buffer(var_compute, [m, n], dtype="float32")
- for i0, i1 in T.grid(m, n):
- with T.block("compute"):
- v_i0, v_i1 = T.axis.remap("SS", [i0, i1])
- compute[v_i0, v_i1] = T.max(
- T.min(rxplaceholder[v_i0, v_i1], T.float32(8)), T.float32(5)
- )
-
- mod = LegalizeOps()(Clip)
- tvm.ir.assert_structural_equal(mod, Expected)
+@pytest.mark.parametrize(
+ "name, relax_op, te_func, dtype",
+ [
+ ("abs", R.abs, topi.abs, "float32"),
+ ("acos", R.acos, topi.acos, "float32"),
+ ("acosh", R.acosh, topi.acosh, "float32"),
+ ("asin", R.asin, topi.asin, "float32"),
+ ("asinh", R.asinh, topi.asinh, "float32"),
+ ("atan", R.atan, topi.atan, "float32"),
+ ("atanh", R.atanh, topi.atanh, "float32"),
+ ("ceil", R.ceil, topi.ceil, "float32"),
+ ("ceil", R.ceil, topi.identity, "int32"),
+ ("cos", R.cos, topi.cos, "float32"),
+ ("cosh", R.cosh, topi.cosh, "float32"),
+ ("exp", R.exp, topi.exp, "float32"),
+ ("floor", R.floor, topi.floor, "float32"),
+ ("floor", R.floor, topi.identity, "int32"),
+ ("log", R.log, topi.log, "float32"),
+ ("negative", R.negative, topi.negative, "float32"),
+ ("round", R.round, topi.round, "float32"),
+ ("round", R.round, topi.identity, "int32"),
+ ("rsqrt", R.rsqrt, topi.rsqrt, "float32"),
+ ("sigmoid", R.sigmoid, topi.sigmoid, "float32"),
+ ("sign", R.sign, topi.sign, "float32"),
+ ("sign", R.sign, topi.sign, "int32"),
+ ("sin", R.sin, topi.sin, "float32"),
+ ("sinh", R.sinh, topi.sinh, "float32"),
+ ("sqrt", R.sqrt, topi.sqrt, "float32"),
+ ("square", R.square, lambda x: topi.multiply(x, x), "float32"),
+ ("tan", R.tan, topi.tan, "float32"),
+ ("tanh", R.tanh, topi.tanh, "float32"),
+ ("clip", lambda x: R.clip(x, 5, 8), lambda x: topi.clip(x, 5, 8), "float32"),
+ ],
+)
+def test_unary_ops(name: str, relax_op: Callable, te_func: Callable, dtype: str):
+ _test_static_shape(name, relax_op, te_func, dtype)
+ _test_symbolic_shape(name, relax_op, te_func, dtype)
if __name__ == "__main__":