Skip to content

Commit

Permalink
linux-dpdk: validation: ml: add validation tests
Browse files Browse the repository at this point in the history
Add validation tests for the new mldev based ML implementation.

Signed-off-by: Jere Leppänen <[email protected]>
  • Loading branch information
JereLeppanen committed Jun 13, 2024
1 parent f1d2b55 commit b963a6f
Show file tree
Hide file tree
Showing 9 changed files with 1,166 additions and 0 deletions.
1 change: 1 addition & 0 deletions platform/linux-dpdk/m4/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ AC_CONFIG_FILES([platform/linux-dpdk/Makefile
platform/linux-dpdk/test/example/switch/Makefile
platform/linux-dpdk/test/performance/Makefile
platform/linux-dpdk/test/performance/dmafwd/Makefile
platform/linux-dpdk/test/validation/api/ml/Makefile
platform/linux-dpdk/test/validation/api/pktio/Makefile])
])
5 changes: 5 additions & 0 deletions platform/linux-dpdk/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ test_SCRIPTS = $(dist_check_SCRIPTS)
SUBDIRS += validation/api/pktio \
example \
performance

if WITH_ML
SUBDIRS += validation/api/ml
endif

else
#performance tests refer to pktio_env
if test_perf
Expand Down
2 changes: 2 additions & 0 deletions platform/linux-dpdk/test/validation/api/ml/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ml_dpdk
conv.bin
33 changes: 33 additions & 0 deletions platform/linux-dpdk/test/validation/api/ml/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include ../Makefile.inc

test_PROGRAMS = ml_dpdk
ml_dpdk_SOURCES = ml_dpdk.c

dist_check_SCRIPTS = ml_dpdk.sh

test_SCRIPTS = $(dist_check_SCRIPTS)

TESTS = $(test_SCRIPTS)

EXTRA_DIST = conv_gen.py conv.onnx

# 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
Binary file added platform/linux-dpdk/test/validation/api/ml/conv.onnx
Binary file not shown.
34 changes: 34 additions & 0 deletions platform/linux-dpdk/test/validation/api/ml/conv_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Nokia
#

import onnx
from onnx import helper
from onnx import TensorProto

graph = helper.make_graph(
[ # nodes
helper.make_node("Conv", ["X", "W"], ["Y"], "Conv Node"),
],
"Test Graph", # name
[ # inputs
helper.make_tensor_value_info('X', TensorProto.FLOAT, [1, 1, 1, 2]),
],
[ # outputs
helper.make_tensor_value_info('Y', TensorProto.FLOAT, [1, 1, 1, 2]),
],
[ # initializer
helper.make_tensor('W', TensorProto.FLOAT, [1, 1, 1, 1], [2.0]),
],
)

model = helper.make_model(
graph,
opset_imports=[helper.make_opsetid("", 14)],
producer_name='ODP validation tests',
model_version=1,
doc_string="output = 2 * input",
ir_version = 8
)

onnx.save(model, 'conv.onnx')
10 changes: 10 additions & 0 deletions platform/linux-dpdk/test/validation/api/ml/conv_gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh -ex
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Nokia

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
Loading

0 comments on commit b963a6f

Please sign in to comment.