Skip to content

Commit

Permalink
Use common preprocessing for program mobilenets-armcl-opencl (#11)
Browse files Browse the repository at this point in the history
* switch program to common preprocessing

* normalize data

* push weights to remote

* old var refs removed

* support for convolution method file

* push convolution method files to remote
  • Loading branch information
Chunosov authored and psyhtest committed Jul 11, 2018
1 parent a166641 commit bf28142
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 916 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*tmp/
*.pyc
program/mobilenets-armcl-opencl/batches*
program/mobilenets-armcl-opencl/images*.txt
program/mobilenets-armcl-opencl/preprocessed

45 changes: 27 additions & 18 deletions program/mobilenets-armcl-opencl/.cm/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@
"compiler_env": "CK_CXX",
"compiler_flags_as_env": "$<<CK_COMPILER_FLAG_CPP11>>$ -Wno-ignored-attributes",
"data_name": "mobilenets-armcl-opencl",
"linker_add_lib_as_env": [
"CK_CXX_EXTRA",
"CK_ENV_LIB_STDCPP_STATIC"
],
"extra_ld_vars": "$<<CK_ENV_LIB_STDCPP_DYNAMIC>>$",
"main_language": "cpp",
"only_for_target_os_tags": [
"android",
"linux"
],
"print_files_after_run": [
"tmp-stdout.tmp",
"tmp-stderr.tmp"
],
"process_in_tmp": "yes",
"program": "yes",
"run_cmds": {
Expand All @@ -58,49 +60,56 @@
"run_time": {
"output_invariant_of_repeat": "yes",
"fine_grain_timer_file": "tmp-ck-timer.json",
"run_cmd_out1": "tmp-stdout.tmp",
"run_cmd_out2": "tmp-stderr.tmp",
"need_compute_device": "opencl",
"pre_process_via_ck": {
"script_name": "preprocess"
},
"post_process_via_ck": "yes",
"post_process_cmds": [
"python $#src_path_local#$postprocess.py"
"python $#ck_take_from_{script:689867d1939a781d}#$postprocess.py"
],
"pre_process_via_ck": {
"module_uoa": "script",
"data_uoa": "689867d1939a781d",
"script_name": "preprocess"
},
"run_cmd_main": "$#BIN_FILE#$",
"run_cmd_out1": "tmp-stdout.tmp",
"run_cmd_out2": "tmp-stderr.tmp",
"run_output_files": [
"tmp-ck-timer.json"
"tmp-ck-timer.json",
"tmp-stdout.tmp",
"tmp-stderr.tmp"
]
}
}
},
"run_vars": {
"CK_IMAGE_FILE": "",
"CK_IMAGE_LIST": "../images",
"CK_BATCH_LIST": "../batches",
"CK_BATCHES_DIR": "../batches",
"CK_RESULTS_DIR": "predictions",
"CK_BATCH_COUNT": 1,
"CK_BATCH_SIZE": 1,
"CK_CROP_PERCENT": 87.5,
"CK_IMAGE_FILE": "",
"CK_RECREATE_CACHE": "NO",
"CK_SKIP_IMAGES": 0,
"CK_PREPARE_ALWAYS": "NO"
"CK_NORMALIZE_DATA": "YES",
"CK_SUBTRACT_MEAN": "YES",
"CK_TMP_IMAGE_SIZE": 0
},
"run_deps": {
"weights": {
"force_target_as_host": "yes",
"local": "yes",
"name": "MobileNet weights (as NumPy arrays)",
"sort": 10,
"tags": "mobilenet,weights,npy",
"no_tags": "mobilenet-all"
},
"imagenet-aux": {
"force_target_as_host": "yes",
"local": "yes",
"name": "ImageNet dataset (aux)",
"sort": 20,
"tags": "dataset,imagenet,aux"
},
"imagenet-val": {
"force_target_as_host": "yes",
"local": "yes",
"name": "ImageNet dataset (val)",
"sort": 30,
Expand All @@ -110,7 +119,7 @@
"skip_bin_ext": "yes",
"source_files": [
"benchmark.cpp",
"mobilenets.cpp",
"mobilenet.cpp",
"$<<CK_ENV_LIB_ARMCL_UTILS>>$/GraphUtils.cpp",
"$<<CK_ENV_LIB_ARMCL_UTILS>>$/Utils.cpp"
],
Expand Down
23 changes: 18 additions & 5 deletions program/mobilenets-armcl-opencl/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
# mobilenet-armcl-opencl
# Classification program for ArmCL

ImageNet classification and benchmarking using ArmCL and MobileNet.

## Requirements

ArmCL compiled with Graph API:
### ArmCL library
To build this program, you need ArmCL compiled with Graph API:
```
ck install package:lib-armcl-opencl-18.01 --env.USE_GRAPH=ON --env.USE_NEON=ON --extra_version=-graph
```

To build this program for Android you need to embedd kernels and select target API as follows:
```
$ ck install package:lib-armcl-opencl-18.05 --env.USE_GRAPH=ON --env.USE_NEON=ON --extra_version=-graph --env.USE_EMBEDDED_KERNELS=ON --env.DEBUG=ON --target_os=android23-arm64
```

**NB:** Use `--target_os=android23-arm64` to build for Android API 23 (v6.0 "Marshmallow") or [similar](https://source.android.com/setup/start/build-numbers).

We have to embed kernels when building for Android as OpenCL kernel files are not copied to a remote device.

**TODO:** For some reason only debug version of the library can be used with this program on Android. When we use release version, the program gets stuck at graph preparation stage.

### Weights package
One of MobileNet weights packages:
```
ck install package:weights-mobilenet-v1-1.0-224-npy
Expand All @@ -32,18 +45,18 @@ ck install package:weights-mobilenet-v1-0.50-128-npy
ck install package:weights-mobilenet-v1-0.25-128-npy
```

ImageNet dataset:
### ImageNet dataset
```
ck install package:imagenet-2012-val
ck install package:imagenet-2012-aux
```

## Build
```
ck compile program:mobilenet-armcl-opencl
ck compile program:mobilenet-armcl-opencl [--target_os=android23-arm64]
```

## Run
```
ck run program:mobilenet-armcl-opencl
ck run program:mobilenet-armcl-opencl [--target_os=android23-arm64]
```
125 changes: 0 additions & 125 deletions program/mobilenets-armcl-opencl/armcl_graph_common.h

This file was deleted.

Loading

0 comments on commit bf28142

Please sign in to comment.