Skip to content

Commit

Permalink
[programming examples] Fix lit vision (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
denolf authored Apr 25, 2024
1 parent 0644a0a commit 05a31ec
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 87 deletions.
17 changes: 9 additions & 8 deletions programming_examples/vision/color_detect/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#
##===----------------------------------------------------------------------===##

include ../../makefile-common
srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

VPATH := ../../../aie_kernels/aie2
include ${srcdir}/../../makefile-common

VPATH := ${srcdir}/../../../aie_kernels/aie2

COLORDETECT_WIDTH = 1920
COLORDETECT_HEIGHT = 1080
Expand All @@ -27,13 +29,13 @@ mlir: build/aie2_lineBased_8b_${COLORDETECT_WIDTH}.mlir

build/%.cc.o: %.cc
mkdir -p ${@D}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -DBIT_WIDTH=8 -c $(<:%=../%) -o ${@F}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -DBIT_WIDTH=8 -c $< -o ${@F}

build/combined_bitwiseOR_gray2rgba_bitwiseAND.a: build/bitwiseOR.cc.o build/gray2rgba.cc.o build/bitwiseAND.cc.o
mkdir -p ${@D}
ar rvs $@ $< $(word 2,$^) $(word 3,$^)

build/aie2_lineBased_8b_${COLORDETECT_WIDTH}.mlir: aie2_colorDetect.py
build/aie2_lineBased_8b_${COLORDETECT_WIDTH}.mlir: ${srcdir}/aie2_colorDetect.py
mkdir -p ${@D}
python3 $< ${COLORDETECT_WIDTH} ${COLORDETECT_HEIGHT} > $@

Expand All @@ -42,12 +44,11 @@ build/final_${COLORDETECT_WIDTH}.xclbin: build/aie2_lineBased_8b_${COLORDETECT_W
cd ${@D} && aiecc.py --aie-generate-cdo --aie-generate-npu --no-compile-host \
--xclbin-name=${@F} --npu-insts-name=insts.txt $(<:%=../%)

${targetname}.exe: test.cpp
${targetname}.exe: ${srcdir}/test.cpp
mkdir -p ${@D}
rm -rf _build
mkdir -p _build
cd _build && ${powershell} cmake .. -DTARGET_NAME=${targetname} -DCOLORDETECT_WIDTH=${COLORDETECT_WIDTH} -DCOLORDETECT_HEIGHT=${COLORDETECT_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13

cd _build && ${powershell} cmake ${srcdir} -DTARGET_NAME=${targetname} -DCOLORDETECT_WIDTH=${COLORDETECT_WIDTH} -DCOLORDETECT_HEIGHT=${COLORDETECT_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13
cd _build && ${powershell} cmake --build . --config Release
ifeq "${powershell}" "powershell.exe"
cp _build/${targetname}.exe $@
Expand All @@ -59,4 +60,4 @@ run: ${targetname}.exe build/final_${COLORDETECT_WIDTH}.xclbin build/insts.txt
${powershell} ./$< -x build/final_${COLORDETECT_WIDTH}.xclbin -i build/insts.txt -k MLIR_AIE

clean:
rm -rf build _build
rm -rf build _build ${targetname}.exe colorDetectOut_test.jpg
16 changes: 0 additions & 16 deletions programming_examples/vision/color_detect/run.lit

This file was deleted.

10 changes: 10 additions & 0 deletions programming_examples/vision/color_detect/run_makefile.lit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// (c) Copyright 2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// REQUIRES: ryzen_ai, chess
//
// RUN: make -f %S/Makefile clean
// RUN: make -f %S/Makefile
// RUN: %run_on_npu make -f %S/Makefile run | FileCheck %s
// CHECK: PASS!

18 changes: 8 additions & 10 deletions programming_examples/vision/color_threshold/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#
##===----------------------------------------------------------------------===##

include ../../makefile-common
srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

VPATH := ../../../aie_kernels/aie2
include ${srcdir}/../../makefile-common

VPATH := ${srcdir}/../../../aie_kernels/aie2

COLORTHRESHOLD_WIDTH = 1920
COLORTHRESHOLD_HEIGHT = 1080
Expand All @@ -24,25 +26,21 @@ mlir: build/aie2_${COLORTHRESHOLD_WIDTH}.mlir

build/%.cc.o: %.cc
mkdir -p ${@D}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -d -DBIT_WIDTH=8 -c $(<:%=../%) -o ${@F}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -d -DBIT_WIDTH=8 -c $< -o ${@F}

build/aie2_${COLORTHRESHOLD_WIDTH}.mlir: aie2_colorThreshold.py
build/aie2_${COLORTHRESHOLD_WIDTH}.mlir: ${srcdir}/aie2_colorThreshold.py
mkdir -p ${@D}
python3 $< ${COLORTHRESHOLD_WIDTH} ${COLORTHRESHOLD_HEIGHT} > $@

#build/aie.mlir: aie.mlir
# mkdir -p ${@D}
# cp $< $@

build/final_${COLORTHRESHOLD_WIDTH}.xclbin: build/aie2_${COLORTHRESHOLD_WIDTH}.mlir build/threshold.cc.o
mkdir -p ${@D}
cd ${@D} && aiecc.py --aie-generate-cdo --aie-generate-npu --no-compile-host \
--xclbin-name=${@F} --npu-insts-name=insts.txt $(<:%=../%)

${targetname}.exe: test.cpp
${targetname}.exe: ${srcdir}/test.cpp
rm -rf _build
mkdir -p _build
cd _build && ${powershell} cmake .. -DTARGET_NAME=${targetname} -DCOLORTHRESHOLD_WIDTH=${COLORTHRESHOLD_WIDTH} -DCOLORTHRESHOLD_HEIGHT=${COLORTHRESHOLD_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13
cd _build && ${powershell} cmake ${srcdir} -DTARGET_NAME=${targetname} -DCOLORTHRESHOLD_WIDTH=${COLORTHRESHOLD_WIDTH} -DCOLORTHRESHOLD_HEIGHT=${COLORTHRESHOLD_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13
cd _build && ${powershell} cmake --build . --config Release
ifeq "${powershell}" "powershell.exe"
cp _build/${targetname}.exe $@
Expand Down
11 changes: 0 additions & 11 deletions programming_examples/vision/color_threshold/run.lit

This file was deleted.

10 changes: 10 additions & 0 deletions programming_examples/vision/color_threshold/run_makefile.lit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// (c) Copyright 2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// REQUIRES: ryzen_ai, chess
//
// RUN: make -f %S/Makefile clean
// RUN: make -f %S/Makefile
// RUN: %run_on_npu make -f %S/Makefile run | FileCheck %s
// CHECK: PASS!

16 changes: 9 additions & 7 deletions programming_examples/vision/edge_detect/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#
##===----------------------------------------------------------------------===##

include ../../makefile-common
srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

VPATH := ../../../aie_kernels/aie2
include ${srcdir}/../../makefile-common

VPATH := ${srcdir}/../../../aie_kernels/aie2

EDGEDETECT_WIDTH = 1920
EDGEDETECT_HEIGHT = 1080
Expand All @@ -27,13 +29,13 @@ mlir: build/aie2_lineBased_8b_${EDGEDETECT_WIDTH}.mlir

build/%.cc.o: %.cc
mkdir -p ${@D}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -DBIT_WIDTH=8 -c $(<:%=../%) -o ${@F}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -DBIT_WIDTH=8 -c $< -o ${@F}

build/combined_gray2rgba_addWeighted.a: build/gray2rgba.cc.o build/addWeighted.cc.o
mkdir -p ${@D}
ar rvs $@ $< $(word 2,$^)

build/aie2_lineBased_8b_${EDGEDETECT_WIDTH}.mlir: aie2_edgeDetect.py
build/aie2_lineBased_8b_${EDGEDETECT_WIDTH}.mlir: ${srcdir}/aie2_edgeDetect.py
mkdir -p ${@D}
python3 $< ${EDGEDETECT_WIDTH} ${EDGEDETECT_HEIGHT} > $@

Expand All @@ -42,10 +44,10 @@ build/final_${EDGEDETECT_WIDTH}.xclbin: build/aie2_lineBased_8b_${EDGEDETECT_WID
cd ${@D} && aiecc.py --aie-generate-cdo --aie-generate-npu --no-compile-host \
--xclbin-name=${@F} --npu-insts-name=insts.txt $(<:%=../%)

${targetname}.exe: test.cpp
${targetname}.exe: ${srcdir}/test.cpp
rm -rf _build
mkdir -p _build
cd _build && ${powershell} cmake .. -DTARGET_NAME=${targetname} -DEDGEDETECT_WIDTH=${EDGEDETECT_WIDTH} -DEDGEDETECT_HEIGHT=${EDGEDETECT_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13
cd _build && ${powershell} cmake ${srcdir} -DTARGET_NAME=${targetname} -DEDGEDETECT_WIDTH=${EDGEDETECT_WIDTH} -DEDGEDETECT_HEIGHT=${EDGEDETECT_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13
cd _build && ${powershell} cmake --build . --config Release
ifeq "${powershell}" "powershell.exe"
cp _build/${targetname}.exe $@
Expand All @@ -57,4 +59,4 @@ run: ${targetname}.exe build/final_${EDGEDETECT_WIDTH}.xclbin build/insts.txt
${powershell} ./$< -x build/final_${EDGEDETECT_WIDTH}.xclbin -i build/insts.txt -k MLIR_AIE

clean:
rm -rf build _build ${targetname}.exe
rm -rf build _build ${targetname}.exe ${targetname}Out_test.jpg
17 changes: 0 additions & 17 deletions programming_examples/vision/edge_detect/run.lit

This file was deleted.

10 changes: 10 additions & 0 deletions programming_examples/vision/edge_detect/run_makefile.lit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// (c) Copyright 2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// REQUIRES: ryzen_ai, chess
//
// RUN: make -f %S/Makefile clean
// RUN: make -f %S/Makefile
// RUN: %run_on_npu make -f %S/Makefile run | FileCheck %s
// CHECK: PASS!

16 changes: 9 additions & 7 deletions programming_examples/vision/vision_passthrough/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#
##===----------------------------------------------------------------------===##

include ../../makefile-common
srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

VPATH := ../../../aie_kernels/generic
include ${srcdir}/../../makefile-common

VPATH := ${srcdir}/../../../aie_kernels/generic

PASSTHROUGH_WIDTH = 1920
PASSTHROUGH_HEIGHT = 1080
Expand All @@ -22,23 +24,23 @@ targetname = passThrough

all: build/final_${PASSTHROUGH_WIDTH}.xclbin

build/aie2_lineBased_8b_${PASSTHROUGH_WIDTH}.mlir: aie2.py
build/aie2_lineBased_8b_${PASSTHROUGH_WIDTH}.mlir: ${srcdir}/aie2.py
mkdir -p ${@D}
python3 $< ${PASSTHROUGH_WIDTH} ${PASSTHROUGH_HEIGHT} > $@

build/passThrough.cc.o: passThrough.cc
mkdir -p ${@D}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -DBIT_WIDTH=8 -c $(<:%=../%) -o ${@F}
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -DBIT_WIDTH=8 -c $< -o ${@F}

build/final_${PASSTHROUGH_WIDTH}.xclbin: build/aie2_lineBased_8b_${PASSTHROUGH_WIDTH}.mlir build/passThrough.cc.o
mkdir -p ${@D}
cd ${@D} && aiecc.py --aie-generate-cdo --aie-generate-npu --no-compile-host \
--xclbin-name=${@F} --npu-insts-name=insts.txt $(<:%=../%)

${targetname}.exe: test.cpp
${targetname}.exe: ${srcdir}/test.cpp
rm -rf _build
mkdir -p _build
cd _build && ${powershell} cmake .. -DTARGET_NAME=${targetname} -DPASSTHROUGH_WIDTH=${PASSTHROUGH_WIDTH} -DPASSTHROUGH_HEIGHT=${PASSTHROUGH_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13
cd _build && ${powershell} cmake ${srcdir} -DTARGET_NAME=${targetname} -DPASSTHROUGH_WIDTH=${PASSTHROUGH_WIDTH} -DPASSTHROUGH_HEIGHT=${PASSTHROUGH_HEIGHT} -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13
cd _build && ${powershell} cmake --build . --config Release
ifeq "${powershell}" "powershell.exe"
cp _build/${targetname}.exe $@
Expand All @@ -50,4 +52,4 @@ run: ${targetname}.exe build/final_${PASSTHROUGH_WIDTH}.xclbin build/insts.txt
${powershell} ./$< -x build/final_${PASSTHROUGH_WIDTH}.xclbin -i build/insts.txt -k MLIR_AIE

clean:
rm -rf build _build ${targetname}.exe
rm -rf build _build ${targetname}.exe ${targetname}Out_test.jpg
11 changes: 0 additions & 11 deletions programming_examples/vision/vision_passthrough/run.lit

This file was deleted.

10 changes: 10 additions & 0 deletions programming_examples/vision/vision_passthrough/run_makefile.lit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// (c) Copyright 2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// REQUIRES: ryzen_ai, chess
//
// RUN: make -f %S/Makefile clean
// RUN: make -f %S/Makefile
// RUN: %run_on_npu make -f %S/Makefile run | FileCheck %s
// CHECK: PASS!

0 comments on commit 05a31ec

Please sign in to comment.