Skip to content

Commit

Permalink
Finished pass of cleaning up aie2_iron examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hunhoffe committed Nov 23, 2024
1 parent 5217a20 commit 5b1029d
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 326 deletions.
33 changes: 8 additions & 25 deletions programming_examples/basic/row_wise_bias_add/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@ xclbin_target?=build/final.xclbin
insts_target?=build/insts.txt
host_target?=build/test

experimental_mlir_target?=build/experimental_aie.mlir
experimental_xclbin_target?=build/experimental_final.xclbin
experimental_insts_target?=build/experimental_insts.txt
experimental_host_target?=build/experimental_test

M=768
N=2304
m=96
n=32

aie_py_src=aie2.py
use_alt?=0
use_iron?=0

ifeq (${use_alt}, 1)
aie_py_src=aie2_alt.py
ifeq (${use_iron}, 1)
$(error Cannot specify both alternative design and IRON)
endif
endif

ifeq (${use_iron}, 1)
aie_py_src=aie2_iron.py
endif

.PHONY: all
Expand All @@ -60,40 +63,20 @@ ${mlir_target}: ${srcdir}/${aie_py_src}
mkdir -p ${@D}
python3 $< $M $N $m $n > $@

${experimental_mlir_target}: ${srcdir}/experimental_aie2.py
mkdir -p ${@D}
python3 $< $M $N $m $n > $@

${xclbin_target}: ${mlir_target} build/kernel.o
mkdir -p ${@D}
cd ${@D} && aiecc.py -v --aie-generate-cdo --no-compile-host --xclbin-name=${@F} \
--no-xchesscc --no-xbridge \
--aie-generate-npu --npu-insts-name=${insts_target:build/%=%} ${<:%=../%}

${experimental_xclbin_target}: ${experimental_mlir_target} build/kernel.o
mkdir -p ${@D}
cd ${@D} && aiecc.py -v --aie-generate-cdo --no-compile-host --xclbin-name=${@F} \
--no-xchesscc --no-xbridge \
--aie-generate-npu --npu-insts-name=${experimental_insts_target:build/%=%} ${<:%=../%}

${host_target}: ${srcdir}/test.cpp ${xclbin_target}
mkdir -p ${@D}
${CXX} ${XRT_FLAGS} -DM=$M -DN=$N -o $@ $< ${XRT_LIBS}

${experimental_host_target}: ${srcdir}/test.cpp ${experimental_xclbin_target}
mkdir -p ${@D}
mv ${experimental_xclbin_target} ${xclbin_target}
mv ${experimental_insts_target} ${insts_target}
${CXX} ${XRT_FLAGS} -DM=$M -DN=$N -o $@ $< ${XRT_LIBS}

.PHONY: run
run: ${host_target}
./${host_target}

.PHONY: run_experimental
run_experimental: ${experimental_host_target}
./${experimental_host_target}

xclbin_sign=${XILINX_XRT}/amdxdna/setup_xclbin_firmware.sh
.PHONY: sign
sign: ${xclbin_target}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import numpy as np
import sys

from aie.api.io.iocoordinator import IOCoordinator
from aie.api.dataflow.objectfifo import ObjectFifo
from aie.api.placers import SequentialPlacer
from aie.api.program import Program
from aie.api.kernels.binkernel import BinKernel
from aie.api.worker import Worker
from aie.api.phys.device import NPU1Col1
from aie.helpers.tensortiler.tensortiler2D import TensorTiler2D
from aie.iron.io.iocoordinator import IOCoordinator
from aie.iron.dataflow.objectfifo import ObjectFifo
from aie.iron.placers import SequentialPlacer
from aie.iron.program import Program
from aie.iron.kernels.binkernel import BinKernel
from aie.iron.worker import Worker
from aie.iron.phys.device import NPU1Col1
from aie.helpers.taplib import TensorTiler2D
from aie.helpers.dialects.ext.scf import _for as range_


Expand Down Expand Up @@ -46,17 +46,16 @@ def core_fn(in_fifo, bias_fifo, out_fifo, kernel_func):
in_fifo.release(1)
bias_fifo.release(1)

tiler = TensorTiler2D.group_tiler(
(M, N), (m, n), (M // m, N // n), tile_group_col_major=True
)
bias_tiler = TensorTiler2D.group_tiler((1, N), (1, n), (1, N // n))

io = IOCoordinator()
with io.runtime_sequence(tensor_ty, bias_ty, tensor_ty) as (inp, bias, out):
tiler = TensorTiler2D(M, N, m, n, tensor_col_major=True)
bias_tiler = TensorTiler2D(1, N, 1, n)
for t, bias_t in io.tile_loop(
tiler.tile_iter(chunk_height=M // m, chunk_width=N // n),
bias_tiler.tile_iter(chunk_width=N // n),
):
io.fill(in_fifo.prod, t, inp)
io.fill(bias_fifo.prod, bias_t, bias)
io.drain(out_fifo.cons, t, out, wait=True)
io.fill(in_fifo.prod, tiler[0], inp)
io.fill(bias_fifo.prod, bias_tiler[0], bias)
io.drain(out_fifo.cons, tiler[0], out, wait=True)

my_worker = Worker(
core_fn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from aie.dialects.aie import *
from aie.dialects.aiex import *

from aie.extras.context import mlir_mod_ctx
from aie.helpers.dialects.ext.scf import _for as range_
from aie.helpers.taplib import TensorTiler2D
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5b1029d

Please sign in to comment.