11 Commits

Author SHA1 Message Date
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 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
Eric Lunderberg d030ce27a1 [TVMScript] Optionally use ruff format instead of black (#16876)
* [TVMScript] Optionally use `ruff format` instead of `black`

The `ruff format` tool is significantly faster than the `black`
formatter.  For some particularly long TVMScript modules, using it can
reduce the time required to show a formatted module from ~5 minutes to
~1 minute.  This commit updates the `.show()` function to apply the
optionally formatting using `ruff format` if available, falling back
to `black` otherwise.

* Fix lint error
2024-04-17 10:34:10 +05:30
Siyuan Feng 7322769474 [TVMScript] Disable black_format by default (#15706)
`Black` is a popular code formatter for Python. However, it is not
suitable for TVM script. This PR tries to disable it by default.
2023-09-08 18:07:12 -07:00
Siyuan Feng 4daf38f691 [TVMScript] Robustify the Highlight Printer (#13861)
Current `cprint` allows `PrimFunc` and `IRModule` as input. However,
after the fragment printing enabled by @junrushao, we can make it robust
to support any Objects that have method `script`
2023-01-30 22:49:47 -08:00
Hongyu Cai dc3fc36d0b [TVMScript] More accurate hints for ImportError (#13662) 2022-12-28 20:10:50 +09:00
Eric Lunderberg e2fc4d7e98 [TVMScript] Improvements tvm.script.highlight (#13438)
* [TVMScript] Improvements tvm.script.highlight

- Automatically use "black" formatter if available.

- Allow overrides of pygmentize style based on environment variable
  `TVM_PYGMENTIZE_STYLE`.

- Forwarded `black_format` argument from `show` method to `cprint`
2022-11-22 18:52:31 -08:00
Junru Shao 3b3443bd12 [TIR][Schedule][UX] Beautify TIR Trace Printing (#12507)
Following https://github.com/apache/tvm/pull/12197, this PR introduces
`Schedule.show()` which convenience the user experience in the following
two aspects:
- Python syntax highlighting
- Outputs a schedule function instead of standalone instructions so that
it's easier to follow.

To demonstrate this change:
- Before `Schedule.show()` is introduced:
<img width="555" alt="image" src="https://user-images.githubusercontent.com/22515877/185713487-03722566-1df7-45c7-a034-c1460d399681.png">

- After this change:
<img width="583" alt="image" src="https://user-images.githubusercontent.com/22515877/185713564-c54f3a9d-cd52-4709-a8b8-d8a61361e611.png">
2022-08-20 18:10:19 -04:00
Jiawei Liu e756980b41 [UX][TVMSciprt] Use HTML formatter in notebook environments (#12240)
Previously we use ANSI color sequences to highlight TVM script. In jupyter notebook environments, such color sequence will be recoginized and translated to corresponding HTML to display things. 

This works fine for most notebook environments (including the jupyter notebook and the VS Code plugin). Recently, thanks to @tqchen, we found that Google Colab does not well support ansi color sequence for 24-bit colors (`JupyterLight` and `VSCDark`) that all its displayed colors are unexpectedly black/gray/white. To also bring highlighting in Colab, in this PR, we directly render the highlighted code with HTML when a notebook environment is detected.
2022-07-30 14:33:45 -07:00
Jiawei Liu d19570fb23 [UX] highlight tvm script (#12197)
* feat(ux): highlight tvm script

* resolve dependency

* refact(tvmscript): highlight fallback as plain text with warning; put ansi colors as default terminal style

* refact(tvmscript): make terminal style close to the default notebook style

* fix(pylint): disable=import-outside-toplevel

* fix(ci-dep): Pygments>=2.4.0 to support ansicolors w/o #

* refact: making Pygments versioning most robust and user-friendly

* fix: pylint var naming
2022-07-29 10:50:00 -07:00