Skip to content

Commit 0a6c11c

Browse files
authored
Unify Operators using Python Interface, Remove CMake (#37)
* separate runtime and artifact setup * start on refactoring operators from CMake to Python * operators up to GEMM migrated (dequant missing); fixed timing issue in Python (missing warmup iterations); merge Curt's GEMM fixes * more fixes; remove old moved operators * [wip] tests with default parameters are working * undo change to aie base operator: * format * port last two remaining operators (mostly Claude) * remove CMake and other unused code after refactor * format * remove refactored files, restore torch_dtype_map * fix tests * update action to use Python-based tests * format * fix swiglu * update application tests * update README, remove references to CMake * remove CMake from requirements * format * cleanup utils/torch_to_numpy, make example applications test discovery use absolute path * format * more fixes * more fixes
1 parent 3a053d3 commit 0a6c11c

File tree

195 files changed

+5388
-10725
lines changed

Some content is hidden

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

195 files changed

+5388
-10725
lines changed

.github/actions/build/action.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ inputs:
1010
env_name:
1111
required: false
1212
default: "ci_env"
13-
cmake_extra_flags:
13+
extensive:
1414
required: false
15-
default: ""
15+
default: "false"
1616

1717
runs:
1818
using: "composite"
1919
steps:
20-
- name: Build
20+
- name: Discover tests
2121
env:
2222
HOME: /workspace
2323
shell: bash
2424
run: |
2525
source ${{ inputs.env_name }}/bin/activate
2626
set -euxo pipefail
27-
if [ -n "${{ inputs.cmake_extra_flags }}" ]; then
28-
echo "Using extra CMake flags: ${{ inputs.cmake_extra_flags }}"
29-
fi
30-
cmake -B build -DCMAKE_BUILD_TYPE=Release -DIRONCLAD_AIE_TARGET=aie2p ${{ inputs.cmake_extra_flags }}
31-
cmake --build build -- -j1 VERBOSE=1
27+
mkdir -p testing
28+
cd testing
29+
python3 ../operators/common/discover_tests.py $(if [ "${{ inputs.extensive }}" = "true" ]; then echo "--extensive"; fi) --output-dir .

.github/actions/test/action.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ inputs:
1010
env_name:
1111
required: false
1212
default: "ci_env"
13-
build_dir:
13+
testing_dir:
1414
required: false
15-
default: "build"
15+
default: "testing"
1616

1717
runs:
1818
using: "composite"
@@ -23,4 +23,4 @@ runs:
2323
shell: "bash"
2424
run: |
2525
source ${{ inputs.env_name }}/bin/activate
26-
./scripts/run_tests.py ${{ inputs.test_flags }} ${{ inputs.build_dir }}
26+
./scripts/run_tests.py ${{ inputs.test_flags }} ${{ inputs.testing_dir }}

.github/workflows/extensive.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: ./.github/actions/build
3737
with:
3838
env_name: ci_env
39-
cmake_extra_flags: "-DEXTENSIVE_TESTING=ON"
39+
extensive: "true"
4040

4141
- name: Test
4242
id: test

.github/workflows/small.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
uses: ./.github/actions/build
3636
with:
3737
env_name: ci_env
38+
extensive: "false"
3839

3940
- name: Test
4041
id: test

.github/workflows/test-examples.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,28 @@ jobs:
3838
source ci_env/bin/activate
3939
pip install -r requirements_examples.txt
4040
41-
- name: Build examples
42-
uses: ./.github/actions/build
43-
with:
44-
env_name: ci_env
45-
cmake_extra_flags: "-DBUILD_APPLICATIONS=ON -DBUILD_EXAMPLES=OFF"
41+
- name: Generate application tests
42+
shell: bash
43+
env:
44+
HOME: /workspace
45+
run: |
46+
source ci_env/bin/activate
47+
set -euxo pipefail
48+
mkdir -p testing
49+
cd testing
50+
python3 ../applications/discover_application_tests.py --output-dir .
51+
echo "Application tests generated:"
52+
ls -la
4653
4754
- name: Run examples
4855
id: test
4956
continue-on-error: true
50-
uses: ./.github/actions/test
51-
with:
52-
env_name: ci_env
53-
test_flags: "--log tests.log --csv-latest tests_latest.csv"
57+
shell: bash
58+
env:
59+
HOME: /workspace
60+
run: |
61+
source ci_env/bin/activate
62+
./scripts/run_tests.py --log tests.log --csv-latest tests_latest.csv testing
5463
5564
- name: Commit example test results
5665
uses: ./.github/actions/commit_results

.github/workflows/test-mlir-aie-wheels.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
uses: ./.github/actions/build
4747
with:
4848
env_name: ci_env
49-
cmake_extra_flags: "-DBUILD_APPLICATIONS=OFF -DBUILD_EXAMPLES=ON"
5049

5150
- name: Test
5251
id: test

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44
/my_install*
55
/ironenv*
6-
/cmakeModules*
76
.vscode
87
__pycache__
98
.DS_Store
10-
**/CMakeFiles
119
*.bin
1210
build/*
1311
**/_build/**

CMakeLists.txt

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

README.md

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ If starting from `Ubuntu 24.04` you may need to update the Linux kernel to 6.11+
9797
```bash
9898
# Python versions 3.10, 3.12 and 3.13 are currently supported by our wheels
9999
sudo apt install \
100-
build-essential clang clang-14 lld lld-14 cmake ninja-build python3-venv python3-pip
100+
build-essential clang clang-14 lld lld-14 python3-venv python3-pip
101101
```
102102

103103
1. Setup a virtual environment and activate it:
@@ -119,56 +119,30 @@ If starting from `Ubuntu 24.04` you may need to update the Linux kernel to 6.11+
119119

120120
1. To test your installation, you can try to build and run the example below:
121121
```bash
122-
cmake -B build
123-
cmake --build build --target silu_1_cols_1_channels_2048_tile_2048_run
122+
./operators/axpy/test.py
124123
```
125124

126-
Note: On a fresh install, if you get `CMake Error: Could not find CMAKE_ROOT !!!`, just deactivate and reactivate your python environment.
125+
### Building/Using & Testing Operators
127126

128-
### Building & Testing
127+
All available operators can be found in `operators`. These each contain:
129128

130-
> NOTE: Be sure the XRT setup script has been sourced:
131-
> `source /opt/xilinx/xrt/setup.sh`
132-
133-
IRON is a CMake-based project. To configure the project, run:
134-
```shell
135-
cmake -B build
136-
```
137-
138-
> Note: By default, the project is built for AIE2P. To build for AIE2, set the target using:
139-
> `cmake -B build -DIRONCLAD_AIE_TARGET=aie2`
129+
* `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.)
130+
* `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.
131+
* `reference.py`: A reference CPU implementation to validate the correctness of the NPU implementation.
132+
* `test.py`: An end-to-end test that instantiates and builds the operator, runs it and verifies its outputs against the reference.
140133
141-
To build all designs, use:
142-
```shell
143-
cmake --build build
144-
```
134+
> NOTE: Be sure the XRT setup script has been sourced and the Python environment is activated:
135+
> `source /opt/xilinx/xrt/setup.sh`
136+
> `source /path/to/ironenv/bin/activate`
145137
146-
To test all the designs, use the following python script:
138+
To build and test all the operators, first generate a list of all test cases, then run them:
147139
``` python
148-
./scripts/run_tests.py --iter 1
140+
mkdir testing && cd testing
141+
../operators/common/discover_tests.py
142+
../scripts/run_tests.py --iter 1
149143
```
150-
You can select a single test to run using the `--select` flag.
151144
152-
> Targets are listed when running `cmake -B build` with the following syntax:
153-
> ```
154-
> Registering Executable: <TARGET_NAME>
155-
> ```
156-
157-
If you want to build only a specific design, run:
158-
```shell
159-
# Example: cmake --build build --target silu_4_cols_1_channels_2048_tile_512
160-
cmake --build build --target <TARGET_NAME>
161-
```
162-
163-
You can also test an individual (or a selection of multiple) test(s) using the same script:
164-
```shell
165-
./scripts/run_tests.py --select <TARGET_ONE> --select <TARGET_TWO>
166-
```
167-
168-
Additionally a target to build & run is made available under the `<TARGET_NAME>_run` symbol.
169-
```shell
170-
cmake --build build --target silu_4_cols_1_channels_2048_tile_512_run
171-
```
145+
You can select a single test to run using the `--select` flag.
172146
173147
### Git Hooks (Optional but Recommended)
174148

aie_kernels/CMakeLists.txt

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

0 commit comments

Comments
 (0)