Skip to content
Merged
Show file tree
Hide file tree
Changes from 234 commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
d422622
update readme
hunhoffe Nov 26, 2025
5256eda
remove references to old util folder
hunhoffe Dec 1, 2025
2f86372
Small fixes with imports
hunhoffe Dec 1, 2025
ebdf631
Small changes
hunhoffe Dec 1, 2025
fc6a0c2
small fixes with group id for insts
hunhoffe Dec 2, 2025
7ca3a42
fix typo in last commit
hunhoffe Dec 2, 2025
c7c31e8
first attempt at a runtime
hunhoffe Nov 24, 2025
0dcf518
Start to stub out runtime class
hunhoffe Nov 25, 2025
88ba934
add import
hunhoffe Nov 25, 2025
5d93b72
more progress towards a runtime
hunhoffe Nov 25, 2025
c84fbfd
try to make the xrt hostruntime handle insts more appropriately
hunhoffe Nov 25, 2025
7422259
handle insts a little better
hunhoffe Nov 25, 2025
acd6456
still not working, some small progress though
hunhoffe Nov 25, 2025
fdecb02
remove buggy test for now
hunhoffe Nov 25, 2025
b027436
manage the instructions cache within the host runtime class
hunhoffe Nov 25, 2025
cf137dd
move read insts and clean up cache
hunhoffe Nov 25, 2025
0146dc9
fix bad import
hunhoffe Nov 25, 2025
1d300fa
fix default kernel name
hunhoffe Nov 25, 2025
8327d0e
remove unneeded todos
hunhoffe Nov 25, 2025
494692c
fix bad function call
hunhoffe Nov 26, 2025
02678df
debugging, small progress
hunhoffe Nov 26, 2025
5153605
Small fix, still debugging
hunhoffe Nov 26, 2025
68d8875
still debugging
hunhoffe Nov 26, 2025
62d1175
revert some changes for easier debugging
hunhoffe Nov 26, 2025
00c5461
simplify jit example device handling
hunhoffe Nov 26, 2025
0339418
small fix
hunhoffe Dec 2, 2025
990242e
remove unused files
hunhoffe Dec 2, 2025
78e5bb9
Merge branch 'main' into iron_runtime
hunhoffe Dec 3, 2025
fc4eab7
some progress on trace support
hunhoffe Dec 3, 2025
4a247f4
dedupe insts parsing
hunhoffe Dec 3, 2025
d7cd9c3
use insts in one more place
hunhoffe Dec 3, 2025
cee6ec3
fix type
hunhoffe Dec 3, 2025
6cdfdbc
fix formatting
hunhoffe Dec 3, 2025
128c6c0
small renaming
hunhoffe Dec 3, 2025
4c4e651
Use iron runtime in npukernel
hunhoffe Dec 4, 2025
492c3e6
remove variables which I believe are set but not used
hunhoffe Dec 4, 2025
583d541
filter callables out of npukernel args
hunhoffe Dec 4, 2025
e74cc98
Fix circular import caused by removing the caching of instructions
hunhoffe Dec 4, 2025
0397a30
add missing import
hunhoffe Dec 4, 2025
693edd3
rename file
hunhoffe Dec 4, 2025
9c0014f
update import path
hunhoffe Dec 4, 2025
fef96f9
Fix another bad import path
hunhoffe Dec 4, 2025
07799da
I do not know how used, but adding back in
hunhoffe Dec 4, 2025
91a6606
re-add env, try to streamline AIE_Application class
hunhoffe Dec 4, 2025
02fd5c6
fix typo
hunhoffe Dec 4, 2025
57d7cee
a bit more simplification and fix paths
hunhoffe Dec 4, 2025
2653148
Fix subtle KernelHandle equality bug
hunhoffe Dec 5, 2025
f4f0cc9
Add xrt loaded kernels cache tests
hunhoffe Dec 5, 2025
190ac94
cleanup cache a bit more carefully
hunhoffe Dec 5, 2025
9968913
add atexit hook
hunhoffe Dec 5, 2025
991d2ca
use file modification time for XRTKernelHandles
hunhoffe Dec 5, 2025
9ca94c7
tell lit to ignore python pytest configuration files
hunhoffe Dec 5, 2025
00b4b4c
Merge branch 'main' into iron_runtime
hunhoffe Dec 5, 2025
f205fd1
try to prevent/detect loading race condition
hunhoffe Dec 5, 2025
2a7f3e0
be more careful about keeping track of both contexts and kernel keys.
hunhoffe Dec 5, 2025
da9014b
continue to cleanup the logic of xrthostruntime
hunhoffe Dec 5, 2025
1f895db
small renaming
hunhoffe Dec 5, 2025
357c710
remove unncessary change
hunhoffe Dec 5, 2025
4be6418
check if this change is necessary
hunhoffe Dec 5, 2025
a54216b
add timing data
hunhoffe Dec 6, 2025
0cd26ad
Fix a test bug, add more logging on xclbin context creation error
hunhoffe Dec 6, 2025
b86961c
Merge branch 'main' into iron_runtime
hunhoffe Dec 9, 2025
0e7aab5
convert to path
hunhoffe Dec 9, 2025
111e0ad
Update python/iron/compile/__init__.py
hunhoffe Dec 9, 2025
7811925
reduce cache size to 6
hunhoffe Dec 9, 2025
9cb519e
remove another utility
hunhoffe Dec 10, 2025
a831851
absolute paths, smaller cache for phoenix
hunhoffe Dec 10, 2025
bf44a9c
update test.py file for now
hunhoffe Dec 10, 2025
a5472a2
update trace test
hunhoffe Dec 10, 2025
8eb831c
Update more test code
hunhoffe Dec 10, 2025
9e8a20e
update section 3 code
hunhoffe Dec 10, 2025
7171841
Merge branch 'main' into iron_runtime
hunhoffe Dec 10, 2025
9d33531
remove unused import
hunhoffe Dec 10, 2025
e242024
fix up lit test output with updated helper functions
hunhoffe Dec 10, 2025
4c8ff66
a bit more cleanup
hunhoffe Dec 11, 2025
978e999
Introduced kernel return object
hunhoffe Dec 11, 2025
f94a9a3
A lot of untested changes
hunhoffe Dec 11, 2025
b9bbccd
fix import error and shadowing of "tensor" import from hostruntime
hunhoffe Dec 11, 2025
1b5a6db
fix xrt host runtime pytests
hunhoffe Dec 11, 2025
33530fe
another import fix
hunhoffe Dec 11, 2025
145699c
Use file names to make it easier to run all pytests from test/python …
hunhoffe Dec 11, 2025
2edf77e
more debugging
hunhoffe Dec 11, 2025
491ad68
Handle insts elf mod better in xrt runtime
hunhoffe Dec 11, 2025
2c8cc41
fix import typo
hunhoffe Dec 11, 2025
4293f98
work to consolidate tracing support
hunhoffe Dec 11, 2025
88f5b18
Unchecked updates to some programming examples to use the newer methods
hunhoffe Dec 11, 2025
a931498
small conversion to numpy for views
hunhoffe Dec 11, 2025
ef7b58b
add import
hunhoffe Dec 11, 2025
35159dc
small fixes
hunhoffe Dec 15, 2025
501817a
Merge branch 'main' into iron_runtime
hunhoffe Dec 15, 2025
df6a121
small fix to utility function, fix one test
hunhoffe Dec 15, 2025
087e5cf
change how tensors initialized
hunhoffe Dec 15, 2025
a76aa52
small fixes
hunhoffe Dec 15, 2025
a05f1ec
truncate output
hunhoffe Dec 15, 2025
63028f3
update some of the tests
hunhoffe Dec 15, 2025
d2a3cb1
fix bug in verification logic
hunhoffe Dec 15, 2025
832b471
restrict test to npu1
hunhoffe Dec 15, 2025
196a14c
fix tracing bug
hunhoffe Dec 15, 2025
1ad4dfe
try different context management strategy
hunhoffe Dec 15, 2025
92bd4d7
Merge branch 'main' into iron_runtime
hunhoffe Dec 16, 2025
fbce13d
Merge branch 'main' into iron_runtime
hunhoffe Dec 17, 2025
337a4e3
Merge branch 'main' into iron_runtime
hunhoffe Dec 18, 2025
ede43d4
Merge branch 'main' into iron_runtime
hunhoffe Dec 19, 2025
6690f84
Merge branch 'main' into iron_runtime
hunhoffe Dec 19, 2025
96f12eb
Merge branch 'main' into iron_runtime
hunhoffe Dec 29, 2025
ca1f84d
Update example
hunhoffe Dec 29, 2025
bb03d67
Merge branch 'main' into iron_runtime
hunhoffe Dec 29, 2025
21713f6
make sure buffers are initially synced to npu for tracing
hunhoffe Dec 29, 2025
5ec167d
Update lit requires
hunhoffe Dec 30, 2025
2972e2c
Remove unnecessary changes
hunhoffe Dec 30, 2025
9bf66b4
truncate output and restore unneeded change
hunhoffe Dec 30, 2025
0b3b8eb
restore more changes
hunhoffe Dec 30, 2025
3b50a9a
Simplify runtime
hunhoffe Dec 30, 2025
8239090
Cleanup bugs from previous simplification; passes test/python pytests…
hunhoffe Dec 30, 2025
34e0fdd
fix elf bug I introduced
hunhoffe Dec 30, 2025
402dc14
one more small fix
hunhoffe Dec 30, 2025
f266be1
truncate error output to avoid truncating overall ci logs
hunhoffe Dec 30, 2025
171d82a
still getting segfaults but fix a few python errors
hunhoffe Dec 30, 2025
85bdac4
fix formatting
hunhoffe Dec 30, 2025
ff7a58f
Not sure if control packets is really working, but it is closer
hunhoffe Dec 30, 2025
87ef701
fix python formatting
hunhoffe Jan 2, 2026
eb510af
Fix conv2d example and bug in extract prefix
hunhoffe Jan 2, 2026
2cfc466
update test.py
hunhoffe Jan 2, 2026
c1a5a6b
quick fixup for reference data
hunhoffe Jan 2, 2026
ad5645e
improve parsing of trace function
hunhoffe Jan 2, 2026
b34e82c
Merge branch 'main' into iron_runtime
hunhoffe Jan 2, 2026
8d63854
Improve packet handling
hunhoffe Jan 2, 2026
74d4918
fix api error
hunhoffe Jan 2, 2026
bf5e3da
fixup trace size
hunhoffe Jan 2, 2026
a3e5568
Try to clean up interface a little
hunhoffe Jan 2, 2026
5deb002
Use original array
hunhoffe Jan 2, 2026
a815781
Merge branch 'main' into iron_runtime
hunhoffe Jan 2, 2026
5826402
Try to cleanup trace config a bit more
hunhoffe Jan 2, 2026
32c143c
start consolidating tracing utilities
hunhoffe Jan 2, 2026
b53bacf
integrate more of xrt.py into hostruntime
hunhoffe Jan 2, 2026
eb00b0a
finally remove xrt.py
hunhoffe Jan 2, 2026
99c6d06
Simplify a little
hunhoffe Jan 2, 2026
f71d12f
a little more trace refactoring
hunhoffe Jan 2, 2026
90d4259
integrate NPUKernel into runtime
hunhoffe Jan 2, 2026
b1d874c
try to simplify things a little
hunhoffe Jan 2, 2026
c8c64ef
most iron.hostruntime to utils
hunhoffe Jan 3, 2026
e07c29b
update docs
hunhoffe Jan 3, 2026
94ee9f1
move compile args, start to remove references to iron in utils
hunhoffe Jan 3, 2026
3507116
try to fix circular import
hunhoffe Jan 3, 2026
40ddecb
fixup import
hunhoffe Jan 3, 2026
284929d
now passing test/python pytests
hunhoffe Jan 3, 2026
c13cd68
tidy tracing code a little bit
hunhoffe Jan 3, 2026
c2ff4be
cleaning up old code and fixing imports
hunhoffe Jan 3, 2026
d557c86
move another tracing utility
hunhoffe Jan 3, 2026
389582b
Try to deduplicate some
hunhoffe Jan 3, 2026
23703ee
continue trace cleanup
hunhoffe Jan 3, 2026
8912f1b
fixup imports some more
hunhoffe Jan 3, 2026
4728739
fixup paths in programming examples
hunhoffe Jan 3, 2026
3c5648b
fixup more paths
hunhoffe Jan 3, 2026
2bb083e
fixup another path
hunhoffe Jan 3, 2026
6d28aed
add JIT + trace test
hunhoffe Jan 3, 2026
9e2a773
getting closer to jit trace
hunhoffe Jan 3, 2026
e99cc6a
jit trace working locally
hunhoffe Jan 3, 2026
c77b6e0
fixup import
hunhoffe Jan 3, 2026
3826f08
update documentation
hunhoffe Jan 3, 2026
de948c8
fixup some more paths
hunhoffe Jan 3, 2026
272fe08
fix another import
hunhoffe Jan 3, 2026
cd75071
create utils/hostruntime directory
hunhoffe Jan 3, 2026
a5702b5
fix another import
hunhoffe Jan 3, 2026
0339dba
stronger trace check
hunhoffe Jan 3, 2026
ee5c96e
update cmake python/utils source files
hunhoffe Jan 3, 2026
8c3bc5f
fix test imports
hunhoffe Jan 3, 2026
5e936d6
Fixed path
hunhoffe Jan 3, 2026
4568c43
update imports in a few more examples
hunhoffe Jan 3, 2026
906ec54
try to deduplicate list of npu1 vs npu2 arches
hunhoffe Jan 3, 2026
be386bc
update scripts
hunhoffe Jan 3, 2026
0a5cef8
Use opts kernel
hunhoffe Jan 3, 2026
18b899f
fix another test
hunhoffe Jan 3, 2026
1a25c96
Update python/utils/npu_models.json
hunhoffe Jan 3, 2026
21515ba
fix import issue
hunhoffe Jan 4, 2026
0920a9c
update build
hunhoffe Jan 5, 2026
3e241ef
Merge branch 'main' into iron_runtime
hunhoffe Jan 5, 2026
0097bae
fix default kernel name
hunhoffe Jan 5, 2026
a1bf2dc
Merge branch 'main' into iron_runtime
hunhoffe Jan 5, 2026
50b9618
Fixed notebook example
hunhoffe Jan 5, 2026
eb63d9a
Merge branch 'main' into iron_runtime
hunhoffe Jan 5, 2026
8e0b739
fix import
hunhoffe Jan 6, 2026
3247306
first attempt at merging main
hunhoffe Jan 6, 2026
8002871
pytests working ok
hunhoffe Jan 6, 2026
72eec97
one fix, revert some changes
hunhoffe Jan 6, 2026
584e641
some import fixes
hunhoffe Jan 6, 2026
b05e0eb
fix another import
hunhoffe Jan 6, 2026
9cb52ae
choose enums by arch name
hunhoffe Jan 6, 2026
c486007
Fix typo
hunhoffe Jan 6, 2026
55962bd
fix another check
hunhoffe Jan 6, 2026
96e3031
fix another import error
hunhoffe Jan 6, 2026
46075d2
Simplify changes a bit more
hunhoffe Jan 6, 2026
a64cc10
Merge branch 'main' into iron_runtime
hunhoffe Jan 6, 2026
8010762
revert unnecessary change
hunhoffe Jan 6, 2026
ca283f5
use tensor whenever possible
hunhoffe Jan 6, 2026
a56e71a
try to create a cache xrt runtime again
hunhoffe Jan 6, 2026
2f3f019
used CachedXRTRuntime by default
hunhoffe Jan 6, 2026
f161926
Cleanup cache when python process exits
hunhoffe Jan 6, 2026
7719fb9
stricter eviction
hunhoffe Jan 6, 2026
8813f50
fix switched if/else
hunhoffe Jan 6, 2026
9a24d2a
add some tests
hunhoffe Jan 6, 2026
05e1fcf
fill cache test is passing
hunhoffe Jan 6, 2026
7fd1704
add cache tests
hunhoffe Jan 6, 2026
f3d3645
Merge branch 'main' into iron_runtime
hunhoffe Jan 6, 2026
903c8b9
add base runtime unit test
hunhoffe Jan 6, 2026
8f17791
fix some errors
hunhoffe Jan 6, 2026
b86e5d0
add a bit more compatibility with driver versions and make sure to cl…
hunhoffe Jan 7, 2026
c1502de
pytests working on phoenix
hunhoffe Jan 7, 2026
b064426
add comment
hunhoffe Jan 7, 2026
6a529d5
remove outdated import
hunhoffe Jan 7, 2026
d6399bc
Set cache size based also on lit test concurrency
hunhoffe Jan 7, 2026
2bea652
insts caching
hunhoffe Jan 7, 2026
84e1092
retries for context, small bug in buffer obj cleanup, update tests
hunhoffe Jan 7, 2026
d7fc986
limit parallelism of lit tests that use xrt to run things on an npu
hunhoffe Jan 7, 2026
78f9aef
fix trace bug
hunhoffe Jan 7, 2026
85d85e4
try increasing cache size a little
hunhoffe Jan 7, 2026
b4074c5
Update python/helpers/util.py
hunhoffe Jan 7, 2026
b64d8dd
Update test/python/npu-xrt/test_jit_trace.py
hunhoffe Jan 7, 2026
b093163
Merge branch 'main' into iron_runtime
hunhoffe Jan 7, 2026
0a206d1
Update python/utils/__init__.py
hunhoffe Jan 7, 2026
de0afd5
remove iron naming from utils for the most part
hunhoffe Jan 8, 2026
2b57b31
fixup comment
hunhoffe Jan 8, 2026
c32d7e3
change ref to dictionary
hunhoffe Jan 8, 2026
c6d7872
change ref to dict in examples
hunhoffe Jan 8, 2026
293035d
change ordering of run_test
hunhoffe Jan 8, 2026
a534bf0
remove unnecessary declaration
hunhoffe Jan 8, 2026
3350e69
set env_cache_size more deterministically
hunhoffe Jan 8, 2026
e15a92d
fixup context key
hunhoffe Jan 8, 2026
951cc4a
fix a few bugs
hunhoffe Jan 8, 2026
b3c31aa
rename
hunhoffe Jan 8, 2026
fa1283a
pytests pass
hunhoffe Jan 8, 2026
1e7e875
added more interesting comment
hunhoffe Jan 8, 2026
29b5e9b
fix another typo
hunhoffe Jan 8, 2026
be554cc
update comments
hunhoffe Jan 8, 2026
ba76518
be more careful with npu1/npu2 strings
hunhoffe Jan 8, 2026
7a8769e
fixup year
hunhoffe Jan 8, 2026
8214478
small fix
hunhoffe Jan 8, 2026
b194fbc
another fix
hunhoffe Jan 8, 2026
367aa96
fix in test
hunhoffe Jan 8, 2026
ed78e0e
fixup documentation a bit
hunhoffe Jan 8, 2026
2565f34
more docstrings
hunhoffe Jan 8, 2026
a6d5dce
include utils/hostruntime in the documentation webpage
hunhoffe Jan 8, 2026
dda8594
more updates to documentation
hunhoffe Jan 8, 2026
fb8f442
more small fixes
hunhoffe Jan 8, 2026
c11665c
Add another test
hunhoffe Jan 8, 2026
24c6997
add another flag to better control the cached runtime behavior
hunhoffe Jan 8, 2026
83b81c1
update copyright
hunhoffe Jan 8, 2026
9908eb7
Merge branch 'main' into iron_runtime
hunhoffe Jan 8, 2026
42315b6
override set device
hunhoffe Jan 9, 2026
f1ae207
Add some sanity checks
hunhoffe Jan 9, 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
26 changes: 16 additions & 10 deletions .github/workflows/buildAndTestRyzenAI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
matrix:
runner_type: [ amd7940hs, amdhx370 ]
env:
IRON_CACHE_HOME: ${{ github.workspace }}/iron-cache-${{ matrix.runner_type }}-${{ github.run_id }}
NPU_CACHE_HOME: ${{ github.workspace }}/iron-cache-${{ matrix.runner_type }}-${{ github.run_id }}
PIP_CACHE_DIR: ${{ github.workspace }}/.pip-cache-${{ matrix.runner_type }}-${{ github.run_id }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -130,18 +130,21 @@ jobs:
$CMAKE_ARGS

# Create runner-specific cache directory
rm -rf $IRON_CACHE_HOME
mkdir $IRON_CACHE_HOME
rm -rf $NPU_CACHE_HOME
mkdir $NPU_CACHE_HOME

# Set number of contexts to maintain in cache per process
export XRT_CONTEXT_CACHE_SIZE=3

ninja install
ninja check-aie
ninja check-aie-concurrency
popd

- name: Cleanup IRON_CACHE_HOME
- name: Cleanup NPU_CACHE_HOME
if: always()
run: |
rm -rf $IRON_CACHE_HOME
rm -rf $NPU_CACHE_HOME
rm -rf $PIP_CACHE_DIR

build-quick-setup:
Expand All @@ -152,7 +155,7 @@ jobs:
matrix:
runner_type: [ amd7940hs, amdhx370 ]
env:
IRON_CACHE_HOME: ${{ github.workspace }}/iron-cache-${{ matrix.runner_type }}-${{ github.run_id }}
NPU_CACHE_HOME: ${{ github.workspace }}/iron-cache-${{ matrix.runner_type }}-${{ github.run_id }}
PIP_CACHE_DIR: ${{ github.workspace }}/.pip-cache-${{ matrix.runner_type }}-${{ github.run_id }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -200,17 +203,20 @@ jobs:
LIT_OPTS="-j12 $LIT_OPTS"
fi

# Set number of contexts to maintain in cache per process
export XRT_CONTEXT_CACHE_SIZE=3

# Create runner-specific cache directory
rm -rf $IRON_CACHE_HOME
mkdir $IRON_CACHE_HOME
rm -rf $NPU_CACHE_HOME
mkdir $NPU_CACHE_HOME

ninja install
ninja check-reference-designs
ninja check-programming-guide
popd

- name: Cleanup IRON_CACHE_HOME
- name: Cleanup NPU_CACHE_HOME
if: always()
run: |
rm -rf $IRON_CACHE_HOME
rm -rf $NPU_CACHE_HOME
rm -rf $PIP_CACHE_DIR
10 changes: 5 additions & 5 deletions .github/workflows/buildAndTestVitis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
matrix:
runner_type: [ ubuntu-vitis ]
env:
IRON_CACHE_HOME: ${{ github.workspace }}/iron-cache-${{ matrix.runner_type }}-${{ github.run_id }}
NPU_CACHE_HOME: ${{ github.workspace }}/iron-cache-${{ matrix.runner_type }}-${{ github.run_id }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -125,13 +125,13 @@ jobs:
$CMAKE_ARGS

# Create runner-specific cache directory
rm -rf $IRON_CACHE_HOME
mkdir $IRON_CACHE_HOME
rm -rf $NPU_CACHE_HOME
mkdir $NPU_CACHE_HOME

ninja install
ninja check-aie
popd

- name: Cleanup IRON_CACHE_HOME
- name: Cleanup NPU_CACHE_HOME
if: always()
run: rm -rf $IRON_CACHE_HOME
run: rm -rf $NPU_CACHE_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ run: ${targetname}.exe ${xclbin_target}
trace: ${targetname}.exe ${trace_xclbin_target} ${insts_target}
export XRT_HACK_UNSECURE_LOADING_XCLBIN=1 && \
${powershell} ./$< -x ${trace_xclbin_target} -i ${insts_target} -k MLIR_AIE -M $M -K $K -N $N ${runargs} -t ${trace_size}
${srcdir}/../../../../python/utils/parse_trace.py --input trace.txt --mlir ${trace_mlir_target} --output trace_mm.json
${srcdir}/../../../../python/utils/trace/parse.py --input trace.txt --mlir ${trace_mlir_target} --output trace_mm.json

# ${powershell} ./$< -x ${trace_xclbin_target} -i ${insts_target} -k MLIR_AIE -M $M -K $K -N $N -v 1 --warmup 0 --iters 1 -t ${trace_size}

.PHONY: parse_trace
parse_trace:
${srcdir}/../../../../python/utils/parse_trace.py --input trace.txt --mlir ${trace_mlir_target} --output trace_mm.json
${srcdir}/../../../../python/utils/trace/parse.py --input trace.txt --mlir ${trace_mlir_target} --output trace_mm.json

.PHONY: clean
clean: clean_trace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from aie.dialects.aie import *
from aie.dialects.aiex import *
import aie.utils.trace as trace_utils
from aie.utils.trace import PortEvent
from aie.iron.controlflow import range_
from aie.iron.dtype import str_to_dtype

Expand Down Expand Up @@ -280,28 +279,28 @@ def sequence(A, B, C):
trace_size=trace_size,
coretile_events=[
# captures input A (PORT_RUNNING_0, at port number 1, master for inputs)
trace_utils.PortEvent(
trace_utils.CoreEvent.PORT_RUNNING_0,
trace_utils.events.PortEvent(
trace_utils.events.CoreEvent.PORT_RUNNING_0,
port_number=1,
master=True,
),
# captures input B (PORT_RUNNING_1, at port number 2, master for inputs)
trace_utils.PortEvent(
trace_utils.CoreEvent.PORT_RUNNING_1,
trace_utils.events.PortEvent(
trace_utils.events.CoreEvent.PORT_RUNNING_1,
port_number=2,
master=True,
),
# captures output C (PORT_RUNNING_2, at port number 1, slave for outputs)
trace_utils.PortEvent(
trace_utils.CoreEvent.PORT_RUNNING_2,
trace_utils.events.PortEvent(
trace_utils.events.CoreEvent.PORT_RUNNING_2,
port_number=1,
master=False,
),
trace_utils.CoreEvent.INSTR_EVENT_0,
trace_utils.CoreEvent.INSTR_EVENT_1,
trace_utils.CoreEvent.MEMORY_STALL,
trace_utils.CoreEvent.LOCK_STALL,
trace_utils.CoreEvent.INSTR_VECTOR,
trace_utils.events.CoreEvent.INSTR_EVENT_0,
trace_utils.events.CoreEvent.INSTR_EVENT_1,
trace_utils.events.CoreEvent.MEMORY_STALL,
trace_utils.events.CoreEvent.LOCK_STALL,
trace_utils.events.CoreEvent.INSTR_VECTOR,
],
)

Expand Down
5 changes: 4 additions & 1 deletion programming_examples/basic/packet_switch/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@ int main(int argc, const char *argv[]) {
ref = srcVecA[i] + 2; // ref for the second input packet
}
if (*(bufOut + i) != ref) {
if (errors < 10) {
if (errors < 100) {
std::cout << "Error in output " << i << "; Input: " << srcVecA[i]
<< "; Output: " << *(bufOut + i) << " != reference:" << ref
<< std::endl;
} else if (errors == 100) {
std::cout << "..." << std::endl;
std::cout << "[Errors truncated]" << std::endl;
}
errors++;
}
Expand Down
8 changes: 4 additions & 4 deletions programming_examples/basic/passthrough_kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ run_py: build/final_${data_size}.xclbin build/insts_${data_size}.bin

trace: ${targetname}_${data_size}.exe build/final_trace_${data_size}.xclbin build/insts_${data_size}.bin
${powershell} ./$< -x build/final_trace_${data_size}.xclbin -i build/insts_${data_size}.bin -k MLIR_AIE -t ${trace_size}
${srcdir}/../../../python/utils/parse_trace.py --input trace.txt --mlir build/aie2_trace_lineBased_8b_${data_size}.mlir --output trace_passthrough_kernel.json
${srcdir}/../../../python/utils/get_trace_summary.py --input trace_passthrough_kernel.json
${srcdir}/../../../python/utils/trace/parse.py --input trace.txt --mlir build/aie2_trace_lineBased_8b_${data_size}.mlir --output trace_passthrough_kernel.json
${srcdir}/../../../python/utils/trace/get_trace_summary.py --input trace_passthrough_kernel.json

trace_py: build/final_trace_${data_size}.xclbin build/insts_${data_size}.bin
${powershell} python3 ${srcdir}/test.py -x build/final_trace_${data_size}.xclbin -i build/insts_${data_size}.bin -k MLIR_AIE -t ${trace_size} -i1s ${in1_size} -os ${out_size}
${srcdir}/../../../python/utils/parse_trace.py --input trace.txt --mlir build/aie2_trace_lineBased_8b_${data_size}.mlir --output trace_${targetname}.json
${srcdir}/../../../python/utils/get_trace_summary.py --input trace_${targetname}.json
${srcdir}/../../../python/utils/trace/parse.py --input trace.txt --mlir build/aie2_trace_lineBased_8b_${data_size}.mlir --output trace_${targetname}.json
${srcdir}/../../../python/utils/trace/get_trace_summary.py --input trace_${targetname}.json

clean_trace:
rm -rf tmpTrace trace.txt parse*json trace*json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
// RUN: make -f %S/Makefile devicename=npu2
// RUN: %run_on_npu2% make -f %S/Makefile run devicename=npu2
// RUN: make -f %S/Makefile clean
// RUN: env CHESS=false %run_on_npu2% make -f %S/Makefile trace devicename=npu2
// RUN: env CHESS=false %run_on_npu2% make -f %S/Makefile trace devicename=npu2
33 changes: 14 additions & 19 deletions programming_examples/basic/passthrough_kernel/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
# (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
import numpy as np
import sys
import aie.utils.xrt as xrt_utils
import aie.utils.test as test_utils
import aie.iron as iron
from aie.utils import DefaultNPURuntime


def main(opts):
in1_size = int(opts.in1_size) # in bytes
in2_size = int(opts.in2_size) # in bytes
out_size = int(opts.out_size) # in bytes

# --------------------------------------------------------------------------
Expand All @@ -36,28 +36,23 @@ def main(opts):
assert out_size == in1_size

# Initialize data
in1_data = np.arange(0, in1_volume, dtype=in1_dtype)
out_data = np.zeros([out_volume], dtype=out_dtype)

# Define reference data
ref = in1_data
ref = np.arange(0, in1_volume, dtype=in1_dtype)
in1 = iron.tensor(ref, dtype=in1_dtype)
out = iron.zeros([out_volume], dtype=out_dtype)

# --------------------------------------------------------------------------

print("Running...\n")
res = xrt_utils.setup_and_run_aie(
in1_dtype,
None,
out_dtype,
in1_data,
None,
out_data,
in1_volume,
None,
out_volume,
ref,
opts,
npu_opts = test_utils.create_npu_kernel(opts)
res = DefaultNPURuntime.run_test(
npu_opts.npu_kernel,
[in1, out],
{1: ref},
verify=npu_opts.verify,
verbosity=npu_opts.verbosity,
)
if res == 0:
print("\nPASS!\n")
sys.exit(res)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"from aie.helpers.dialects.func import func\n",
"from aie.iron.controlflow import range_\n",
"\n",
"from aie.utils.xrt import setup_aie, execute as execute_on_aie\n",
"from aie.utils import NPUKernel, DefaultNPURuntime, get_current_device\n",
"import aie.iron as iron\n",
"from aie.iron.device import NPU2\n",
"import aie.utils.test as test_utils"
]
},
Expand Down Expand Up @@ -69,7 +71,11 @@
" N = vector_size\n",
" lineWidthInBytes = N // 4 # chop input in 4 sub-tensors\n",
"\n",
" @device(AIEDevice.npu1_1col)\n",
" d = get_current_device()\n",
" if d is None:\n",
" raise RuntimeError(\"Could not determine current device\")\n",
"\n",
" @device(d.resolve())\n",
" def device_body():\n",
" # define types\n",
" line_ty = np.ndarray[(lineWidthInBytes,), np.dtype[np.uint8]]\n",
Expand Down Expand Up @@ -106,20 +112,15 @@
"\n",
" @runtime_sequence(vector_ty, vector_ty, vector_ty)\n",
" def sequence(inTensor, outTensor, notUsed):\n",
" npu_dma_memcpy_nd(\n",
" metadata=of_in,\n",
" bd_id=0,\n",
" mem=inTensor,\n",
" sizes=[1, 1, 1, N],\n",
" issue_token=True,\n",
" in_task = shim_dma_single_bd_task(\n",
" of_in, inTensor, sizes=[1, 1, 1, N], issue_token=True\n",
" )\n",
" npu_dma_memcpy_nd(\n",
" metadata=of_out,\n",
" bd_id=1,\n",
" mem=outTensor,\n",
" sizes=[1, 1, 1, N],\n",
" out_task = shim_dma_single_bd_task(\n",
" of_out, outTensor, sizes=[1, 1, 1, N], issue_token=True\n",
" )\n",
" dma_wait(of_in, of_out)"
"\n",
" dma_start_task(in_task, out_task)\n",
" dma_await_task(in_task, out_task)"
]
},
{
Expand Down Expand Up @@ -181,19 +182,22 @@
"source": [
"dtype = np.uint8\n",
"\n",
"app = setup_aie(\n",
"npu_kernel = NPUKernel(\n",
" \"notebook_build/notebook.xclbin\",\n",
" \"notebook_build/notebook_insts.bin\",\n",
" VECTOR_SIZE,\n",
" dtype,\n",
" None,\n",
" None,\n",
" VECTOR_SIZE,\n",
" dtype,\n",
" kernel_name=\"MLIR_AIE\",\n",
")\n",
"kernel_handle = DefaultNPURuntime.load(npu_kernel)\n",
"\n",
"input = np.arange(1, VECTOR_SIZE + 1, dtype=dtype)\n",
"in_tensor = iron.tensor(input, dtype=dtype)\n",
"out_tensor = iron.zeros(VECTOR_SIZE, dtype=dtype)\n",
"\n",
"buffers = [in_tensor, out_tensor]\n",
"\n",
"print(\"Running...\")\n",
"aie_output = execute_on_aie(app, input)\n",
"DefaultNPURuntime.run(kernel_handle, buffers)\n",
"aie_output = out_tensor.numpy()\n",
"\n",
"# Copy output results and verify they are correct\n",
"errors = 0\n",
Expand Down
42 changes: 15 additions & 27 deletions programming_examples/basic/passthrough_pykernel/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
# (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
import numpy as np
import sys
from aie.utils.xrt import setup_aie, execute
import aie.utils.test as test_utils
import aie.iron as iron
from aie.utils import DefaultNPURuntime


def main(opts):
Expand All @@ -17,34 +18,21 @@ def main(opts):
data_size = int(opts.size)
dtype = np.uint8

app = setup_aie(
opts.xclbin,
opts.instr,
data_size,
dtype,
None,
None,
data_size,
dtype,
input_data = np.arange(1, data_size + 1, dtype=dtype)
in1 = iron.tensor(input_data, dtype=dtype)
out = iron.zeros(data_size, dtype=dtype)

npu_opts = test_utils.create_npu_kernel(opts)
res = DefaultNPURuntime.run_test(
npu_opts.npu_kernel,
[in1, out],
{1: input_data},
verify=npu_opts.verify,
verbosity=npu_opts.verbosity,
)
input = np.arange(1, data_size + 1, dtype=dtype)
aie_output = execute(app, input)

# Copy output results and verify they are correct
errors = 0
if opts.verify:
if opts.verbosity >= 1:
print("Verifying results ...")
e = np.equal(input, aie_output)
errors = np.size(e) - np.count_nonzero(e)

if not errors:
if res == 0:
print("\nPASS!\n")
exit(0)
else:
print("\nError count: ", errors)
print("\nFailed.\n")
exit(-1)
sys.exit(res)


if __name__ == "__main__":
Expand Down
Loading
Loading