diff options
Diffstat (limited to 'lib/oeqa/runtime/miutils/tests')
4 files changed, 161 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 @@ +import os +script_path = os.path.dirname(os.path.realpath(__file__)) +files_path = os.path.join(script_path, '../../files/') + +class DldtInferenceEngineTest(object): + ie_input_files = {'ie_python_sample': 'classification_sample.py', + 'input': 'chicky_512.png', + 'input_download': 'https://raw.githubusercontent.com/opencv/opencv/master/samples/data/chicky_512.png', + 'model': 'squeezenet_v1.1.xml'} + + def __init__(self, target, work_dir): + self.target = target + self.work_dir = work_dir + + def setup(self): + self.target.run('mkdir -p %s' % self.work_dir) + self.target.copy_to(os.path.join(files_path, 'dldt-inference-engine', self.ie_input_files['ie_python_sample']), + self.work_dir) + python_cmd = 'from openvino.inference_engine import IENetwork, IECore; ie = IECore(); print(ie.available_devices)' + __, output = self.target.run('python3 -c "%s"' % python_cmd) + self.available_devices = output + + def tear_down(self): + self.target.run('rm -rf %s' % self.work_dir) + + def test_check_if_openvino_device_available(self, device): + if device not in self.available_devices: + return False, self.available_devices + return True, self.available_devices + + def test_can_download_input_file(self, proxy_port): + return self.target.run('cd %s; wget %s -e https_proxy=%s' % + (self.work_dir, + self.ie_input_files['input_download'], + proxy_port)) + + def test_dldt_ie_classification_with_device(self, device, ir_files_dir): + return self.target.run('classification_sample_async -d %s -i %s -m %s' % + (device, + os.path.join(self.work_dir, self.ie_input_files['input']), + os.path.join(ir_files_dir, self.ie_input_files['model']))) + + def test_dldt_ie_classification_python_api_with_device(self, device, ir_files_dir, extension=''): + if extension: + return self.target.run('python3 %s -d %s -i %s -m %s -l %s' % + (os.path.join(self.work_dir, self.ie_input_files['ie_python_sample']), + device, + os.path.join(self.work_dir, self.ie_input_files['input']), + os.path.join(ir_files_dir, self.ie_input_files['model']), + extension)) + else: + return self.target.run('python3 %s -d %s -i %s -m %s' % + (os.path.join(self.work_dir, self.ie_input_files['ie_python_sample']), + device, + os.path.join(self.work_dir, self.ie_input_files['input']), + 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 @@ +import os + +class DldtModelOptimizerTest(object): + mo_input_files = {'model': 'squeezenet_v1.1.caffemodel', + 'prototxt': 'deploy.prototxt'} + mo_exe = 'mo.py' + + def __init__(self, target, work_dir): + self.target = target + self.work_dir = work_dir + + def setup(self): + self.target.run('mkdir -p %s' % self.work_dir) + + def tear_down(self): + self.target.run('rm -rf %s' % self.work_dir) + + def test_dldt_mo_can_create_ir(self, mo_exe_dir, mo_files_dir): + return self.target.run('python3 %s --input_model %s --input_proto %s --output_dir %s --data_type FP16' % + (os.path.join(mo_exe_dir, self.mo_exe), + os.path.join(mo_files_dir, self.mo_input_files['model']), + os.path.join(mo_files_dir, self.mo_input_files['prototxt']), + 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..13afd1a4 --- /dev/null +++ b/lib/oeqa/runtime/miutils/tests/mkl_dnn_test.py @@ -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')
\ 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 @@ +class SqueezenetModelDownloadTest(object): + download_files = {'squeezenet1.1.prototxt': 'https://raw.githubusercontent.com/DeepScale/SqueezeNet/a47b6f13d30985279789d08053d37013d67d131b/SqueezeNet_v1.1/deploy.prototxt', + 'squeezenet1.1.caffemodel': 'https://github.com/DeepScale/SqueezeNet/raw/a47b6f13d30985279789d08053d37013d67d131b/SqueezeNet_v1.1/squeezenet_v1.1.caffemodel'} + + def __init__(self, target, work_dir): + self.target = target + self.work_dir = work_dir + + def setup(self): + self.target.run('mkdir -p %s' % self.work_dir) + + def tear_down(self): + self.target.run('rm -rf %s' % self.work_dir) + + def test_can_download_squeezenet_model(self, proxy_port): + return self.target.run('cd %s; wget %s -e https_proxy=%s' % + (self.work_dir, + self.download_files['squeezenet1.1.caffemodel'], + proxy_port)) + + def test_can_download_squeezenet_prototxt(self, proxy_port): + return self.target.run('cd %s; wget %s -e https_proxy=%s' % + (self.work_dir, + self.download_files['squeezenet1.1.prototxt'], + proxy_port)) |