mirror of
git://git.yoctoproject.org/meta-intel.git
synced 2025-07-19 21:09:03 +02:00
oeqa/runtime/mkl_dnn: Add mkldnn tests
Add automated tests that: - test that mkl_dnn shared libraries and headers can be used to compile mkl_dnn sample application and execute it - test that mkl_dnn various api (eg. convolution, deconv, rnn, etc) are executable - add extra packages checking for test compiling mkldnn application Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
This commit is contained in:
parent
f23e067e86
commit
0c092dde58
67
lib/oeqa/runtime/cases/mkl_dnn.py
Normal file
67
lib/oeqa/runtime/cases/mkl_dnn.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
from oeqa.runtime.case import OERuntimeTestCase
|
||||||
|
from oeqa.runtime.decorator.package import OEHasPackage
|
||||||
|
from oeqa.core.decorator.depends import OETestDepends
|
||||||
|
from oeqa.runtime.miutils.targets.oeqatarget import OEQATarget
|
||||||
|
from oeqa.runtime.miutils.tests.mkl_dnn_test import MkldnnTest
|
||||||
|
|
||||||
|
class MklDnn(OERuntimeTestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.mkldnntest = MkldnnTest(OEQATarget(cls.tc.target))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.mkldnntest.tear_down()
|
||||||
|
|
||||||
|
@OEHasPackage(['libdnnl', 'libdnnl1'])
|
||||||
|
@OEHasPackage(['libdnnl-src'])
|
||||||
|
@OEHasPackage(['libdnnl-dev'])
|
||||||
|
@OEHasPackage(['gcc'])
|
||||||
|
@OEHasPackage(['gcc-symlinks'])
|
||||||
|
@OEHasPackage(['libstdc++-dev'])
|
||||||
|
@OEHasPackage(['binutils'])
|
||||||
|
def test_mkldnn_can_compile_and_execute(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_can_compile_and_execute()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OEHasPackage(['mkl-dnn', 'libdnnl1'])
|
||||||
|
@OEHasPackage(['mkl-dnn-test', 'libdnnl-test'])
|
||||||
|
def test_mkldnn_benchdnn_package_available(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_benchdnn_package_available()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
|
||||||
|
def test_mkldnn_conv_api(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_conv_api()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
|
||||||
|
def test_mkldnn_bnorm_api(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_bnorm_api()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
|
||||||
|
def test_mkldnn_deconv_api(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_deconv_api()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
|
||||||
|
def test_mkldnn_ip_api(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_ip_api()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
|
||||||
|
def test_mkldnn_reorder_api(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_reorder_api()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
|
||||||
|
def test_mkldnn_rnn_api(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_rnn_api()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
||||||
|
|
||||||
|
@OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
|
||||||
|
def test_mkldnn_shuffle_api(self):
|
||||||
|
(status, output) = self.mkldnntest.test_mkldnn_shuffle_api()
|
||||||
|
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
|
57
lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py
Normal file
57
lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
|
||||||
|
class MkldnnTest(object):
|
||||||
|
mkldnn_target_test_filename = 'mkl-dnn-c'
|
||||||
|
|
||||||
|
def __init__(self, target):
|
||||||
|
self.target = target
|
||||||
|
|
||||||
|
def tear_down(self):
|
||||||
|
self.target.run('rm /tmp/%s' % self.mkldnn_target_test_filename)
|
||||||
|
|
||||||
|
def test_mkldnn_can_compile_and_execute(self):
|
||||||
|
mkldnn_src_dir = '/usr/src/debug/mkl-dnn/'
|
||||||
|
mkldnn_src_test_filename = 'api.c'
|
||||||
|
mkldnn_src_test_file = ''
|
||||||
|
|
||||||
|
(status, output) = self.target.run('cd %s; find -name %s' % (mkldnn_src_dir, mkldnn_src_test_filename))
|
||||||
|
if status:
|
||||||
|
return status, output
|
||||||
|
|
||||||
|
mkldnn_src_test_file = os.path.join(mkldnn_src_dir, output)
|
||||||
|
(status, output) = self.target.run('gcc %s -o /tmp/%s -ldnnl' % (mkldnn_src_test_file, self.mkldnn_target_test_filename))
|
||||||
|
if status:
|
||||||
|
return status, output
|
||||||
|
|
||||||
|
(status, output) = self.target.run('cd /tmp; ./%s' % self.mkldnn_target_test_filename)
|
||||||
|
return status, output
|
||||||
|
|
||||||
|
def test_mkldnn_benchdnn_package_available(self):
|
||||||
|
(status, output) = self.target.run('ls /usr/bin/mkl-dnn/tests/benchdnn')
|
||||||
|
return status, output
|
||||||
|
|
||||||
|
def _run_mkldnn_benchdnn_test(self, cmd):
|
||||||
|
(status, output) = self.target.run('cd /usr/bin/mkl-dnn/tests/benchdnn; %s' % cmd)
|
||||||
|
return status, output
|
||||||
|
|
||||||
|
def test_mkldnn_conv_api(self):
|
||||||
|
return self._run_mkldnn_benchdnn_test('./benchdnn --conv --batch=inputs/conv/test_conv_3d')
|
||||||
|
|
||||||
|
def test_mkldnn_bnorm_api(self):
|
||||||
|
return self._run_mkldnn_benchdnn_test('./benchdnn --bnorm --batch=inputs/bnorm/test_bnorm_regressions')
|
||||||
|
|
||||||
|
def test_mkldnn_deconv_api(self):
|
||||||
|
return self._run_mkldnn_benchdnn_test('./benchdnn --deconv --batch=inputs/deconv/test_deconv_bfloat16')
|
||||||
|
|
||||||
|
def test_mkldnn_ip_api(self):
|
||||||
|
return self._run_mkldnn_benchdnn_test('./benchdnn --ip --batch=inputs/ip/test_ip_bfloat16')
|
||||||
|
|
||||||
|
def test_mkldnn_reorder_api(self):
|
||||||
|
return self._run_mkldnn_benchdnn_test('./benchdnn --reorder --batch=inputs/reorder/test_reorder_bfloat16')
|
||||||
|
|
||||||
|
def test_mkldnn_rnn_api(self):
|
||||||
|
# test_rnn_inference was not yet ready and was expected to fail
|
||||||
|
# while waiting it to be ready, use test_rnn_small for now
|
||||||
|
return self._run_mkldnn_benchdnn_test('./benchdnn --rnn --batch=inputs/rnn/test_rnn_small')
|
||||||
|
|
||||||
|
def test_mkldnn_shuffle_api(self):
|
||||||
|
return self._run_mkldnn_benchdnn_test('./benchdnn --shuffle --batch=inputs/shuffle/test_shuffle_bfloat16')
|
Loading…
Reference in New Issue
Block a user