Skip to content

Commit

Permalink
Fixup test
Browse files Browse the repository at this point in the history
  • Loading branch information
jgmelber committed Oct 24, 2024
1 parent c7fdd9e commit a287f46
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
21 changes: 10 additions & 11 deletions programming_examples/basic/passthrough_kernel/Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

include ${srcdir}/../../makefile-common

devicename = npu
device = npu
targetname = passThroughKernel
VPATH := ${srcdir}/../../../aie_kernels/generic
data_size = 4096
Expand All @@ -25,22 +25,21 @@ all: build/final_${data_size}.xclbin

build/aie2_lineBased_8b_${data_size}.mlir: ${srcdir}/aie2.py
mkdir -p ${@D}
python3 $< ${devicename} ${data_size} 0 > $@
python3 $< ${device} ${data_size} 0 > $@

build/aie_trace__lineBased_8b_${data_size}.mlir: ${srcdir}/aie2.py
mkdir -p ${@D}
python3 $< ${data_size} ${trace_size} > $@
python3 $< ${device} ${data_size} ${trace_size} > $@

build/passThrough.cc.o: passThrough.cc
mkdir -p ${@D}
ifeq ($(devicename), npu)
cd ${@D} && ${PEANO_INSTALL_DIR}/bin/clang++ ${PEANOWRAP2_FLAGS} -DBIT_WIDTH=8 -c $< -o ${@F}
else ifeq ($(devicename), npu2)
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2P_FLAGS} -DBIT_WIDTH=8 -c $< -o ${@F}
else
echo "Device type not supported"
endif
endif
ifeq ($(device),npu)
cd ${@D} && ${PEANO_INSTALL_DIR}/bin/clang++ ${PEANOWRAP2_FLAGS} -DBIT_WIDTH=8 -c $< -o ${@F}
else ifeq ($(device),npu2)
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2P_FLAGS} -DBIT_WIDTH=8 -c $< -o ${@F}
else
echo "Device type not supported"
endif

build/final_${data_size}.xclbin: build/aie2_lineBased_8b_${data_size}.mlir build/passThrough.cc.o
mkdir -p ${@D}
Expand Down
25 changes: 11 additions & 14 deletions programming_examples/basic/passthrough_kernel/aie2.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,10 @@
import aie.utils.trace as trace_utils


def passthroughKernel(vector_size, trace_size):
def passthroughKernel(dev, vector_size, trace_size):
N = vector_size
lineWidthInBytes = N // 4 # chop input in 4 sub-tensors

if len(sys.argv) != 3:
raise ValueError("[ERROR] Need command line arguments (Device name, Vector size)")

if sys.argv[1] == "npu":
dev = AIEDevice.npu1_1col
elif sys.argv[1] == "npu2":
dev = AIEDevice.npu2
else:
raise ValueError("[ERROR] Device name {} is unknown".format(sys.argv[1]))

@device(dev)
def device_body():
# define types
Expand Down Expand Up @@ -95,13 +85,20 @@ def sequence(inTensor, outTensor, notUsed):


try:
vector_size = int(sys.argv[1])
device_name = str(sys.argv[1])
if device_name == "npu":
dev = AIEDevice.npu1_1col
elif device_name == "npu2":
dev = AIEDevice.npu2
else:
raise ValueError("[ERROR] Device name {} is unknown".format(sys.argv[1]))
vector_size = int(sys.argv[2])
if vector_size % 64 != 0 or vector_size < 512:
print("Vector size must be a multiple of 64 and greater than or equal to 512")
raise ValueError
trace_size = 0 if (len(sys.argv) != 3) else int(sys.argv[2])
trace_size = 0 if (len(sys.argv) != 4) else int(sys.argv[3])
except ValueError:
print("Argument has inappropriate value")
with mlir_mod_ctx() as ctx:
passthroughKernel(vector_size, trace_size)
passthroughKernel(dev, vector_size, trace_size)
print(ctx.module)
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 device=npu2
// RUN: %run_on_npu make -f %S/Makefile run device=npu2 | FileCheck %s
// CHECK: Running...
// CHECK: PASS!

0 comments on commit a287f46

Please sign in to comment.