aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Macenauer <pavel.macenauer@linaro.org>2020-04-15 13:28:29 +0000
committerNina Drozd <nina.drozd@arm.com>2020-05-05 16:44:13 +0000
commit5e123f8eeca810507b3de80643ccca19ff954d68 (patch)
treeb85b4dea49297d54e2e61ec4bd68b4f030f37a94
parentb6390dd58a860e8e05947e9108da9e45098ddb0e (diff)
downloadarmnn-5e123f8eeca810507b3de80643ccca19ff954d68.tar.gz
Move PyArmNN test resources to external storage
Change-Id: Ie2c94c8c58ed2964017bc049676ff32dc54c4ad0 Signed-off-by: Pavel Macenauer <pavel.macenauer@nxp.com>
-rw-r--r--python/pyarmnn/README.md15
-rw-r--r--python/pyarmnn/scripts/download_test_resources.py44
-rw-r--r--python/pyarmnn/scripts/requirements.txt3
-rw-r--r--python/pyarmnn/test/testdata/shared/caffe_parser/golden_output_caffe.npybin168 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/caffe_parser/input_caffe.npybin3264 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/license.txt10
-rw-r--r--python/pyarmnn/test/testdata/shared/mock_model.caffemodelbin138926 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/mock_model.onnxbin139104 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/mock_model.pbbin141105 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/mock_model.tflitebin37944 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/mock_profile_out.json216
-rw-r--r--python/pyarmnn/test/testdata/shared/onnx_parser/golden_output_onnx.npybin168 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/onnx_parser/input_onnx.npybin3264 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/tf_parser/golden_output_tf.npybin168 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/tf_parser/input_tf.npybin3264 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/tflite_parser/golden_output_lite.npybin138 -> 0 bytes
-rw-r--r--python/pyarmnn/test/testdata/shared/tflite_parser/input_lite.npybin912 -> 0 bytes
-rw-r--r--python/pyarmnn/tox.ini2
18 files changed, 59 insertions, 231 deletions
diff --git a/python/pyarmnn/README.md b/python/pyarmnn/README.md
index a8f7573826..25213bb26e 100644
--- a/python/pyarmnn/README.md
+++ b/python/pyarmnn/README.md
@@ -155,19 +155,24 @@ Before building package or running tests you need to generate SWIG wrappers base
It can be done with tox target 'gen':
```bash
-tox -e gen
+$ tox -e gen
```
## Running unit-tests
-Execute command from the project root dir:
+Download resources required to run unit tests by executing the script in the scripts folder:
+```
+$ python ./scripts/download_test_resources.py
+```
+
+The script will download an archive from the Linaro server and extract it. A folder `test/testdata/shared` will be created. Execute `pytest` from the project root dir:
```bash
-$ tox
+$ python -m pytest test/ -v
```
-or
+or run tox which will do both:
```bash
-$ pytest -v
+$ tox
```
## Build python distr
diff --git a/python/pyarmnn/scripts/download_test_resources.py b/python/pyarmnn/scripts/download_test_resources.py
new file mode 100644
index 0000000000..b166ed77be
--- /dev/null
+++ b/python/pyarmnn/scripts/download_test_resources.py
@@ -0,0 +1,44 @@
+"""Downloads and extracts resources for unit tests.
+
+It is mandatory to run this script prior to running unit tests. Resources are stored as a tar.gz or a tar.bz2 archive and
+extracted into the test/testdata/shared folder.
+"""
+
+import tarfile
+import requests
+import os
+import uuid
+
+SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
+EXTRACT_DIR = os.path.join(SCRIPTS_DIR, "..", "test")
+ARCHIVE_URL = "https://snapshots.linaro.org/components/pyarmnn-tests/pyarmnn_testdata_200500_20200415.tar.bz2"
+
+
+def download_resources(url, save_path):
+ # download archive - only support tar.gz or tar.bz2
+ print("Downloading '{}'".format(url))
+ temp_filename = str(uuid.uuid4())
+ if url.endswith(".tar.bz2"):
+ temp_filename += ".tar.bz2"
+ elif url.endswith(".tar.gz"):
+ temp_filename += ".tar.gz"
+ else:
+ raise RuntimeError("Unsupported file.")
+ try:
+ r = requests.get(url, stream=True)
+ except requests.exceptions.RequestException as e:
+ raise RuntimeError("Unable to download file: {}".format(e))
+ file_path = os.path.join(save_path, temp_filename)
+ with open(file_path, 'wb') as f:
+ f.write(r.content)
+
+ # extract and delete temp file
+ with tarfile.open(file_path, "r:bz2" if temp_filename.endswith(".tar.bz2") else "r:gz") as tar:
+ print("Extracting '{}'".format(file_path))
+ tar.extractall(save_path)
+ if os.path.exists(file_path):
+ print("Removing '{}'".format(file_path))
+ os.remove(file_path)
+
+
+download_resources(ARCHIVE_URL, EXTRACT_DIR)
diff --git a/python/pyarmnn/scripts/requirements.txt b/python/pyarmnn/scripts/requirements.txt
new file mode 100644
index 0000000000..6f6296c244
--- /dev/null
+++ b/python/pyarmnn/scripts/requirements.txt
@@ -0,0 +1,3 @@
+requests==2.23.0
+pdoc3==0.6.3
+pyarmnn>=19.8.0
diff --git a/python/pyarmnn/test/testdata/shared/caffe_parser/golden_output_caffe.npy b/python/pyarmnn/test/testdata/shared/caffe_parser/golden_output_caffe.npy
deleted file mode 100644
index 007141cb9f..0000000000
--- a/python/pyarmnn/test/testdata/shared/caffe_parser/golden_output_caffe.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/caffe_parser/input_caffe.npy b/python/pyarmnn/test/testdata/shared/caffe_parser/input_caffe.npy
deleted file mode 100644
index 15df758b58..0000000000
--- a/python/pyarmnn/test/testdata/shared/caffe_parser/input_caffe.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/license.txt b/python/pyarmnn/test/testdata/shared/license.txt
deleted file mode 100644
index 1e95a68e0d..0000000000
--- a/python/pyarmnn/test/testdata/shared/license.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-This folder contains models and data needed for the testing of PyArmNN.
-
-All models and files found in this folder were created by ARM for the purpose
-of testing PyArmNN.
-
-All the contents of this folder are distributed with the following license.
-
-Copyright © 2020 Arm Ltd. All rights reserved.
-SPDX-License-Identifier: MIT
-
diff --git a/python/pyarmnn/test/testdata/shared/mock_model.caffemodel b/python/pyarmnn/test/testdata/shared/mock_model.caffemodel
deleted file mode 100644
index df4079b729..0000000000
--- a/python/pyarmnn/test/testdata/shared/mock_model.caffemodel
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/mock_model.onnx b/python/pyarmnn/test/testdata/shared/mock_model.onnx
deleted file mode 100644
index c1b506cc16..0000000000
--- a/python/pyarmnn/test/testdata/shared/mock_model.onnx
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/mock_model.pb b/python/pyarmnn/test/testdata/shared/mock_model.pb
deleted file mode 100644
index cff9dc7add..0000000000
--- a/python/pyarmnn/test/testdata/shared/mock_model.pb
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/mock_model.tflite b/python/pyarmnn/test/testdata/shared/mock_model.tflite
deleted file mode 100644
index 0b8944d3ed..0000000000
--- a/python/pyarmnn/test/testdata/shared/mock_model.tflite
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/mock_profile_out.json b/python/pyarmnn/test/testdata/shared/mock_profile_out.json
deleted file mode 100644
index 8e1056160b..0000000000
--- a/python/pyarmnn/test/testdata/shared/mock_profile_out.json
+++ /dev/null
@@ -1,216 +0,0 @@
-{
- "ArmNN": {
- "inference_measurements_#1": {
- "type": "Event",
- "Wall clock time_#1": {
- "type": "Measurement",
- "raw": [
- 1.1,
- 2.2,
- 3.3,
- 4.4,
- 5.5,
- 6.6
- ],
- "unit": "us"
- },
-
- "Execute_#2": {
- "type": "Event",
- "Wall clock time_#2": {
- "type": "Measurement",
- "raw": [
- 1.1,
- 2.2,
- 3.3,
- 4.4,
- 5.5,
- 6.6
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#2": {
- "type": "Measurement",
- "raw": [
- 1,
- 1,
- 1,
- 1,
- 1,
- 1
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#2": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
-
- "RefSomeMock1dWorkload_Execute_#5": {
- "type": "Event",
- "Wall clock time_#5": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#5": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#5": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- },
- "NeonSomeMock2Workload_Execute_#6": {
- "type": "Event",
- "Wall clock time_#6": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#6": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#6": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- },
- "ClSomeMock3dWorkload_Execute_#7": {
- "type": "Event",
- "Wall clock time_#7": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#7": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#7": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- },
- "EthosNSomeMock4dWorkload_Execute_#8": {
- "type": "Event",
- "Wall clock time_#8": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#8": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#8": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- }
- }
- }
- }
-}
diff --git a/python/pyarmnn/test/testdata/shared/onnx_parser/golden_output_onnx.npy b/python/pyarmnn/test/testdata/shared/onnx_parser/golden_output_onnx.npy
deleted file mode 100644
index f83d6ea7cb..0000000000
--- a/python/pyarmnn/test/testdata/shared/onnx_parser/golden_output_onnx.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/onnx_parser/input_onnx.npy b/python/pyarmnn/test/testdata/shared/onnx_parser/input_onnx.npy
deleted file mode 100644
index 15df758b58..0000000000
--- a/python/pyarmnn/test/testdata/shared/onnx_parser/input_onnx.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/tf_parser/golden_output_tf.npy b/python/pyarmnn/test/testdata/shared/tf_parser/golden_output_tf.npy
deleted file mode 100644
index 007141cb9f..0000000000
--- a/python/pyarmnn/test/testdata/shared/tf_parser/golden_output_tf.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/tf_parser/input_tf.npy b/python/pyarmnn/test/testdata/shared/tf_parser/input_tf.npy
deleted file mode 100644
index a21802e4b8..0000000000
--- a/python/pyarmnn/test/testdata/shared/tf_parser/input_tf.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/tflite_parser/golden_output_lite.npy b/python/pyarmnn/test/testdata/shared/tflite_parser/golden_output_lite.npy
deleted file mode 100644
index 099f7fed22..0000000000
--- a/python/pyarmnn/test/testdata/shared/tflite_parser/golden_output_lite.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/test/testdata/shared/tflite_parser/input_lite.npy b/python/pyarmnn/test/testdata/shared/tflite_parser/input_lite.npy
deleted file mode 100644
index 53174683ff..0000000000
--- a/python/pyarmnn/test/testdata/shared/tflite_parser/input_lite.npy
+++ /dev/null
Binary files differ
diff --git a/python/pyarmnn/tox.ini b/python/pyarmnn/tox.ini
index ca1d12bcb7..7fa437c33f 100644
--- a/python/pyarmnn/tox.ini
+++ b/python/pyarmnn/tox.ini
@@ -12,10 +12,12 @@ deps = pytest==5.2.0
setuptools==41.6.0
numpy==1.17.2
pillow==6.1.0
+ requests==2.23.0
recreate = True
whitelist_externals = /bin/sh
commands =
+ python ./scripts/download_test_resources.py
python -m pytest test/ -v {posargs} --junit-xml=test_report_junit-{envname}.xml --cov=pyarmnn --cov-report xml:coverage-{envname}.xml
[testenv:devenv]