-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Use pre-commit (copy IREE) for linting (#1020)
This commit aligns iree-amd-aie's linting with IREE's. It copies files https://github.com/iree-org/iree/blob/main/.pre-commit-config.yaml and https://github.com/iree-org/iree/blob/main/.github/workflows/lint.yml , with the only change being a removal of basel and yml linting, as we don't have basel or yml in iree-amd-aie (and the basel linter was failing). This commit also includes the changes needed to pass the linter. Running `pre-commit run --all-files` basically did everything needed, with 2 places where a `clang-format off/on` pair was needed to avoid header rearrangement. Note to developers: if your PR fails linting after this lands, it's very easy to fix locally: `pip install pre-commit` and then run pre-commit on all or a subset of the project files.
- Loading branch information
Showing
134 changed files
with
1,038 additions
and
953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2019 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# History in iree-amd-aie: copied from IREE January 2025. | ||
# To apply fixes locally, something like the following should work | ||
# > pip-install pre-commit | ||
# > pre-commit run --all-files | ||
# Fixes of tabs (replace with space) must be done manually. | ||
|
||
name: Lint | ||
|
||
on: [pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checking out repository | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
- name: Setting up python | ||
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | ||
- name: Running pre-commit | ||
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Pre-commit (https://pre-commit.com) configuration for assorted lint checks. | ||
# | ||
# See https://pre-commit.com/hooks.html for more hooks. | ||
# | ||
# History in iree-amd-aie. January 2025: copied from IREE and trimmed down to | ||
# the subset of hooks that are relevant. | ||
|
||
exclude: "third_party/" | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
|
||
- id: check-yaml | ||
# * Extensions can't be included in the mkdocs schema, so skip checking | ||
# https://github.com/squidfunk/mkdocs-material/issues/6378 | ||
# * clang-format files use `---` to split for multiple languages, | ||
# resulting in errors like `expected a single document in the stream` | ||
exclude: "mkdocs.yml|.clang-format" | ||
|
||
- id: end-of-file-fixer | ||
exclude_types: ["image", "jupyter"] | ||
|
||
- id: trailing-whitespace | ||
exclude_types: ["image", "jupyter"] | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
name: Run Black to format Python files | ||
|
||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
# Loosely track the most recent versions in | ||
# * Runner images: https://github.com/actions/runner-images/ | ||
# * Editor extensions: https://github.com/microsoft/vscode-cpptools | ||
rev: v18.1.3 | ||
hooks: | ||
- id: clang-format | ||
name: Run clang-format on C/C++/etc. files | ||
exclude_types: ["jupyter"] | ||
|
||
- repo: https://github.com/Lucas-C/pre-commit-hooks | ||
rev: v1.5.5 | ||
hooks: | ||
- id: forbid-tabs | ||
exclude: ".gitmodules|Makefile" | ||
|
||
- repo: https://github.com/jlebar/pre-commit-hooks.git | ||
rev: f2d115a052860b09b2888b4f104be614bf3b4779 | ||
hooks: | ||
- id: do-not-submit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ git \ | |
[email protected]:nod-ai/iree-amd-aie.git # https://github.com/nod-ai/iree-amd-aie.git | ||
``` | ||
|
||
The above avoids cloning entire repo histories for submodules, and skips a few, currently, unused, | ||
The above avoids cloning entire repo histories for submodules, and skips a few, currently, unused, | ||
submodules that are nested in IREE. | ||
|
||
### Dependencies | ||
|
@@ -78,7 +78,7 @@ cmake --build <WHERE_YOU_WOULD_LIKE_TO_BUILD> | |
|
||
### Instructions | ||
|
||
The bare minimum configure command for IREE with the amd-aie plugin | ||
The bare minimum configure command for IREE with the amd-aie plugin | ||
|
||
``` | ||
cmake \ | ||
|
@@ -106,7 +106,7 @@ you can opt-out of everything (except the `llvm-cpu` backend) with | |
-DIREE_INPUT_TOSA=OFF \ | ||
-DIREE_HAL_DRIVER_DEFAULTS=OFF \ | ||
-DIREE_TARGET_BACKEND_DEFAULTS=OFF \ | ||
-DIREE_TARGET_BACKEND_LLVM_CPU=ON | ||
-DIREE_TARGET_BACKEND_LLVM_CPU=ON | ||
``` | ||
|
||
With the above you can also skip cloning the `stablehlo` and `torch-mlir` submodules/repos but in this case you will need to add | ||
|
@@ -121,14 +121,14 @@ If you're "bringing your own LLVM", i.e., you have a prebuilt/compiled distribut | |
-DIREE_BUILD_BUNDLED_LLVM=OFF | ||
``` | ||
|
||
In this case you will need `lit` somewhere in your environment and you will need to add to CMake `-DLLVM_EXTERNAL_LIT=<SOMEWHERE>` | ||
In this case you will need `lit` somewhere in your environment and you will need to add to CMake `-DLLVM_EXTERNAL_LIT=<SOMEWHERE>` | ||
(e.g., `pip install lit; SOMEWHERE=$(which lit)`). | ||
|
||
See [Bringing your own LLVM](#bringing-your-own-llvm) below for more information on using prebuilt/compiled distributions of LLVM. | ||
|
||
## Testing | ||
|
||
Lit tests (i.e., compiler tests) specific to AIE can be run with something like | ||
Lit tests (i.e., compiler tests) specific to AIE can be run with something like | ||
|
||
``` | ||
cd <WHERE_YOU_WOULD_LIKE_TO_BUILD> | ||
|
@@ -137,7 +137,7 @@ ctest -R amd-aie --output-on-failure -j 10 | |
|
||
(the `-j 10` runs `10` tests in parallel) | ||
|
||
Other tests, which run on device, are in the `build_tools` subdirectory. | ||
Other tests, which run on device, are in the `build_tools` subdirectory. | ||
See [build_tools/ci/run_all_runtime_tests.sh](build_tools/ci/run_all_runtime_tests.sh) for an example script that shows how to run all the runtime tests. | ||
|
||
## Pro-tips | ||
|
@@ -181,4 +181,3 @@ Note, this is roughly equivalent to [passing](https://github.com/nod-ai/iree-amd | |
## Architectural overview (out of date) | ||
|
||
 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.