Skip to content

Commit

Permalink
linux-dpdk: example: ml: include in build
Browse files Browse the repository at this point in the history
Include linux-dpdk/example/ml in build. It was removed in a recent
revert along with the onnx model based examples. The conv example is
skipped in make check, unless the model file is manually provided.

Signed-off-by: Jere Leppänen <[email protected]>
  • Loading branch information
JereLeppanen committed Sep 20, 2024
1 parent 03af119 commit f46244f
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if PLATFORM_IS_LINUX_DPDK
PLATFORM_DIR = platform/linux-dpdk
PLATFORM_DUMPCONF_DIR = platform/linux-dpdk/dumpconfig
PLATFORM_TEST_DIR = platform/linux-dpdk/test
PLATFORM_EXAMPLE_DIR = platform/linux-dpdk/example
endif

SUBDIRS = \
Expand Down
5 changes: 5 additions & 0 deletions platform/linux-dpdk/example/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SUBDIRS =

if WITH_ML
SUBDIRS += ml
endif
1 change: 1 addition & 0 deletions platform/linux-dpdk/example/ml/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conv.bin
34 changes: 34 additions & 0 deletions platform/linux-dpdk/example/ml/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include $(top_srcdir)/example/Makefile.inc

EXTRA_DIST = \
odp_ml_run_conv.sh \
conv.onnx \
conv_gen.py \
conv_gen.sh \
conv-input.bin \
conv-output.bin

if test_example
TESTS = odp_ml_run_conv.sh
endif

# If building out-of-tree, make check will not copy the scripts and data to the
# $(builddir) assuming that all commands are run locally. However this prevents
# running tests on a remote target using LOG_COMPILER.
# So copy all script and data files explicitly here.
all-local:
if [ "x$(srcdir)" != "x$(builddir)" ]; then \
for f in $(EXTRA_DIST); do \
if [ -e $(srcdir)/$$f ]; then \
mkdir -p $(builddir)/$$(dirname $$f); \
cp -f $(srcdir)/$$f $(builddir)/$$f; \
fi \
done \
fi

clean-local:
if [ "x$(srcdir)" != "x$(builddir)" ]; then \
for f in $(EXTRA_DIST); do \
rm -f $(builddir)/$$f; \
done \
fi
17 changes: 17 additions & 0 deletions platform/linux-dpdk/example/ml/conv_gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -ex
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Nokia

#
# This script requires the onnx python module. The mrvl-mlc and mlModel tools
# are expected to be in PATH. These tools are x86-64 binaries, so this script
# must be run on an x86-64 machine. However, the model can only be run on a
# machine equipped with the Marvell machine learning inference processor (MLIP).
#

python ./conv_gen.py
mrvl-mlc conv.onnx conv --num_tiles=1 --batch=1
mv bin_conv/conv.bin .
rm -rf bin_conv compiler_dir profile
mlModel -M -m conv.bin
1 change: 0 additions & 1 deletion platform/linux-dpdk/example/ml/odp_ml_run_conv.sh

This file was deleted.

28 changes: 28 additions & 0 deletions platform/linux-dpdk/example/ml/odp_ml_run_conv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Nokia

TEST_DIR="${TEST_DIR:-$(dirname $0)}"
MODEL_FILE=$TEST_DIR/conv.bin

# exit codes expected by automake for skipped tests
TEST_SKIPPED=77

# Skip test if model file is not found. The model file is compiled separately.
# See platform/linux-dpdk/example/ml/conv_gen.sh.

if [ ! -e "$MODEL_FILE" ]; then
echo "SKIP: ML model file ($MODEL_FILE) not found"
exit $TEST_SKIPPED
fi

../../../../example/ml/odp_ml_run${EXEEXT} \
-m $MODEL_FILE -i conv-input.bin -r conv-output.bin -q 1 -d 1

if [ $? -ne 0 ] ; then
echo Test FAILED
exit 1
fi

exit 0
2 changes: 2 additions & 0 deletions platform/linux-dpdk/m4/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ AM_CONDITIONAL([PLATFORM_IS_LINUX_DPDK],
AC_CONFIG_FILES([platform/linux-dpdk/Makefile
platform/linux-dpdk/libodp-dpdk.pc
platform/linux-dpdk/dumpconfig/Makefile
platform/linux-dpdk/example/Makefile
platform/linux-dpdk/example/ml/Makefile
platform/linux-dpdk/test/Makefile
platform/linux-dpdk/test/example/Makefile
platform/linux-dpdk/test/example/classifier/Makefile
Expand Down

0 comments on commit f46244f

Please sign in to comment.