summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/oeqa/runtime/cases/mkl_dnn.py67
-rw-r--r--lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py57
2 files changed, 124 insertions, 0 deletions
diff --git a/lib/oeqa/runtime/cases/mkl_dnn.py b/lib/oeqa/runtime/cases/mkl_dnn.py
new file mode 100644
index 00000000..c7994b13
--- /dev/null
+++ b/lib/oeqa/runtime/cases/mkl_dnn.py
@@ -0,0 +1,67 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.runtime.decorator.package import OEHasPackage
3from oeqa.core.decorator.depends import OETestDepends
4from oeqa.runtime.miutils.targets.oeqatarget import OEQATarget
5from oeqa.runtime.miutils.tests.mkl_dnn_test import MkldnnTest
6
7class MklDnn(OERuntimeTestCase):
8
9 @classmethod
10 def setUpClass(cls):
11 cls.mkldnntest = MkldnnTest(OEQATarget(cls.tc.target))
12
13 @classmethod
14 def tearDownClass(cls):
15 cls.mkldnntest.tear_down()
16
17 @OEHasPackage(['libdnnl', 'libdnnl1'])
18 @OEHasPackage(['libdnnl-src'])
19 @OEHasPackage(['libdnnl-dev'])
20 @OEHasPackage(['gcc'])
21 @OEHasPackage(['gcc-symlinks'])
22 @OEHasPackage(['libstdc++-dev'])
23 @OEHasPackage(['binutils'])
24 def test_mkldnn_can_compile_and_execute(self):
25 (status, output) = self.mkldnntest.test_mkldnn_can_compile_and_execute()
26 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
27
28 @OEHasPackage(['mkl-dnn', 'libdnnl1'])
29 @OEHasPackage(['mkl-dnn-test', 'libdnnl-test'])
30 def test_mkldnn_benchdnn_package_available(self):
31 (status, output) = self.mkldnntest.test_mkldnn_benchdnn_package_available()
32 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
33
34 @OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
35 def test_mkldnn_conv_api(self):
36 (status, output) = self.mkldnntest.test_mkldnn_conv_api()
37 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
38
39 @OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
40 def test_mkldnn_bnorm_api(self):
41 (status, output) = self.mkldnntest.test_mkldnn_bnorm_api()
42 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
43
44 @OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
45 def test_mkldnn_deconv_api(self):
46 (status, output) = self.mkldnntest.test_mkldnn_deconv_api()
47 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
48
49 @OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
50 def test_mkldnn_ip_api(self):
51 (status, output) = self.mkldnntest.test_mkldnn_ip_api()
52 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
53
54 @OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
55 def test_mkldnn_reorder_api(self):
56 (status, output) = self.mkldnntest.test_mkldnn_reorder_api()
57 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
58
59 @OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
60 def test_mkldnn_rnn_api(self):
61 (status, output) = self.mkldnntest.test_mkldnn_rnn_api()
62 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
63
64 @OETestDepends(['mkl_dnn.MklDnn.test_mkldnn_benchdnn_package_available'])
65 def test_mkldnn_shuffle_api(self):
66 (status, output) = self.mkldnntest.test_mkldnn_shuffle_api()
67 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
diff --git a/lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py b/lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py
new file mode 100644
index 00000000..13afd1a4
--- /dev/null
+++ b/lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py
@@ -0,0 +1,57 @@
1
2class MkldnnTest(object):
3 mkldnn_target_test_filename = 'mkl-dnn-c'
4
5 def __init__(self, target):
6 self.target = target
7
8 def tear_down(self):
9 self.target.run('rm /tmp/%s' % self.mkldnn_target_test_filename)
10
11 def test_mkldnn_can_compile_and_execute(self):
12 mkldnn_src_dir = '/usr/src/debug/mkl-dnn/'
13 mkldnn_src_test_filename = 'api.c'
14 mkldnn_src_test_file = ''
15
16 (status, output) = self.target.run('cd %s; find -name %s' % (mkldnn_src_dir, mkldnn_src_test_filename))
17 if status:
18 return status, output
19
20 mkldnn_src_test_file = os.path.join(mkldnn_src_dir, output)
21 (status, output) = self.target.run('gcc %s -o /tmp/%s -ldnnl' % (mkldnn_src_test_file, self.mkldnn_target_test_filename))
22 if status:
23 return status, output
24
25 (status, output) = self.target.run('cd /tmp; ./%s' % self.mkldnn_target_test_filename)
26 return status, output
27
28 def test_mkldnn_benchdnn_package_available(self):
29 (status, output) = self.target.run('ls /usr/bin/mkl-dnn/tests/benchdnn')
30 return status, output
31
32 def _run_mkldnn_benchdnn_test(self, cmd):
33 (status, output) = self.target.run('cd /usr/bin/mkl-dnn/tests/benchdnn; %s' % cmd)
34 return status, output
35
36 def test_mkldnn_conv_api(self):
37 return self._run_mkldnn_benchdnn_test('./benchdnn --conv --batch=inputs/conv/test_conv_3d')
38
39 def test_mkldnn_bnorm_api(self):
40 return self._run_mkldnn_benchdnn_test('./benchdnn --bnorm --batch=inputs/bnorm/test_bnorm_regressions')
41
42 def test_mkldnn_deconv_api(self):
43 return self._run_mkldnn_benchdnn_test('./benchdnn --deconv --batch=inputs/deconv/test_deconv_bfloat16')
44
45 def test_mkldnn_ip_api(self):
46 return self._run_mkldnn_benchdnn_test('./benchdnn --ip --batch=inputs/ip/test_ip_bfloat16')
47
48 def test_mkldnn_reorder_api(self):
49 return self._run_mkldnn_benchdnn_test('./benchdnn --reorder --batch=inputs/reorder/test_reorder_bfloat16')
50
51 def test_mkldnn_rnn_api(self):
52 # test_rnn_inference was not yet ready and was expected to fail
53 # while waiting it to be ready, use test_rnn_small for now
54 return self._run_mkldnn_benchdnn_test('./benchdnn --rnn --batch=inputs/rnn/test_rnn_small')
55
56 def test_mkldnn_shuffle_api(self):
57 return self._run_mkldnn_benchdnn_test('./benchdnn --shuffle --batch=inputs/shuffle/test_shuffle_bfloat16') \ No newline at end of file