82 Commits

Author SHA1 Message Date
ConvolutedDog e7a7447929 [Fix][CI]: remove astral-sh/setup-uv from lint workflow (#19554)
This PR fixes https://github.com/apache/tvm/issues/19552.

astral-sh/setup-uv is not on the ASF GitHub Enterprise action allowlist,
causing the Lint workflow to fail with "Startup failure" before any
pre-commit checks run. See
https://github.com/apache/tvm/actions/runs/25743684906 for the failed
reason.

This PR removes the uv setup and sync steps entirely; pre-commit/action
will install and manage pre-commit and all hook dependencies on its own.
This PR also corrected previous lint errors.

After the fix, the CI lint succeeded:
https://github.com/apache/tvm/actions/runs/25775499703/job/75707088129
2026-05-13 12:28:31 +08:00
HoYi b915cac0bf [Relax][Frontend][TFLite] Add soft-NMS support for TFLite NON_MAX_SUPPRESSION_V5 (#19426)
## Summary

This PR completes the TFLite `NON_MAX_SUPPRESSION_V5` implementation in
Relax by adding support for `soft_nms_sigma != 0`.

It extends `relax.vision.non_max_suppression` with soft-NMS attributes,
updates the TFLite frontend to consume the soft-NMS outputs correctly,
and aligns the TOPI implementation with LiteRT's reference behavior.

Relates to #19412.

## Changes

1. **Relax / TOPI soft-NMS support**
- Extend `NonMaximumSuppressionAttrs` with `soft_nms_sigma` and
`score_threshold`.
- Thread the new attributes through Relax op registration, Python
wrapper, and legalization.
- Add soft-NMS handling to TOPI classic NMS so
`relax.vision.non_max_suppression` can represent the
`NON_MAX_SUPPRESSION_V5` behavior.

2. **TFLite frontend support for `NON_MAX_SUPPRESSION_V5`**
- Remove the previous `soft_nms_sigma != 0` unsupported-path guard in
the TFLite frontend.
- Forward `soft_nms_sigma` and `score_threshold` into
`relax.vision.non_max_suppression`.
- Handle the soft-NMS return path explicitly so the frontend reads
decayed scores from the processed NMS output instead of re-reading the
original score tensor.

3. **Soft-NMS correctness fixes**
- Fix the soft-NMS path so boxes whose scores fall below the threshold
after decay are invalidated consistently.
- Keep returned indices and decayed scores aligned in both the TOPI TIR
implementation and the NumPy reference implementation.
- Update the soft-NMS candidate selection logic to re-pick the current
best candidate after each decay step, matching LiteRT's
     reference behavior.
   - Align the Gaussian decay formula with LiteRT.

4. **Test coverage**
- Add Relax tests for soft-NMS struct-info inference and legalization.
- Add Relax E2E tests covering reordered outputs after score decay and
other soft-NMS follow-up cases.
- Add TFLite frontend tests for `NON_MAX_SUPPRESSION_V5` with
`soft_nms_sigma != 0`.
- Add IR checks to verify that `soft_nms_sigma` and `score_threshold`
are forwarded correctly.

## Testing

```bash
python -m pytest -n 1 tests/python/relax/test_op_vision.py -k "all_class_non_max_suppression or get_valid_counts or nms" -v
python -m pytest tests/python/relax/test_frontend_tflite.py -k "nms_v5" -v
```

## Result:
- Relax vision tests passed locally
- TFLite `NON_MAX_SUPPRESSION_V5` coverage added for both hard-NMS and
soft-NMS paths
2026-04-27 16:42:34 -04:00
Shushi Hong b6f67b06db [Docs] Add Python API reference for tvm submodule docs (#19379)
as per title
2026-04-10 14:52:49 -04:00
Soowon Jeong 2e6ee08eaf [BugFix] Align tir.round to ties-to-even across all backends (#19368)
## Problem

`tir.round` constant-folds using `std::nearbyint` (IEEE 754
ties-to-even), but all backends lower it to platform `round()` which
uses ties-away-from-zero. This means compiled code can produce different
results from constant-folded code for midpoint values:

| Input | Constant-fold (ties-to-even) | Compiled (ties-away) |
|-------|-----|------|
| 0.5   | 0.0 | 1.0  |
| 2.5   | 2.0 | 3.0  |
| -0.5  | 0.0 | -1.0 |

This was identified as a follow-up to #19367 — see [this
comment](https://github.com/apache/tvm/pull/19367#issuecomment-4201800320).

## Fix

Align all backends to use ties-to-even intrinsics, matching the
constant-folding behavior:

| Backend | Before | After |
|---------|--------|-------|
| LLVM/ROCm/Hexagon | `llvm::Intrinsic::round` |
`llvm::Intrinsic::nearbyint` |
| NVPTX | `__nv_round[f]` | `__nv_nearbyint[f]` |
| CUDA | `round`/`roundf` | `nearbyint`/`nearbyintf` (f16/bf16 already
used `hrint`) |
| Metal/OpenCL | `round` | `rint` |
| Vulkan/SPIR-V | `GLSLstd450Round` | `GLSLstd450RoundEven` |

Also fixes OpenCL codegen where `tir.nearbyint` was incorrectly mapped
to OpenCL `round()` instead of `rint()`.

Updates `op.h` documentation to explicitly state ties-to-even semantics
for both `round()` and `nearbyint()`.

## Testing

```
python -m pytest tests/python/tirx-base/test_tir_intrin.py -xvs
```

New `test_round_ties_to_even` verifies midpoint inputs `[0.5, 1.5, 2.5,
3.5, -0.5, -1.5, -2.5, -3.5]` produce ties-to-even results on the LLVM
backend. All 12 tests pass (10 passed, 2 skipped for CUDA).

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 14:35:22 -04:00
HoYi 38eb79c63f [Relax][Vision] Add get_valid_counts and classic NMS (#18943)
## Summary

Add `relax.vision.get_valid_counts` and classic
`relax.vision.non_max_suppression` for object-detection post-processing
pipelines.

`get_valid_counts` performs score-based bounding box filtering and
compacts valid boxes to the front of each batch. Classic
`non_max_suppression` performs flexible IoU-based suppression on
filtered boxes, complementing existing `all_class_non_max_suppression`
for custom post-processing workflows.

This PR implements the Relax-level registration, legalization, TOPI
compute, and test coverage for both operators.

## Changes

**Relax op registration and legalization:**
- C++ op functions, FFI registration, and struct info inference for both
operators (`vision.h`, `vision.cc`)
- Python wrappers with Relax docstrings (`vision.py`)
- Legalization to `topi.vision.get_valid_counts` and
`topi.vision.non_max_suppression`
- Additional struct-info validation for `score_index`, `id_index`, and
`coord_start` when `elem_length` is statically known

**TOPI and testing:**
- Full TOPI implementation for `get_valid_counts`
- Reimplementation of classic `non_max_suppression` in TOPI
- NumPy reference implementations in `tvm.topi.testing` for both
operators
- Op-level tests for struct info inference, legalization, invalid
attribute ranges, and e2e numerical correctness
- Stronger legalization tests that verify both `relax.call_tir`
introduction and removal of the original Relax vision op

## Limitations

- Attribute range validation for `score_index`, `id_index`, and
`coord_start` is only enforced when the input `elem_length` is
statically known during struct-info inference.
- Classic `non_max_suppression` follows the existing Relax / TOPI API
shape and is intended for single-class or class-aware custom
post-processing flows, distinct from `all_class_non_max_suppression`.

## Validation

```bash
pytest tests/python/relax/test_op_vision.py -k "get_valid_counts" -v
pytest tests/python/relax/test_op_vision.py -k "test_nms_" -v
```
All related tests passed.
2026-03-28 13:24:27 -04:00
YinHanke 1e08eb2fa9 [Relax][ONNX][Torch] Add roi_align support and frontend integration (#18936)
## Summary

Add Relax `roi_align` support and wire it through the ONNX and PyTorch
frontends.

## Changes

- add `relax.vision.roi_align`, including attrs, Python wrapper, struct
info inference, and legalization
- add TOPI `roi_align` compute and keep both legacy and aligned ROIAlign
semantics
- support ONNX `RoiAlign`, including `coordinate_transformation_mode`
handling for `output_half_pixel` and `half_pixel`
- support PyTorch `torchvision.ops.roi_align` in the exported-program
frontend, including the `aligned` flag
- add regression tests for Relax op inference, legalization, TVMScript
parsing, ONNX frontend import, and PyTorch frontend import
- add aligned ROIAlign test coverage to make sure sub-pixel RoIs no
longer use the legacy `min=1.0` clamp

## Validation

- `pytest tests/python/relax/test_op_vision.py -k roi_align`
- `pytest tests/python/relax/test_tvmscript_parser_op_vision.py -k
roi_align`
- `pytest tests/python/relax/test_frontend_onnx.py -k roi_align`
- `pytest tests/python/relax/test_frontend_from_exported_program.py -k
roi_align`

This PR completes the Relax/ONNX/Torch roi_align work tracked in #18928.
2026-03-26 10:41:54 -04:00
Tianqi Chen 9a8320acbd [LINT][PYTHON] Modernize annotations with ruff UP rules (#18830)
This PR enables ruff pyupgrade (UP) rules with py310 target, auto-fixing
~5600 annotation modernizations (PEP 585 generics, PEP 604 unions,
deprecated typing imports).

Also removes from __future__ import annotations from ir/module.py and
rmsnorm.py, bumps requires-python to >=3.10, and removes absolute_import
aliases from topi/contrib files.
2026-02-27 21:29:47 -05:00
Tianqi Chen c1d32438a0 [BugFix][TOPI] Fix resize accuracy issue with non-floor rounding (#18838)
## Summary

The int_div optimization in `topi.image.resize` was applied
unconditionally
for `nearest_neighbor` + `asymmetric` mode, regardless of rounding
method.
This caused accuracy issues when `rounding_method` is not `"floor"`
(e.g.,
`"round"`, `"round_prefer_ceil"`), because integer division truncates
toward
zero rather than rounding.

**Fix**: Gate the int_div optimization on `rounding_method == "floor"`
or
`rounding_method == ""` (the default, which gets resolved to `"floor"`
for
non-align_corners modes).

- Updates `_resize_2d` in `python/tvm/topi/image/resize.py`
- Updates reference implementation in
`python/tvm/topi/testing/resize_python.py`
- Updates legalize test expected output to reflect the new behavior
2026-02-27 11:21:16 -05:00
Tianqi Chen 33dcea1686 [REFACTOR][LINT] Modernize ruff config (#18810)
This PR removes the extra lint violations from the codebase so lint
aligns with the latest style
2026-02-23 07:29:21 -05:00
Tianqi Chen aa2e609136 [LINT] Modernize lint to use pre-commit hooks (#18807)
This PR migrates existing lint to use pre-commit hooks
2026-02-22 11:03:21 -05:00
Tianqi Chen 95d1268982 [REFACTOR] Introduce and modernize FFI system (#17920)
This PR modernizes the FFI foundation of the project and introduce
a new minimal and lightweight module [tvm ffi](https://github.com/apache/tvm/tree/refactor-s3/ffi)
based on our lessons in the past few years. It implements a modern
version of the [Unified Packed and Object RFC](https://github.com/apache/tvm-rfcs/blob/main/rfcs/0097-unify-packed-and-object.md)
that unifies the packed function call and object systems.

Summary of the change:
- A dedicated clean Any/AnyView that can store strong and weak
references of items
- Function(previously PackedFunc) system built on top of the Any/AnyView
- A minimal C API that backs the overall calls. We are stabilizing the
API with a goal to bring clean, stable FFI conventions for both compiled
and registered code
- A rewrite of core python binding and generated code based on the module
- Update existing code and test cases to the new module
- Latest dlpack support
 
The new module brings many benefits thanks to the cleaner design,
to name a few:
- Any can support both POD types(int) and object types.
- Containers (e.g. Array) can now also contain Any value, e.g. now
`Array<int>` is supported, no need for boxed types
- Error handling now upgrades to object-based, allowing cleaner
traceback across languages
- Map now preserves insertion orders
- Path toward isolated stabilize minimum core ABI/API foundation module
- Type traits based design that cleanly defines how values interact
with Any system
- Automatic conversion of different types based on traits if needed 

Because FFI upgrade is at heart of the project, the change touches every
component of the system. Importantly, this is an upgrade of the ABI so the
change is not backward compatible.  The code compiled under the old
FFI won't work under the new one. We did provide example ABI translation
(e.g. LegacyTVMArgValueToFFIAny) functions for compatibility. 
The PR tries to leave files in their old places while creating redirections.
The goal is to have the first milestone landed and infrastructure in place,
so we can do further refactors to complete features and cleanup legacy code
as trackable PRs. As of now, python binding and compiled code are under the
new convention while RPC and some  other bindings still relies on legacy ABI
translation. We will work on upgrades in the coming PRs, including areas such
as reflection, phasing out legacy redirections etc.
2025-05-06 19:18:33 -04:00
Tianqi Chen c81fccaa2f [REFACTOR] Phase out te.Schedule c++ components (#17662)
* cleanup schedule c++

* remove vitis ai

* remove VERILATOR

* remove aocl and sdaccel

* remove opengl

* remove microdev and antlr

* remove frontends

* fix

* Cleanup relay related legacy components

* fix

---------

Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
2025-02-17 17:03:09 -05:00
Tianqi Chen ccaa534b2c [REFACTOR] Phase out relay python components (#17656)
This PR starts the step 0 to phase out relay from the current
development main branch.  This PR focuses on the python
components of relay, autotvm, auto_scheduler. To make the change
manageable, we will also do followup steps on te.Schedule and
c++ components in followup PRs.

To continue support community members who depends on
legacy flows, the [v0.19.0](https://github.com/apache/tvm/tree/v0.19.0)
branch will continue contain these components.


As noted in [discussion on phasing out legacy components](https://discuss.tvm.apache.org/t/phasing-out-legacy-components/17703/30),
this would help us to do two purposes:

- By removing outdated or redundant elements, we can significantly
reduce complexity and improve maintainability.
- Unify our focus: Concentrating our efforts on the new unity flow
will allow for more efficient development and innovation.

It is also a good opportunity for us to revisit and reduce CI time.
The past relay legacy flow contains a lot of end to end tests that
requires hardware resources to run and causing long CI time.
Moving onwards, we can focus more on unit-tests that focuses
on structural equality and runs within seconds, while be mindful
about tests that requires hardware resources (by restricting them
to specific folders and CI nightly in some cases).

---

Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
2025-02-15 13:48:28 -05:00
Wuwei Lin 5d5edd2fd8 [Relax] Integrate cuDNN attention (#17157)
* [Relax] Integrate cuDNN attention

* update cmake

* lint

* lint

* cudnn frontend

* lint

* lint

* fix test

* skip test
2024-07-22 12:36:06 -07:00
Ruihang Lai b47280b1fa Merge branch 'main' into 'unity' 2024-01-06 17:19:26 -05:00
JongHewk Park d310d7db59 [TOPI] Add support for group_conv3d_transpose_ncdhw for generic (#16259)
* support generic group_conv3d_transpose

* remove new line

* try fixing ci build

---------

Co-authored-by: rebel-jonghewk <jonghewk@rebellions.ai>
2023-12-22 22:16:47 +05:30
JongHewk Park 3df798d422 [Relay][TOPI] Add support for group_conv1d_transpose_ncw for generic (#16248)
This PR adds support for group_conv1d_transpose_ncw generic.

* Merge commit '803c4ad0847f492491d8714c7ab6f52c679e6431'

* apply black format

* skip test for cuda (unimplemented)

* avoid code duplication for conv1d_transpose_ncw

* rename func & cleanup

---------

Co-authored-by: jonghewk <jonghewk@rebellions.ai>
2023-12-18 19:51:32 +05:30
Yaxing Cai 276b4cedbd [Unity][Fix] Fix topi.rms_norm with float32 upscale (#16099)
This PR is a mirror PR for #16091
2023-11-09 11:23:06 -08:00
Yaxing Cai 42de91ff45 [Fix] Fix topi.rms_norm with float32 upscale (#16091)
This PR fixes the `topi.rms_norm` with upscale to float32, for large reduction dimension of computation on float16.
2023-11-09 08:07:00 -08:00
tqchen 23edbff40a Merge remote-tracking branch 'upstream/main' into unity-staging
[MERGE] Merge main into unity 2023-08-01
2023-08-01 09:52:24 -04:00
Egor Churaev d6407bef5d [Adreno] Small fixes in Adreno schedules (#15391)
On several topologies, I faced compilation errors. This PR introduces
small fixes for these errors.
2023-07-25 12:37:02 +08:00
Junru Shao d8f1ac4e87 Merge remote-tracking branch 'apache-upstream/main' into unity 2023-07-18 14:57:34 -07:00
Yaxing Cai a13b56a945 [OP] Add rms_norm into TOPI (#15326)
This PR introduces the operator root mean square, `rms_norm`, into TOPI.
2023-07-18 11:07:58 -07:00
tqchen d159f73d2a [MERGE] Merge main into unity 2023-05-14
Merge remote-tracking branch 'upstream/main' into unity
2023-05-15 09:50:33 -04:00
Krzysztof Parzyszek 71d3262e90 [TOPI] Use f-strings for string formatting, NFC (#14839) 2023-05-13 14:33:59 -04:00
Krzysztof Parzyszek 48200fc3d7 [TOPI] Use f-strings for string formatting, NFC (#14822)
* [TOPI] Use f-strings for string formatting, NFC

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

* Format updated files
2023-05-11 16:13:10 +09:00
tqchen f762b4e833 [MERGE] Bring changes from main into unity 2023-04-12 2023-04-12 19:41:39 -04:00
Krzysztof Parzyszek 4d7e890407 [testing] Use tuples for numpy indexing (#14476)
Some versions of numpy disallow the following:

>>> import numpy as np
>>> a = np.zeros(10)
>>> b = [slice(None)]
>>> a[b]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis
(`None`) and integer or boolean arrays are valid indices

When b is a tuple, it works fine:

>>> a[tuple(b)]
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
2023-04-03 18:13:21 -07:00
Bohan Hou f67657fe09 [Unity][TOPI] fp16 LayerNorm & GroupNorm (#14264)
This pr modifies the topi implementation (which is also the legalizer's backend of Relax) of LayerNorm and GroupNorm operators to allow them to accept fp16 inputs, cast to fp32 internally, and produce fp16 outputs.

This can help eliminate unnecessary casts caused by AMP.
2023-04-01 15:31:44 -04:00
Wuwei Lin 683e7a4555 [TOPI] Add instance_norm operator (#14410) 2023-03-30 10:39:42 -04:00
Ruihang Lai baedf7f04d [TOPI] Group normalization (#14193)
As more and more ML models nowadays contain the group normalization
computation, we find it beneficial to introduce this op to TOPI level.
It will enable us to optimize the group normalization operation as a
whole in a more convenient way.

This PR introduces the group normalization op to TOPI. The group norm
operation was introduced in https://arxiv.org/abs/1803.08494. The
implementation uses tuple reduction, same as the implementation of layer
norm. Implemented with tuple reduction, the corresponding generated TIR
function can be optimized by cross-thread reduction or rfactor through
MetaSchedule.


Co-authored-by: Bohan Hou <spectrometerh@gmail.com>
2023-03-04 19:22:11 -05:00
Chaofan Lin 22c47ee6de [TOPI] Batch Norm Training Mode (#14190)
Prior to this PR, TOPI batch_norm only supports inference.

This PR adds training: bool flag and momentum: float argument to support training mode (update moving_mean / var and return), which aligns with torch.nn.functional.batch_norm.
2023-03-04 11:58:58 -05:00
Krzysztof Parzyszek da2a6379ab [Test] Make tests work with older numpy versions (#13582)
Add explicit "constant" as `mode` argument in `pad` and replace
`default_rng` with `randint`.
2022-12-09 05:25:48 +09:00
Wuwei Lin 4e783a6087 [TOPI] Add layer norm operator (#12864)
* [TOPI] Add one-pass layer norm using tuple reduction

* Add reducer pattern for LowerCrossThreadReduction

* lint

* update docs
2022-09-22 13:20:40 -07:00
Altan Haan 898946fec6 support any shape and axis for log softmax (#11951) 2022-06-30 09:43:48 +09:00
Altan Haan 32a86f8304 [TOPI] TE implementation of LSTM using scan (#11531)
* TE implementation of LSTM in TOPI

* docstring

* lint

* add injective tags where applicable
2022-06-07 10:33:21 -07:00
Ziqang XU 1aee5e1728 Complete pytorch grid_sample (#10504)
Pytorch's grid_sample() supports various interpolation options:
(1) data dimension: 2D / 3D
(2) interpolation method: nearest / bilinear / bicubic
(3) padding_mode: zeros / border / reflection
(4) align_corners: True / False

However, TVM only supports a part of above options:
(1) data dimension: 2D
(2) interpolation method: bilinear
(3) padding_mode: zeros / border
(4) align_corners: True

This commit completes the options not supported by TVM, and keeps existing
grid_sample of onnx/pytorch uninfluenced.

Co-authored-by: shukun.net
2022-04-25 17:17:49 -03:00
Leandro Nunes 89061fafa5 [CI] Bump black version to 22.3.0 (#10960)
* Make all required adjusts in the code to comply with the new version
* Upadte ci-lint to v0.71, based on tlcpackstaging/ci_lint:20220411-060305-45f3d4a52
2022-04-11 10:24:05 -07:00
Tristan Konolige 2c0a7c2a7e [TOPI] Add support for groupped conv3d (#9873)
* [TOPI] Add support for groupped conv3d

Change conv3d to use generic conv implementation which supports groupped
convolutions. Also, remove support for non-float16 tensorcore operations
as they cause large degradation in accuracy. Generic conv now supports
autoscheduler.

* correct none check

* add tests for floordiv simplification

* fixed incorrect test for autoscheduler

* formatting

* add groups to winograd

* fix tensorcore

* manually simplify index instead of relying on simplifier

* formatting

* add groups argument to conv3d_ncdhw_winograd_without_weight_transform

* formatting
2022-02-19 06:18:01 +09:00
Mei Ye 98fcca1720 Support PyTorch grid_sample (#10184)
* [relay] Fix stack overflow in device_planner observed on windows due to recursive function calls.

* Revert "[relay] Fix stack overflow in device_planner observed on windows due to recursive function calls."

This reverts commit 70581364771e2415b37b202a9fa6a937f275cfc6.

* [PyTorch] Add grid_sample with zeros and border padding mode for PyTorch.
2022-02-08 14:57:15 +09:00
Masahiro Masuda 7fd73b2663 [CUTLASS] Initial support for conv2d wgrad (#10177)
* [CUTLASS] Add wgrad support (without split-k)

* run black

* wgrad tests now work under pytest

* dw conv2d properly supported for wgrad

* all tests work

* fixed for sm75

* cpplint

* fix conv2d grad test
2022-02-08 10:28:20 +09:00
Masahiro Masuda d35b858ceb [CUDNN] Support gradient kernels (#9986)
* Dgrad nchw, nhwc, fp16 working

commit 426e5dca446a27da49270f45171b58f1bfa21fa9
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 11:48:53 2022 +0900

    black

commit 211a58b80f4d0f0b5b0230720e41f35e50cb1eaf
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 11:43:52 2022 +0900

    fp16 also works

commit c2a34d473b063873628bff00e51a44cd8e4d0e4f
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 11:36:36 2022 +0900

    nhwc test also worked

commit c0609ab147fef30c230a94d16b6c1ba35f7dd9c0
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 11:21:23 2022 +0900

    nchw test worked

commit 2bf68c72763708151e9f49f09916a210b2547be8
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 10:41:35 2022 +0900

    add test stub

commit c86b1288d5e371f12cba4e1b1866966cb9264401
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 10:32:09 2022 +0900

    add python definition stub

commit 3166952f9673376801bf4b5b39eeb6f89452f30a
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 06:57:18 2022 +0900

    bwd filter compiled

commit e311ba3d05c5f9424ecb952cb5a520ce81a0828a
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 06:27:55 2022 +0900

    dgrad compiled

commit 47f35beb5eeeb7cbf9f6ec7cf8f5c80c65e8da46
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Jan 18 06:16:43 2022 +0900

    add dgrad stub

commit ebed032d15b1c3895f541c46ce5d80b6dd769034
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Mon Jan 17 17:01:56 2022 +0900

    cpplint

commit 834f54a8c13512130e7d91ca0f54268dc06c5481
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Mon Jan 17 16:55:58 2022 +0900

    remove cudnn get output

commit dcbd9c95fdb8ffef9db9c2350430b270461a31c3
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Mon Jan 17 16:28:07 2022 +0900

    more refactor

commit 146464e8496fff972bdb1687c4e9d432fe3278d5
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Mon Jan 17 15:57:35 2022 +0900

    Introduce SetConvdescriptors to refactor cudnn/conv_forward.cc

* add python function for cudnn wgrad

* adding wgrad test

* black

* wgrad nchw and nhwc worked

* remove bwd algo name stuff

* compute output shape properly

* swap arg order in wgrad

* add kernel size arg in test

* black

* cleanup

* more fix

* fix dgrad test

* support running relay conv2d_backward_weight directly with cudnn

* black

* refactor reference function to support nhwc

* removed unused function

* lint

* enable offloading conv2d_transpose to cudnn dgrad

* relax tol

* name fix, remove print
2022-01-23 06:58:31 +09:00
Masahiro Masuda fd5915a098 [Relay] Add conv2d_backward_weight op (without topi) (#9954)
* python plumbing

* add cpp def

* legalize worked

* clean up

* layout conversion doesnt work

* extract wgrad body

* fix convert layout

* black

* fix kernel size

* revert irrelevant change

* add doc, clarify the meanings of parameters

* update layout convert

* test passed

* fixed layout conversion

* update convert layout

* remove print

* remove layout convert for now

* minor fix

* removed unused import

* add wgrad python reference

* add test stub

* add doc

* test other stride and pad

* tweak

* more pylint filter

* fix typo in doc

* swap arg order (data, grad) to be consistent with conv2d_transpose(dgrad)
2022-01-20 04:10:36 +09:00
Tristan Konolige f6f252f0ab [TOPI] Support grouped conv1d (#9832)
* [TOPI] Support grouped conv1d

Generalize the conv2d compute statement to a generic convNd that
supports any layout and groups. Replace some existing conv2d and conv1d
compute statements with this generic compute. Also add a topi
group_conv1d compute that uses the generic convNd compute. Existing
schedules for conv1d work with group_conv1d, so they are reused.

* permute reduction axis order

* formatting
2022-01-07 16:27:42 -07:00
Michal Piszczek cb34604602 [TOPI] Add generic batch norm (#9694)
* Add topi batch norm and tests

* Handle none values correctly

* Return correct nun outputs for onnx

* Use moving var/mean and update tests

* Add a test for batch norm folding

* Fix comment

* Format with black

* Re-order test args to match interface

* Call fold constant manually
2021-12-13 09:00:22 -07:00
Ligeng Zhu 3ad7c4a769 [Conv2DTransposed] Fix wrong shape check and add new TOPI module to support groups (#9465)
* f wrong type check in conv2d_transpose

* add test case for conv2d transpose

* add groups support for conv2d_transpose

* add  naive implementation and schedule for conv2d with groups

* enable tests for cpu and arm_cpu, raise error for cuda platform

* revert the cuda and generic strategy

* revert back the x86 strategy

* revert back the arm_cpu strategy

* revert back the arm_cpu strategy

* revert back the arm_cpu strategy

* fix EOF of x86

* clang lint updated c++ code

* update topi implementation

* Revert test

* Revert test

* add generic/x86/arm specialization for conv2d_transpose with groups > 1

* remove commentted codes

* fix lint

* fix lint

* fix c++ lint

* fix lint

* fix python lint

* remove comments and reformat

* lint file

* lint code

* fix lint

* update logging information in convolution.h

Co-authored-by: Alicja Kwasniewska <alicja.kwasniewska@sima.ai>
2021-11-12 09:05:39 -08:00
masahi 9cf0245adb [Relay, TOPI] Add searchsorted op (#9184)
* Add relay definition

* 1D cpu test working

* multi dim working

* gpu version working

* check shape in type rel

* support side

* use target specfic max threads

* add relay boilerplate

* relay test working

* cleanup topi test

* fix test

* add torch converter

* handle other cases

* more topi test

* support torch bucketize

* update doc

* fix tests

* fix lint

* rebase fix

* make the test case smaller

* add tests for edge cases

* replace "side" attribute with boolean "right"

* add more descrition to binear_search IR gen params

* return index from binary_search rather than update inplace

* remove unused argument

* format fix
2021-10-20 18:19:36 -04:00
Lunderberg bf3669d3e3 [Topi][Testing] Float16 unittests for dense, conv2d, depthwise conv2d (#8529)
* [Topi][Testing] Minor cleanup for python reference implementations

- Use input dtype for dilate/conv2d accumulate in python
  impl. Previously, the python implementations of dilation and conv2d
  would use numpy default dtype in some cases, rather than the input
  data's dtype.

- Added fallback for datatypes not supported by scipy.signal.convolve2d (e.g. float16).

- Refactored to avoid duplication, use common get_pad_tuple functionality.

* [Topi][UnitTests] Added float16 tests to test_topi_dense.py

* [Topi][UnitTests] Added float16 to test_topi_conv2d_nchw.py

* [Topi][Float16] Added float16 tests for depthwise conv2d.

* [UnitTests] Explicitly set seed for float16 tests

Intended to avoid flaky test failures later due to rounding errors.

* [UnitTests] Fixed a few failing unit tests.

- ref_data must be a test fixture, not acquired through
  request.getfixturevalue, in order to have the random_seed be known.

- dilate_python's return value didn't follow `out_dtype`.

- The test_topi_conv3d tests had the reference results computed in
  float64, due to dilate_python() not respecting the input data type.
  With the correct dtype, the tolerances needed to be slightly widened.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
2021-08-07 11:26:22 +09:00
Matthew Brookhart 22c7d6107f speed up reference resize kernel (#8592) 2021-07-30 09:49:19 -04:00
Chenfan 850abb0c01 [TOPI] Add transpose_a/b & dynamic shape support for batch matmul (#8527)
* Add basic support for batch matmul transpose

* Update

* Lint fix & add tf convert support

* Update

Lint fix

* Bug fix for qnn.batch_matmul

* Bug fix for tensorflow test

* Add grad support for batch_matmul

* Lint fix

Re-triggle CI

Bug fix

Re-triggle CI

Re-triggle CI

Re-triggle CI
2021-07-29 10:15:21 -07:00