Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b47d62e
Add ruff linting to CI and pre-commit
hunhoffe Jul 24, 2026
f59ce34
Fix circular imports and unnecessary import indirection
hunhoffe Jul 24, 2026
b9c1544
Apply ruff fixes across python/iron, utils, helpers, compiler
hunhoffe Jul 24, 2026
738da91
Fix regressions from the ruff-fix pass that broke CI
hunhoffe Jul 24, 2026
beae92d
Merge remote-tracking branch 'origin/main' into add-ruff-linter-fix
hunhoffe Jul 24, 2026
7e30bc7
Fix import ordering in program.py after merge
hunhoffe Jul 24, 2026
ee0ab22
Fix test_markers.py's split_params import
hunhoffe Jul 25, 2026
2f9b9ad
Merge branch 'main' into add-ruff-linter
hunhoffe Jul 26, 2026
6c0ff3d
Merge branch 'main' into add-ruff-linter
hunhoffe Jul 27, 2026
c3e8a83
Merge branch 'main' into add-ruff-linter
hunhoffe Jul 27, 2026
8ed47ba
Merge branch 'main' into add-ruff-linter
hunhoffe Jul 28, 2026
9a3b6ee
Merge branch 'main' into add-ruff-linter
hunhoffe Jul 28, 2026
3dbc5f3
Fix reintroduced circular import in compile/utils.py
hunhoffe Jul 28, 2026
3eb8de1
Restructure to eliminate the aie.iron <-> aie.utils.compile import cycle
hunhoffe Jul 28, 2026
7a14e62
Restore missing pyright ignore comment on split aie.ir import
hunhoffe Jul 28, 2026
4151b15
Revert kernel/resolvable restructure; keep lazy-import cycle fix
hunhoffe Jul 28, 2026
6d0b943
Merge branch 'main' into add-ruff-linter
hunhoffe Jul 28, 2026
5424a4d
Merge branch 'main' into add-ruff-linter
hunhoffe Jul 29, 2026
6e38950
Merge remote-tracking branch 'origin/main' into add-ruff-linter
hunhoffe Jul 30, 2026
cb31f59
Keep ExternalFunction import lazy to avoid an import cycle
hunhoffe Jul 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/lintAndFormat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ jobs:
ln -sfn "$PWD/build/python" install/python
pyright

- name: Lint Python (ruff)
run: ruff check

- name: Analyze
id: clang-tidy-fixes
run: |
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ repos:
ironenv/.*
)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: cb8c523fd4835aba42af70f4cad5568db4df0b6c # frozen: v0.16.0
hooks:
- id: ruff-check
stages: [pre-push]

# Baseline hygiene: validators run on every commit, fixers gated to pre-push
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
Expand Down
66 changes: 0 additions & 66 deletions .pylintrc

This file was deleted.

2 changes: 2 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ declare_mlir_python_sources(AIEPythonSources.Utils
ADD_TO_PARENT AIEPythonSources
SOURCES
utils/__init__.py
utils/_log_setup.py
utils/benchmark.py
utils/config.py
utils/tensor_factory.py
utils/test.py
utils/ml.py
utils/npukernel.py
Expand Down
12 changes: 8 additions & 4 deletions python/compiler/txn2mlir/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

from aie.ir import * # pyright: ignore[reportMissingImports, reportAttributeAccessIssue]
from aie.dialects.aie import * # pyright: ignore[reportMissingImports]

import argparse

from aie.dialects.aie import (
transaction_binary_to_mlir, # pyright: ignore[reportAttributeAccessIssue]
)
from aie.ir import ( # pyright: ignore[reportMissingImports]
Context,
)


def main():
# Parse arguments
Expand All @@ -20,7 +24,7 @@ def main():
# Read the data from the file
data = args.file.read()

with Context() as ctx: # pyright: ignore[reportUndefinedVariable]
with Context() as ctx:
module = transaction_binary_to_mlir(ctx, data)

print(str(module))
56 changes: 28 additions & 28 deletions python/helpers/dialects/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,43 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import inspect
from functools import update_wrapper
from typing import Any, List, get_args, get_origin

import numpy as np
from functools import lru_cache, update_wrapper
import sys
from typing import get_args, get_origin, Any, List

from ...extras.meta import op_region_builder # pyright: ignore[reportMissingImports]
from ...extras.util import ( # pyright: ignore[reportMissingImports]
get_user_code_loc,
make_maybe_no_args_decorator,
)
from ..util import get_arg_types, NpuDType, try_convert_np_type_to_mlir_type
from ...dialects._ods_common import ( # pyright: ignore[reportMissingImports]
get_op_result_or_op_results,
)
from ...dialects.func import * # pyright: ignore[reportMissingImports]
from ...dialects.func import ( # pyright: ignore[reportMissingImports]
FuncOp,
CallOp,
FuncOp,
ReturnOp,
)
from ...ir import ( # pyright: ignore[reportMissingImports]
from ...extras.dialects.arith import ( # pyright: ignore[reportMissingImports]
ScalarValue,
index_cast,
)
from ...extras.meta import op_region_builder # pyright: ignore[reportMissingImports]
from ...extras.util import ( # pyright: ignore[reportMissingImports]
get_user_code_loc,
make_maybe_no_args_decorator,
)
from ...ir import ( # pyright: ignore[reportMissingImports] # pyright: ignore[reportMissingImports]
Context,
FlatSymbolRefAttr,
FunctionType,
IndexType,
InsertionPoint,
OpView,
IntegerType,
Operation,
OpResult,
OpView,
Type,
TypeAttr,
Value,
)
from ...extras.dialects.arith import ( # pyright: ignore[reportMissingImports]
ScalarValue,
index_cast,
)
from ...ir import ( # pyright: ignore[reportMissingImports]
IndexType,
IntegerType,
OpResult,
)
from ..util import NpuDType, get_arg_types, try_convert_np_type_to_mlir_type


def call(
Expand Down Expand Up @@ -139,17 +136,20 @@ def call(


def isalambda(v):
LAMBDA = lambda: 0
# A `def` here would defeat the check: Python only assigns the literal
# name "<lambda>" to actual lambda expressions, not to `def`s.
LAMBDA = lambda: 0 # noqa: E731

return isinstance(v, type(LAMBDA)) and v.__name__ == LAMBDA.__name__


def prep_func_types(sig, return_types):
assert not (
not sig.return_annotation is inspect.Signature.empty and len(return_types) > 0
), f"func can use return annotation or explicit return_types but not both"
sig.return_annotation is not inspect.Signature.empty and len(return_types) > 0
), "func can use return annotation or explicit return_types but not both"
return_types = (
sig.return_annotation
if not sig.return_annotation is inspect.Signature.empty
if sig.return_annotation is not inspect.Signature.empty
else return_types
)
if not isinstance(return_types, (tuple, list)):
Expand All @@ -162,7 +162,7 @@ def prep_func_types(sig, return_types):
input_types = [
p.annotation
for p in sig.parameters.values()
if not p.annotation is inspect.Signature.empty
if p.annotation is not inspect.Signature.empty
]
# convert ndarray types to memref types
assert all(
Expand Down Expand Up @@ -233,7 +233,7 @@ def __init__(
if self._is_decl():
assert len(self.input_types) == len(
sig.parameters
), f"func decl needs all input types annotated"
), "func decl needs all input types annotated"
self.sym_visibility = "private"
self.emit()

Expand Down
19 changes: 10 additions & 9 deletions python/helpers/dialects/scf.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
# Copyright (C) 2024-2026 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import numpy as np
from contextlib import contextmanager
from typing import Sequence

from ...ir import ( # pyright: ignore[reportMissingImports]
IndexType,
InsertionPoint,
Value,
)
import numpy as np

from ...dialects.scf import ( # pyright: ignore[reportMissingImports]
IfOp,
ForOp,
IfOp,
yield_,
)
from ...extras import types as T # pyright: ignore[reportMissingImports]
from ...extras.dialects.arith import ( # pyright: ignore[reportMissingImports]
constant,
index_cast,
)
from ...extras.util import ( # pyright: ignore[reportMissingImports]
get_user_code_loc,
)
from contextlib import contextmanager
from ...extras import types as T # pyright: ignore[reportMissingImports]
from ...ir import ( # pyright: ignore[reportMissingImports]
IndexType,
InsertionPoint,
Value,
)


def _for(
Expand Down
6 changes: 6 additions & 0 deletions python/helpers/taplib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@
TensorAccessSequence,
)
from .tensortiler2d import TensorTiler2D

__all__ = [
"TensorAccessPattern",
"TensorAccessSequence",
"TensorTiler2D",
]
5 changes: 3 additions & 2 deletions python/helpers/taplib/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

from __future__ import annotations

import itertools
from copy import deepcopy
from typing import Generator, Sequence

import numpy as np
import itertools
from typing import Sequence, Generator

from .utils import (
validate_and_clean_sizes_strides,
Expand Down
Loading
Loading