├── .gitignore ├── .cm ├── alias-a-soft ├── alias-u-5e1100048ab875d7 ├── alias-a-package ├── alias-a-program ├── alias-u-1dc07ee0f4742028 └── alias-u-b0ac08fe1d3c2615 ├── program ├── edgetpu │ ├── .cm │ │ ├── desc.json │ │ ├── info.json │ │ └── meta.json │ └── experiments.sh └── .cm │ ├── alias-a-edgetpu │ └── alias-u-56f42c795b754a09 ├── soft ├── lib.edgetpu │ ├── .cm │ │ ├── desc.json │ │ ├── info.json │ │ └── meta.json │ └── customize.py └── .cm │ ├── alias-a-lib.edgetpu │ └── alias-u-2783dce06e383615 ├── package ├── lib-edgetpu │ ├── .cm │ │ ├── desc.json │ │ ├── info.json │ │ └── meta.json │ ├── README.md │ └── install.sh └── .cm │ ├── alias-a-lib-edgetpu │ └── alias-u-4d21a3f1fd840369 ├── COPYRIGHT.txt ├── .ckr.json └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | -------------------------------------------------------------------------------- /.cm/alias-a-soft: -------------------------------------------------------------------------------- 1 | 5e1100048ab875d7 2 | -------------------------------------------------------------------------------- /.cm/alias-u-5e1100048ab875d7: -------------------------------------------------------------------------------- 1 | soft 2 | -------------------------------------------------------------------------------- /program/edgetpu/.cm/desc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /soft/lib.edgetpu/.cm/desc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.cm/alias-a-package: -------------------------------------------------------------------------------- 1 | 1dc07ee0f4742028 2 | -------------------------------------------------------------------------------- /.cm/alias-a-program: -------------------------------------------------------------------------------- 1 | b0ac08fe1d3c2615 2 | -------------------------------------------------------------------------------- /.cm/alias-u-1dc07ee0f4742028: -------------------------------------------------------------------------------- 1 | package 2 | -------------------------------------------------------------------------------- /.cm/alias-u-b0ac08fe1d3c2615: -------------------------------------------------------------------------------- 1 | program 2 | -------------------------------------------------------------------------------- /package/lib-edgetpu/.cm/desc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /program/.cm/alias-a-edgetpu: -------------------------------------------------------------------------------- 1 | 56f42c795b754a09 2 | -------------------------------------------------------------------------------- /program/.cm/alias-u-56f42c795b754a09: -------------------------------------------------------------------------------- 1 | edgetpu 2 | -------------------------------------------------------------------------------- /package/.cm/alias-a-lib-edgetpu: -------------------------------------------------------------------------------- 1 | 4d21a3f1fd840369 2 | -------------------------------------------------------------------------------- /package/.cm/alias-u-4d21a3f1fd840369: -------------------------------------------------------------------------------- 1 | lib-edgetpu 2 | -------------------------------------------------------------------------------- /soft/.cm/alias-a-lib.edgetpu: -------------------------------------------------------------------------------- 1 | 2783dce06e383615 2 | -------------------------------------------------------------------------------- /soft/.cm/alias-u-2783dce06e383615: -------------------------------------------------------------------------------- 1 | lib.edgetpu 2 | -------------------------------------------------------------------------------- /COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 cTuning foundation. 2 | Copyright (c) 2020 dividiti Limited. 3 | -------------------------------------------------------------------------------- /.ckr.json: -------------------------------------------------------------------------------- 1 | { 2 | "data_uoa": "ck-coral", 3 | "data_uid": "928a209a1a3cd016", 4 | "data_alias": "ck-coral", 5 | "data_name": "ck-coral", 6 | "dict": { 7 | "shared": "git", 8 | "url": "https://github.com/ctuning/ck-coral" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /program/edgetpu/.cm/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "backup_data_uid": "56f42c795b754a09", 3 | "backup_module_uid": "b0ac08fe1d3c2615", 4 | "backup_module_uoa": "program", 5 | "control": { 6 | "engine": "CK", 7 | "iso_datetime": "2020-09-03T12:10:07.317933", 8 | "version": [ 9 | "1", 10 | "15", 11 | "0" 12 | ] 13 | }, 14 | "data_name": "edgetpu" 15 | } 16 | -------------------------------------------------------------------------------- /soft/lib.edgetpu/.cm/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "backup_data_uid": "2783dce06e383615", 3 | "backup_module_uid": "5e1100048ab875d7", 4 | "backup_module_uoa": "soft", 5 | "control": { 6 | "engine": "CK", 7 | "iso_datetime": "2020-08-04T12:57:18.750445", 8 | "version": [ 9 | "1", 10 | "15", 11 | "0" 12 | ] 13 | }, 14 | "data_name": "lib.edgetpu" 15 | } 16 | -------------------------------------------------------------------------------- /package/lib-edgetpu/.cm/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "backup_data_uid": "4d21a3f1fd840369", 3 | "backup_module_uid": "1dc07ee0f4742028", 4 | "backup_module_uoa": "package", 5 | "control": { 6 | "engine": "CK", 7 | "iso_datetime": "2020-08-04T19:58:32.871822", 8 | "version": [ 9 | "1", 10 | "15", 11 | "0" 12 | ] 13 | }, 14 | "data_name": "lib-edgetpu" 15 | } 16 | -------------------------------------------------------------------------------- /soft/lib.edgetpu/.cm/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "auto_detect": "yes", 3 | "customize": { 4 | "check_that_exists": "yes", 5 | "env_prefix": "CK_ENV_LIB_EDGETPU", 6 | "limit_recursion_dir_search": { 7 | "linux": 4 8 | }, 9 | "soft_file": { 10 | "linux": "libedgetpu.so.1" 11 | } 12 | }, 13 | "soft_name": "EdgeTPU lib", 14 | "tags": [ 15 | "lib", 16 | "libedgetpu", 17 | "edgetpu" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /package/lib-edgetpu/README.md: -------------------------------------------------------------------------------- 1 | ## Coral edgetpu package 2 | 3 | This package installs the driver required to run the Coral edgetpu. 4 | 5 | There are two versions; std and max. 6 | 7 | ``` 8 | $ ck install package --tags=lib,edgetpu,std_14.1_arm64 9 | $ ck install package --tags=lib,edgetpu,max_14.1_arm64 10 | ``` 11 | 12 | For instructions on how run, please see [`program:object-detection-tflite-loadgen`](https://github.com/ctuning/ck-mlperf/blob/master/program/object-detection-tflite-loadgen/README.singlestream.md). 13 | -------------------------------------------------------------------------------- /package/lib-edgetpu/install.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # 4 | # Copyright (c) 2020 cTuning foundation. 5 | # See CK COPYRIGHT.txt for copyright details. 6 | # 7 | # See CK LICENSE.txt for licensing details. 8 | # 9 | # Installation script for the EdgeTPU library. 10 | # 11 | function exit_if_error() { 12 | message=${1:-"unknown"} 13 | if [ "${?}" != "0" ]; then 14 | echo "Error: ${message}!" 15 | exit 1 16 | fi 17 | } 18 | wget --no-cookies ${PACKAGE_URL}${PACKAGE_NAME} 19 | exit_if_error "wget failed" 20 | dpkg -x $PACKAGE_NAME . 21 | exit_if_error "dpkg failed" 22 | cp -r usr/lib/*/libedgetpu* usr/lib/ 23 | 24 | cd ${INSTALL_DIR}/usr/lib/aarch64-linux-gnu/ 25 | ln -s libedgetpu.so.1.0 libedgetpu.so 26 | 27 | return 0 28 | -------------------------------------------------------------------------------- /program/edgetpu/.cm/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "backup_data_uid": "56f42c795b754a09", 3 | "data_name": "edgetpu", 4 | "tags": [], 5 | "run_deps": { 6 | "libedgetpu": { 7 | "force_target_as_host": "yes", 8 | "local": "yes", 9 | "name": "EdgeTPU library", 10 | "sort": 110, 11 | "tags": "libedgetpu,std" 12 | } 13 | }, 14 | "program": "yes", 15 | "run_cmds": { 16 | "experiments": { 17 | "ignore_return_code": "no", 18 | "run_time": { 19 | "run_cmd_main": "../experiments.sh", 20 | "run_cmd_out1": "stdout.log", 21 | "run_cmd_out2": "stderr.log", 22 | "run_output_files": [ 23 | "stdout.log", 24 | "stderr.log" 25 | ] 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 cTuning foundation. 2 | Copyright (c) 2020 dividiti Limited. 3 | All rights reserved 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the cTuning foundation 16 | nor the names of its contributors may be used to endorse 17 | or promote products derived from this software without 18 | specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /program/edgetpu/experiments.sh: -------------------------------------------------------------------------------- 1 | cd $(dirname $0) 2 | mkdir coral && cd coral 3 | git clone https://github.com/google-coral/tflite.git 4 | cd tflite/python/examples/classification 5 | echo "---------------------------Classification---------------------------------------" 6 | 7 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 8 | readonly TEST_DATA_URL=https://github.com/google-coral/edgetpu/raw/master/test_data 9 | # Get TF Lite model and labels 10 | MODEL_DIR="${SCRIPT_DIR}/models" 11 | mkdir -p "${MODEL_DIR}" 12 | 13 | (cd "${MODEL_DIR}" && \ 14 | curl -OL "${TEST_DATA_URL}/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite" \ 15 | -OL "${TEST_DATA_URL}/mobilenet_v2_1.0_224_inat_bird_quant.tflite" \ 16 | -OL "${TEST_DATA_URL}/inat_bird_labels.txt") 17 | 18 | # Get example image for classification 19 | IMAGE_DIR="${SCRIPT_DIR}/images" 20 | mkdir -p "${IMAGE_DIR}" 21 | 22 | (cd "${IMAGE_DIR}" && \ 23 | curl -OL "${TEST_DATA_URL}/parrot.jpg") 24 | 25 | python3 classify_image.py --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_labels.txt --input images/parrot.jpg 26 | 27 | # Get model for detection 28 | echo "---------------------------Detection-------------------------------------------" 29 | cd .. 30 | cd ./detection 31 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 32 | MODEL_DIR="${SCRIPT_DIR}/models" 33 | IMAGE_DIR="${SCRIPT_DIR}/images" 34 | mkdir -p "${MODEL_DIR}" 35 | mkdir -p "${IMAGE_DIR}" 36 | (cd "${MODEL_DIR}" 37 | curl -OL "${TEST_DATA_URL}/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite" \ 38 | -OL "${TEST_DATA_URL}/ssd_mobilenet_v2_coco_quant_postprocess.tflite" \ 39 | -OL "${TEST_DATA_URL}/coco_labels.txt") 40 | 41 | # Get example image for detection 42 | (cd "${IMAGE_DIR}" 43 | curl -OL "${TEST_DATA_URL}/grace_hopper.bmp") 44 | 45 | python3 detect_image.py --model models/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite --labels models/coco_labels.txt --input images/grace_hopper.bmp --output images/grace_hopper_processed.bmp 46 | -------------------------------------------------------------------------------- /package/lib-edgetpu/.cm/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "customize": { 3 | "extra_dir": "", 4 | "install_env": { 5 | "PACKAGE_URL": "https://packages.cloud.google.com/apt/pool/", 6 | "PACKAGE_WGET": "YES", 7 | "PACKAGE_WGET_EXTRA": "--no-cookies" 8 | }, 9 | "no_ver_in_suggested_path": "yes", 10 | "version": "with-variations" 11 | }, 12 | "end_full_path": { 13 | "linux": "usr/lib/aarch64-linux-gnu/libedgetpu.so.1" 14 | }, 15 | "need_cpu_info": "yes", 16 | "only_for_host_os_tags": [ 17 | "linux" 18 | ], 19 | "only_for_target_os_tags": [ 20 | "linux" 21 | ], 22 | "process_script": "install", 23 | "soft_uoa": "2783dce06e383615", 24 | "suggested_path": "lib-edgetpu", 25 | "tags": [ 26 | "lib", 27 | "libedgetpu", 28 | "edgetpu" 29 | ], 30 | "variations": { 31 | "std": { 32 | "extra_customize": { 33 | "version": "14.1" 34 | }, 35 | "extra_env": { 36 | "PACKAGE_NAME": "libedgetpu1-std_14.1_arm64_4669a44bd6d6f3b7d33c356182ceaeb29e1c981843629adeb77ac1283dbd498e.deb" 37 | }, 38 | "on_by_default": "yes" 39 | }, 40 | "std_14.1_arm64": { 41 | "extra_customize": { 42 | "version": "14.1" 43 | }, 44 | "extra_env": { 45 | "PACKAGE_NAME": "libedgetpu1-std_14.1_arm64_4669a44bd6d6f3b7d33c356182ceaeb29e1c981843629adeb77ac1283dbd498e.deb" 46 | }, 47 | "on_by_default": "no" 48 | }, 49 | "max": { 50 | "extra_customize": { 51 | "version": "14.1" 52 | }, 53 | "extra_env": { 54 | "PACKAGE_NAME": "libedgetpu1-max_14.1_arm64_795e7f49c81b1f9586f43b1978dd938b192df3e5e4939e1e8deb965d64ca41e6.deb" 55 | }, 56 | "on_by_default": "no" 57 | }, 58 | "max_14.1_arm64": { 59 | "extra_customize": { 60 | "version": "14.1" 61 | }, 62 | "extra_env": { 63 | "PACKAGE_NAME": "libedgetpu1-max_14.1_arm64_795e7f49c81b1f9586f43b1978dd938b192df3e5e4939e1e8deb965d64ca41e6.deb" 64 | }, 65 | "on_by_default": "no" 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /soft/lib.edgetpu/customize.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 cTuning foundation. 3 | # See CK COPYRIGHT.txt for copyright details. 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause. 6 | # See CK LICENSE.txt for licensing details. 7 | # 8 | 9 | import os 10 | 11 | def setup(i): 12 | """ 13 | Input: { 14 | cfg - meta of this soft entry 15 | self_cfg - meta of module soft 16 | ck_kernel - import CK kernel module (to reuse functions) 17 | 18 | host_os_uoa - host OS UOA 19 | host_os_uid - host OS UID 20 | host_os_dict - host OS meta 21 | 22 | target_os_uoa - target OS UOA 23 | target_os_uid - target OS UID 24 | target_os_dict - target OS meta 25 | 26 | target_device_id - target device ID (if via ADB) 27 | 28 | tags - list of tags used to search this entry 29 | 30 | env - updated environment vars from meta 31 | customize - updated customize vars from meta 32 | 33 | deps - resolved dependencies for this soft 34 | 35 | interactive - if 'yes', can ask questions, otherwise quiet 36 | } 37 | 38 | Output: { 39 | return - return code = 0, if successful 40 | > 0, if error 41 | (error) - error text if return > 0 42 | 43 | bat - prepared string for bat file 44 | } 45 | 46 | """ 47 | 48 | ck = i['ck_kernel'] 49 | 50 | cus = i.get('customize',{}) 51 | full_path = cus.get('full_path','') 52 | env = i['env'] 53 | ep = cus['env_prefix'] 54 | host_os_dict = i.get('host_os_dict', {}) 55 | target_os_dict = i.get('target_os_dict', {}) 56 | target_os_name = target_os_dict.get('ck_name2', '') 57 | s = '' 58 | 59 | lib_dir = os.path.dirname(full_path) 60 | install_dir = os.path.dirname(lib_dir) 61 | ck_tools_dir = os.path.dirname(install_dir) 62 | 63 | env[ep] = ck_tools_dir 64 | env[ep+'_LIB_DIRS'] = os.path.join(lib_dir) 65 | env[ep+'_INCLUDE0'] = os.path.join(install_dir, 'include') 66 | 67 | env[ep+'_COMPILE_OPTIONS'] = "-DUSE_EDGETPU" 68 | env[ep+'_LINK_OPTIONS'] = "-L" + lib_dir + " -ledgetpu" 69 | 70 | if 'LD_LIBRARY_PATH' in env: 71 | env['LD_LIBRARY_PATH'] = os.path.join(lib_dir, ':', env['LD_LIBRARY_PATH']) 72 | else: 73 | env['LD_LIBRARY_PATH'] = lib_dir 74 | 75 | return {'return': 0, 'bat': ''} 76 | --------------------------------------------------------------------------------