summaryrefslogtreecommitdiffstats
path: root/lib/oeqa/runtime/miutils/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oeqa/runtime/miutils/tests')
-rw-r--r--lib/oeqa/runtime/miutils/tests/dldt_inference_engine_test.py56
-rw-r--r--lib/oeqa/runtime/miutils/tests/dldt_model_optimizer_test.py23
-rw-r--r--lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py55
-rw-r--r--lib/oeqa/runtime/miutils/tests/squeezenet_model_download_test.py25
4 files changed, 159 insertions, 0 deletions
diff --git a/lib/oeqa/runtime/miutils/tests/dldt_inference_engine_test.py b/lib/oeqa/runtime/miutils/tests/dldt_inference_engine_test.py
new file mode 100644
index 00000000..31bfb539
--- /dev/null
+++ b/lib/oeqa/runtime/miutils/tests/dldt_inference_engine_test.py
@@ -0,0 +1,56 @@
1import os
2script_path = os.path.dirname(os.path.realpath(__file__))
3files_path = os.path.join(script_path, '../../files/')
4
5class DldtInferenceEngineTest(object):
6 ie_input_files = {'ie_python_sample': 'classification_sample.py',
7 'input': 'chicky_512.png',
8 'input_download': 'https://raw.githubusercontent.com/opencv/opencv/master/samples/data/chicky_512.png',
9 'model': 'squeezenet_v1.1.xml'}
10
11 def __init__(self, target, work_dir):
12 self.target = target
13 self.work_dir = work_dir
14
15 def setup(self):
16 self.target.run('mkdir -p %s' % self.work_dir)
17 self.target.copy_to(os.path.join(files_path, 'dldt-inference-engine', self.ie_input_files['ie_python_sample']),
18 self.work_dir)
19 python_cmd = 'from openvino.inference_engine import IENetwork, IECore; ie = IECore(); print(ie.available_devices)'
20 __, output = self.target.run('python3 -c "%s"' % python_cmd)
21 self.available_devices = output
22
23 def tear_down(self):
24 self.target.run('rm -rf %s' % self.work_dir)
25
26 def test_check_if_openvino_device_available(self, device):
27 if device not in self.available_devices:
28 return False, self.available_devices
29 return True, self.available_devices
30
31 def test_can_download_input_file(self, proxy_port):
32 return self.target.run('cd %s; wget %s -e https_proxy=%s' %
33 (self.work_dir,
34 self.ie_input_files['input_download'],
35 proxy_port))
36
37 def test_dldt_ie_classification_with_device(self, device, ir_files_dir):
38 return self.target.run('classification_sample_async -d %s -i %s -m %s' %
39 (device,
40 os.path.join(self.work_dir, self.ie_input_files['input']),
41 os.path.join(ir_files_dir, self.ie_input_files['model'])))
42
43 def test_dldt_ie_classification_python_api_with_device(self, device, ir_files_dir, extension=''):
44 if extension:
45 return self.target.run('python3 %s -d %s -i %s -m %s -l %s' %
46 (os.path.join(self.work_dir, self.ie_input_files['ie_python_sample']),
47 device,
48 os.path.join(self.work_dir, self.ie_input_files['input']),
49 os.path.join(ir_files_dir, self.ie_input_files['model']),
50 extension))
51 else:
52 return self.target.run('python3 %s -d %s -i %s -m %s' %
53 (os.path.join(self.work_dir, self.ie_input_files['ie_python_sample']),
54 device,
55 os.path.join(self.work_dir, self.ie_input_files['input']),
56 os.path.join(ir_files_dir, self.ie_input_files['model'])))
diff --git a/lib/oeqa/runtime/miutils/tests/dldt_model_optimizer_test.py b/lib/oeqa/runtime/miutils/tests/dldt_model_optimizer_test.py
new file mode 100644
index 00000000..7d3db15b
--- /dev/null
+++ b/lib/oeqa/runtime/miutils/tests/dldt_model_optimizer_test.py
@@ -0,0 +1,23 @@
1import os
2
3class DldtModelOptimizerTest(object):
4 mo_input_files = {'model': 'squeezenet_v1.1.caffemodel',
5 'prototxt': 'deploy.prototxt'}
6 mo_exe = 'mo.py'
7
8 def __init__(self, target, work_dir):
9 self.target = target
10 self.work_dir = work_dir
11
12 def setup(self):
13 self.target.run('mkdir -p %s' % self.work_dir)
14
15 def tear_down(self):
16 self.target.run('rm -rf %s' % self.work_dir)
17
18 def test_dldt_mo_can_create_ir(self, mo_exe_dir, mo_files_dir):
19 return self.target.run('python3 %s --input_model %s --input_proto %s --output_dir %s --data_type FP16' %
20 (os.path.join(mo_exe_dir, self.mo_exe),
21 os.path.join(mo_files_dir, self.mo_input_files['model']),
22 os.path.join(mo_files_dir, self.mo_input_files['prototxt']),
23 self.work_dir))
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..869a4cbe
--- /dev/null
+++ b/lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py
@@ -0,0 +1,55 @@
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/onednn/'
13 mkldnn_src_test_filename = 'api.c'
14 mkldnn_src_test_file = ''
15
16 (__, output) = self.target.run('cd %s; find -name %s' % (mkldnn_src_dir, mkldnn_src_test_filename))
17 if 'No such file or directory' in output:
18 return -1, 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 return self._run_mkldnn_benchdnn_test('./benchdnn --rnn --batch=inputs/rnn/test_rnn_all')
53
54 def test_mkldnn_shuffle_api(self):
55 return self._run_mkldnn_benchdnn_test('./benchdnn --shuffle --batch=inputs/shuffle/test_shuffle_bfloat16') \ No newline at end of file
diff --git a/lib/oeqa/runtime/miutils/tests/squeezenet_model_download_test.py b/lib/oeqa/runtime/miutils/tests/squeezenet_model_download_test.py
new file mode 100644
index 00000000..a3e46a0a
--- /dev/null
+++ b/lib/oeqa/runtime/miutils/tests/squeezenet_model_download_test.py
@@ -0,0 +1,25 @@
1class SqueezenetModelDownloadTest(object):
2 download_files = {'squeezenet1.1.prototxt': 'https://raw.githubusercontent.com/DeepScale/SqueezeNet/a47b6f13d30985279789d08053d37013d67d131b/SqueezeNet_v1.1/deploy.prototxt',
3 'squeezenet1.1.caffemodel': 'https://github.com/DeepScale/SqueezeNet/raw/a47b6f13d30985279789d08053d37013d67d131b/SqueezeNet_v1.1/squeezenet_v1.1.caffemodel'}
4
5 def __init__(self, target, work_dir):
6 self.target = target
7 self.work_dir = work_dir
8
9 def setup(self):
10 self.target.run('mkdir -p %s' % self.work_dir)
11
12 def tear_down(self):
13 self.target.run('rm -rf %s' % self.work_dir)
14
15 def test_can_download_squeezenet_model(self, proxy_port):
16 return self.target.run('cd %s; wget %s -e https_proxy=%s' %
17 (self.work_dir,
18 self.download_files['squeezenet1.1.caffemodel'],
19 proxy_port))
20
21 def test_can_download_squeezenet_prototxt(self, proxy_port):
22 return self.target.run('cd %s; wget %s -e https_proxy=%s' %
23 (self.work_dir,
24 self.download_files['squeezenet1.1.prototxt'],
25 proxy_port))