Skip to content

Commit 31360ab

Browse files
authored
Merge cea717f into 0c0eaee
2 parents 0c0eaee + cea717f commit 31360ab

65 files changed

Lines changed: 204 additions & 3548 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ python scripts/clang-format-wrapper.py --diff
108108
python scripts/clang-format-wrapper.py --fix
109109

110110
# Format specific directory
111-
python scripts/clang-format-wrapper.py --fix --path aie_kernels/
111+
python scripts/clang-format-wrapper.py --fix --path iron/
112112
```
113113

114114
### License Compliance (REUSE)
@@ -129,8 +129,9 @@ reuse lint
129129
- `reference.py`: CPU reference implementation for validation
130130
- `test.py`: End-to-end test (build, run, verify against reference)
131131

132-
2. **AIE Kernels** (`aie_kernels/`)
133-
- Architecture-specific C++ compute kernels:
132+
2. **AIE Kernels** ([mlir-aie `aie_kernels/`](https://github.com/Xilinx/mlir-aie/tree/main/aie_kernels))
133+
- Architecture-specific C++ compute kernels, sourced from the installed
134+
mlir-aie package (`AIEContext.kernels_dir`), not from this repo:
134135
- `generic/`: Works on both AIE2 and AIE2P
135136
- `aie2/`: AIE2-specific (NPU1)
136137
- `aie2p/`: AIE2P-specific (NPU2)
@@ -250,7 +251,9 @@ Data movement pattern: L3 → Shim DMA → L2 → L1 (tile local) → Compute
250251
- Define function that builds MLIR-AIE design
251252
- Use `range_()` for loops (not Python `range`)
252253
- Handle device-specific logic (NPU1 vs NPU2) if needed
253-
4. Implement C++ kernel in `aie_kernels/<arch>/` if needed
254+
4. If a new C++ compute kernel is needed, add it to the
255+
[mlir-aie kernel library](https://github.com/Xilinx/mlir-aie/tree/main/aie_kernels)
256+
and consume it via `AIEContext.kernels_dir`; IRON no longer hosts kernels
254257
- Choose appropriate directory: `generic/`, `aie2/`, or `aie2p/`
255258
- Use AIE API for portable vectorization when possible
256259
- Add `event0()` and `event1()` for performance profiling
@@ -450,7 +453,8 @@ logging.basicConfig(level=logging.DEBUG)
450453

451454
**"Kernel not found" or "Symbol not defined"**
452455

453-
- Verify kernel `.cc` file is in correct `aie_kernels/<arch>/` directory
456+
- Verify the kernel `.cc` exists under the installed mlir-aie package's
457+
`include/aie_kernels/<arch>/` (`AIEContext.kernels_dir`)
454458
- Check `get_kernel_artifacts()` in `op.py` references correct kernel path
455459
- Ensure kernel function signature matches `Kernel()` declaration in `design.py`
456460

@@ -499,7 +503,7 @@ Full LLM inference example at `iron/applications/llama_3.2_1b/`:
499503

500504
### AIE Kernel Reference
501505

502-
See `aie_kernels/README.md` for catalog of available kernels:
506+
See the [mlir-aie kernel library README](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/README.md) for the catalog of available kernels:
503507

504508
- Element-wise ops (add, mul, scale)
505509
- Matrix operations (mm, mv)

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,31 @@ The IRON Python API for Ryzen™ AI NPUs is described in the following paper:
4242

4343
| Section | Description | Datatype | AIE2 | AIE2P | Status | Design Example |
4444
|:--------|:------------|:---------|:-----|:------|:-------|:-------------|
45-
| [Element-wise Add](./aie_kernels/generic/add.cc) | Element-wise addition kernel | bfloat16 ||| 🟢 | [iron/operators/elementwise_add/](./iron/operators/elementwise_add/) |
46-
| [Element-wise Mul](./aie_kernels/generic/mul.cc) | Element-wise multiplication kernel | bfloat16 ||| 🟢 | [iron/operators/elementwise_mul/](./iron/operators/elementwise_mul/) |
47-
| [GEMM](./aie_kernels/aie2p/mm.cc) | General Matrix Multiplication kernel | bfloat16 ||| 🟢 | [iron/operators/gemm/](./iron/operators/gemm/) |
48-
| [GEMV](./aie_kernels/generic/mv.cc) | General Matrix-Vector Multiplication kernel | bfloat16 ||| 🟢 | [iron/operators/gemv/](./iron/operators/gemv/) |
49-
| [GQA](./aie_kernels/aie2p/mha.cc) | Grouped Query Attention kernel (Single pipeline) | bfloat16 | || 🟢 | [iron/operators/mha/](./iron/operators/mha/) |
50-
| [MHA](./aie_kernels/aie2p/mha.cc) | Multi-Head Attention kernel & Grouped Query Attention | bfloat16 | || 🟢 | [iron/operators/mha/](./iron/operators/mha/) |
51-
| [RMSNorm](./aie_kernels/aie2/rms_norm.cc) | RMSNorm kernel | bfloat16 ||| 🟢 | [iron/operators/rms_norm/](./iron/operators/rms_norm/) |
52-
| [RoPE](./aie_kernels/generic/rope.cc) | Rotary Positional Embedding kernel | bfloat16 ||| 🟢 | [iron/operators/rope/](./iron/operators/rope/) |
53-
| [SiLU](./aie_kernels/aie2/silu.cc) | Sigmoid Linear Unit activation kernel | bfloat16 ||| 🟢 | [iron/operators/silu/](./iron/operators/silu/) |
54-
| [Softmax](./aie_kernels/aie2/softmax.cc) | Softmax kernel | bfloat16 ||| 🟢 | [iron/operators/softmax/](./iron/operators/softmax/) |
55-
| [Weighted RMSNorm](./aie_kernels/aie2/rms_norm.cc) | Weighted RMSNorm kernel | bfloat16 ||| 🟢 | [iron/operators/rms_norm/](./iron/operators/rms_norm/) |
56-
| [Copy](./aie_kernels/generic/passThrough.cc) | Copy | bfloat16 ||| 🟢 | [iron/operators/mem_copy/](./iron/operators/mem_copy/) |
57-
| [Transpose](./aie_kernels/generic/transpose.cc) | Transpose | bfloat16 ||| 🟢 | [iron/operators/transpose/](./iron/operators/transpose/) |
58-
| [AXPY](./aie_kernels/generic/axpy.cc) | AXPY | bfloat16 ||| 🟢 | [iron/operators/axpy/](./iron/operators/axpy/) |
45+
| [Element-wise Add](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2p/add.cc) | Element-wise addition kernel | bfloat16 ||| 🟢 | [iron/operators/elementwise_add/](./iron/operators/elementwise_add/) |
46+
| [Element-wise Mul](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2p/mul.cc) | Element-wise multiplication kernel | bfloat16 ||| 🟢 | [iron/operators/elementwise_mul/](./iron/operators/elementwise_mul/) |
47+
| [GEMM](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2p/mm.cc) | General Matrix Multiplication kernel | bfloat16 ||| 🟢 | [iron/operators/gemm/](./iron/operators/gemm/) |
48+
| [GEMV](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/generic/mv.cc) | General Matrix-Vector Multiplication kernel | bfloat16 ||| 🟢 | [iron/operators/gemv/](./iron/operators/gemv/) |
49+
| [GQA](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2p/mha.cc) | Grouped Query Attention kernel (Single pipeline) | bfloat16 | || 🟢 | [iron/operators/mha/](./iron/operators/mha/) |
50+
| [MHA](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2p/mha.cc) | Multi-Head Attention kernel & Grouped Query Attention | bfloat16 | || 🟢 | [iron/operators/mha/](./iron/operators/mha/) |
51+
| [RMSNorm](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2p/rms_norm.cc) | RMSNorm kernel | bfloat16 ||| 🟢 | [iron/operators/rms_norm/](./iron/operators/rms_norm/) |
52+
| [RoPE](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/generic/rope.cc) | Rotary Positional Embedding kernel | bfloat16 ||| 🟢 | [iron/operators/rope/](./iron/operators/rope/) |
53+
| [SiLU](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/silu.cc) | Sigmoid Linear Unit activation kernel | bfloat16 ||| 🟢 | [iron/operators/silu/](./iron/operators/silu/) |
54+
| [Softmax](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/softmax.cc) | Softmax kernel | bfloat16 ||| 🟢 | [iron/operators/softmax/](./iron/operators/softmax/) |
55+
| [Weighted RMSNorm](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2p/rms_norm.cc) | Weighted RMSNorm kernel | bfloat16 ||| 🟢 | [iron/operators/rms_norm/](./iron/operators/rms_norm/) |
56+
| [Copy](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/generic/passThrough.cc) | Copy | bfloat16 ||| 🟢 | [iron/operators/mem_copy/](./iron/operators/mem_copy/) |
57+
| [Transpose](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/generic/transpose.cc) | Transpose | bfloat16 ||| 🟢 | [iron/operators/transpose/](./iron/operators/transpose/) |
58+
| [AXPY](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/generic/axpy.cc) | AXPY | bfloat16 ||| 🟢 | [iron/operators/axpy/](./iron/operators/axpy/) |
5959
| [Reduction]() | Reduction | bfloat16 | | | 🟡 | |
60-
| [Dequant](./aie_kernels/generic/expand.cc) | Dequant Q4NX from [AWQ](https://github.com/mit-han-lab/llm-awq) to bfloat16 | bfloat16 ||| 🟢 | [iron/operators/dequant/](./iron/operators/dequant/) |
61-
| [RELU](./aie_kernels/aie2/relu.cc) | RELU | bfloat16 ||| 🟢 | [iron/operators/relu/](./iron/operators/relu/) |
62-
| [Leaky RELU](./aie_kernels/aie2/leaky_relu.cc) | Leaky RELU | bfloat16 ||| 🟢 | [iron/operators/leaky_relu/](./iron/operators/leaky_relu/) |
63-
| [GELU](./aie_kernels/aie2/gelu.cc) | GELU | bfloat16 ||| 🟢 | [iron/operators/gelu/](./iron/operators/gelu/) |
64-
| [LayerNorm](./aie_kernels/aie2/layer_norm.cc) | LayerNorm | bfloat16 ||| 🟢 | [iron/operators/layer_norm/](./iron/operators/layer_norm/) |
60+
| [Dequant](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/generic/expand.cc) | Dequant Q4NX from [AWQ](https://github.com/mit-han-lab/llm-awq) to bfloat16 | bfloat16 ||| 🟢 | [iron/operators/dequant/](./iron/operators/dequant/) |
61+
| [RELU](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/relu.cc) | RELU | bfloat16 ||| 🟢 | [iron/operators/relu/](./iron/operators/relu/) |
62+
| [Leaky RELU](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/leaky_relu.cc) | Leaky RELU | bfloat16 ||| 🟢 | [iron/operators/leaky_relu/](./iron/operators/leaky_relu/) |
63+
| [GELU](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/gelu.cc) | GELU | bfloat16 ||| 🟢 | [iron/operators/gelu/](./iron/operators/gelu/) |
64+
| [LayerNorm](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/layer_norm.cc) | LayerNorm | bfloat16 ||| 🟢 | [iron/operators/layer_norm/](./iron/operators/layer_norm/) |
6565
| [Convolution]() | Convolution | bfloat16 | | | 🟡 | |
6666
| [MaxPool]() | MaxPool | bfloat16 | | || |
6767
| [AveragePool]() | AveragePool | bfloat16 | | || |
68-
| [Tanh](./aie_kernels/aie2/tanh.cc) | Tanh kernel | bfloat16 ||| 🟢 | [iron/operators/tanh/](./iron/operators/tanh/) |
69-
| [Sigmoid](./aie_kernels/aie2/sigmoid.cc) | Sigmoid kernel | bfloat16 ||| 🟢 | [iron/operators/sigmoid/](./iron/operators/sigmoid/) |
68+
| [Tanh](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/tanh.cc) | Tanh kernel | bfloat16 ||| 🟢 | [iron/operators/tanh/](./iron/operators/tanh/) |
69+
| [Sigmoid](https://github.com/Xilinx/mlir-aie/blob/main/aie_kernels/aie2/sigmoid.cc) | Sigmoid kernel | bfloat16 ||| 🟢 | [iron/operators/sigmoid/](./iron/operators/sigmoid/) |
7070

7171
> Use this dashboard to quickly check the status of each kernel and locate relevant setup, build, and usage information.
7272
@@ -134,7 +134,7 @@ If starting from `Ubuntu 24.04` you may need to update the Linux kernel to 6.11+
134134
All available operators can be found in `iron/operators`. These each contain:
135135

136136
- `op.py`: The Python operator interface -- an easy access point to integrate operators into your project that prescribes how to compile the operator (build artifacts) and how to call it at runtime (buffer sizes, etc.)
137-
- `design.py`: The implementation of the operator's NPU code. Often references a kernel in `aie_kernels` for the compute core code and describes the data movement using ObjectFIFOs.
137+
- `design.py`: The implementation of the operator's NPU code. Often references a C++ compute kernel from the [mlir-aie kernel library](https://github.com/Xilinx/mlir-aie/tree/main/aie_kernels) for the compute core code and describes the data movement using ObjectFIFOs.
138138
- `reference.py`: A reference CPU implementation to validate the correctness of the NPU implementation.
139139
- `test.py`: An end-to-end test that instantiates and builds the operator, runs it and verifies its outputs against the reference.
140140
@@ -196,7 +196,7 @@ IRON uses a three-layer architecture:
196196
1. **Operators** (`iron/operators/`): High-level Python API for NPU operations
197197
- Each operator has: `op.py` (interface), `design.py` (MLIR-AIE implementation), `reference.py` (CPU reference), `test.py` (validation)
198198

199-
2. **AIE Kernels** (`aie_kernels/`): Low-level C++ compute kernels
199+
2. **AIE Kernels** ([mlir-aie `aie_kernels/`](https://github.com/Xilinx/mlir-aie/tree/main/aie_kernels)): Low-level C++ compute kernels
200200
- Organized by architecture: `generic/`, `aie2/`, `aie2p/`
201201
- Vectorized using AIE API for optimal performance
202202

@@ -226,7 +226,7 @@ pytest iron/operators/ -m "not extensive" -v
226226
- 💬 **Discord**: Join our [Discord server](https://discord.gg/cW99Ds85e8) for discussions and support
227227
- 🐛 **Issues**: Report bugs and request features via [GitHub Issues](https://github.com/amd/iron/issues)
228228
- 📖 **Contributing**: See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines
229-
- 📚 **Documentation**: Operator examples in `iron/operators/`, kernel docs in `aie_kernels/README.md`
229+
- 📚 **Documentation**: Operator examples in `iron/operators/`, kernel docs in the [mlir-aie kernel library](https://github.com/Xilinx/mlir-aie/tree/main/aie_kernels)
230230

231231
## License
232232

aie_kernels/README.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

aie_kernels/aie1/.gitkeep

Whitespace-only changes.

aie_kernels/aie2/aie2_math.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)