8 Commits

Author SHA1 Message Date
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
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
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
Lunderberg 45497bd362 [Topi][UnitTests] Parameterize conv2d and depthwise_conv2d tests (#8433)
* [UnitTests][Topi] Updated test_topi_conv2d_nchw.py to have parametrized tests.

- Better error messages, displays which workloads/targets failed and why.

- Fixed bug in topi.nn.conv2d._get_workload exposed by the
  parametrized tests.  Incorrect padding if the "SAME" parameter is
  used with dilation>1.

- Fixed bug in tvm.topi.x86.group_conv2d._get_default_config, missing
  dilation parameter in call to _get_conv2d_workload.

* [UnitTests][Topi] Parametrized the tests in test_topi_depthwise_conv2d.py

In preparation for parametrizing to test on float16 as well.

- Single test_conv2d test with parameters for layout/input sizes.

- Extended the support for NCHWc layouts, so that they could be
  included in the parametrization.  (Implemented
  topi.testing.depthwise_conv2d_python_nchwc and
  topi.nn.scale_shift_nchwc, added layout argument to
  topi.nn.depthwise_conv2d._get_workload).

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
2021-07-22 10:26:08 +09:00
Ramana Radhakrishnan 7b898d058c Fix np.int and np.float usage in the tree. (#8389)
* Fix np.int and np.float usage in the tree.

Newer versions of numpy give loads of warnings that suggest
that np.int and np.float will be deprecated. CI uses pytest
and these warning logs clog memory for testing and make it
slower.

* Fix formatting
2021-07-02 15:28:45 -06:00
Wheest cfdbf0eaa5 Asymmetric padding and dilation in conv2d workload (#7142)
* added asymmetric padding to conv2d workload

* fixed depthwise conv2d padding

* Added fix to include dilation in workload output width calculation

* Added missing dilation to arm_cpu/conv2d_int8.py workload

* Fixed dilation for x86 conv2d

* Improved dilation workload integration in x86

* Fixed x86 conv2d_alter_op to add dilation

* Local linting not always producing same output as CI, probably my fault

* Fixed bug, tested locally

* Abusing CI until I can figure out how to reproduce the same behaviour of running integration tests locally.

* Ammeded conv2d_int8 test

* Updated workload, improved unit tests

* Added depthwise conv2d workload test
2020-12-29 15:09:47 -08:00
Jared Roesch f13fed55cf [Format] Convert all Python code w/o CI (#6448)
* Add black setup

* Tweak pyproject.toml

* Fix syntax issues

* Fix

* Tweak

* Black all Python code
2020-09-11 22:17:24 +09:00
Tianqi Chen 0a4ee30da7 [REFACTOR] topi -> tvm/topi (#6186)
This PR migrates the topi library as a sub namespace of tvm.
2020-08-02 09:29:29 -07:00