[Core] Python tests in pytest (#25345)

## Why

IREE's Python tests run as scripts that end in `unittest.main()`, so
every test has to be a `unittest.TestCase`. Future tests may be plain
test functions, fixtures, with parametrization. pytest also runs
`unittest` classes, so making it the runner keeps all existing tests
working without changes.

## Change

- CMake: `iree_py_test` and `iree_local_py_test` run `python -m pytest
<file>`, and `ARGS` go to pytest. The new `SCRIPT` option keeps running
a file as a script, for samples and for files that pytest cannot run. 27
of the 50 registered tests now run under pytest; 23 stay scripts
- CMake passes `--log-level=DEBUG`, so a failed test still shows what it
logged
- Bazel: an `iree_py_test` macro that runs pytest, used by the tests of
`iree.core`, the profile renderer and two build scripts. pytest is added
to the Bazel pip lock
- pkgci runs the `iree.core` tests and the ONNX import test with pytest
- pytest is added to
`runtime/bindings/python/iree/runtime/build_requirements.txt`
- `pytest.ini` at the repository root, so that pytest doesn't use the
configuration of a project that contains IREE
- Four tests that relied on running as `__main__` now work under any
runner: `basic_test` and `net_test` of `iree.build`, `import_onnx_test`
and `mnist_builder_test`
- The testing guide gets a section on Python tests

---------

Signed-off-by: Tobias Fuchs <fuchs@roofline.ai>
29 files changed
tree: 311d31aa0237187a8abd7f0aa278989751f0255b
  1. .github/
  2. build_tools/
  3. compiler/
  4. core/
  5. docs/
  6. experimental/
  7. integrations/
  8. lib/
  9. llvm-external-projects/
  10. runtime/
  11. samples/
  12. tests/
  13. third_party/
  14. tools/
  15. .bazel_to_cmake.cfg.py
  16. .bazelignore
  17. .bazelrc
  18. .bazelversion
  19. .clang-format
  20. .git-blame-ignore-revs
  21. .gitattributes
  22. .gitignore
  23. .gitmodules
  24. .pre-commit-config.yaml
  25. .yamllint.yml
  26. AUTHORS
  27. BUILD.bazel
  28. CITATION.cff
  29. CMakeLists.txt
  30. configure_bazel.py
  31. CONTRIBUTING.md
  32. GOVERNANCE.md
  33. LICENSE
  34. MAINTAINERS.md
  35. MODULE.bazel
  36. pytest.ini
  37. README.md
  38. RELEASING.md
README.md

IREE: Intermediate Representation Execution Environment

IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler and runtime that lowers Machine Learning (ML) models to a unified IR that scales up to meet the needs of the datacenter and down to satisfy the constraints and special considerations of mobile and edge deployments.

See our website for project details, user guides, and instructions on building from source.

IREE Discord Status pre-commit OpenSSF Best Practices

Project news

Project status

Release status

Releases notes are published on GitHub releases.

PackageRelease status
GitHub release (stable)GitHub Release
GitHub release (nightly)GitHub Release
iree-base-compilerPyPI version
iree-base-runtimePyPI version

For more details on the release process, see https://iree.dev/developers/general/release-management/.

Build status

CI PkgCI

Nightly build status

Operating systemBuild status
LinuxCI - Linux arm64 clang
macOSCI - macOS arm64 clang

For the full list of workflows see https://iree.dev/developers/general/github-actions/.

Communication channels

Related project channels

  • MLIR topic within LLVM Discourse: IREE is enabled by and heavily relies on MLIR. IREE sometimes is referred to in certain MLIR discussions. Useful if you are also interested in MLIR evolution.

Architecture overview

IREE Architecture IREE Architecture

See our website for more information.

Presentations and talks

Community meeting recordings: IREE YouTube channel

DateTitleRecordingSlides
2025-06-10Data-Tiling in IREE: Achieving High Performance Through Compiler Design (AsiaLLVM)recordingslides
2025-05-17Introduction to GPU architecture and IREE's GPU CodeGen Pipelinerecordingslides
2025-02-12The Long Tail of AI: SPIR-V in IREE and MLIR (Vulkanised)recordingslides
2024-10-01Unveiling the Inner Workings of IREE: An MLIR-Based Compiler for Diverse Hardwarerecording
2021-06-09IREE Runtime Design Tech Talkrecordingslides
2020-08-20IREE CodeGen (MLIR Open Design Meeting)recordingslides
2020-03-18Interactive HAL IR Walkthroughrecording
2020-01-31End-to-end MLIR Workflow in IREE (MLIR Open Design Meeting)recordingslides

License

IREE is licensed under the terms of the Apache 2.0 License with LLVM Exceptions. See LICENSE for more information.