diff --git a/taskcluster/darwin-amd64-tflite-opt.yml b/taskcluster/darwin-amd64-tflite-opt.yml new file mode 100644 index 00000000..5b1eaa70 --- /dev/null +++ b/taskcluster/darwin-amd64-tflite-opt.yml @@ -0,0 +1,17 @@ +build: + template_file: darwin-opt-base.tyml + routes: + - "index.project.deepspeech.deepspeech.native_client.${event.head.branchortag}.osx-tflite" + - "index.project.deepspeech.deepspeech.native_client.${event.head.branchortag}.${event.head.sha}.osx-tflite" + - "index.project.deepspeech.deepspeech.native_client.osx-tflite.${event.head.sha}" + - "notify.irc-channel.${notifications.irc}.on-exception" + - "notify.irc-channel.${notifications.irc}.on-failed" + tensorflow: "https://index.taskcluster.net/v1/task/project.deepspeech.tensorflow.pip.r1.13.174b4760eb1cba50482ed7d890e654060d360e4b.osx/artifacts/public/home.tar.xz" + scripts: + build: "taskcluster/host-build.sh tflite" + package: "taskcluster/package.sh" + nc_asset_name: "native_client.amd64.tflite.osx.tar.xz" + maxRunTime: 14400 + metadata: + name: "DeepSpeech OSX AMD64 TFLite" + description: "Building DeepSpeech for OSX AMD64, TFLite, optimized version" diff --git a/taskcluster/host-build.sh b/taskcluster/host-build.sh index 908bfcdf..2488a14a 100755 --- a/taskcluster/host-build.sh +++ b/taskcluster/host-build.sh @@ -2,6 +2,8 @@ set -xe +runtime=$1 + source $(dirname "$0")/tc-tests-utils.sh source ${DS_ROOT_TASK}/DeepSpeech/tf/tc-vars.sh @@ -11,7 +13,11 @@ BAZEL_TARGETS=" //native_client:generate_trie " -BAZEL_BUILD_FLAGS="${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}" +if [ "${runtime}" = "tflite" ]; then + BAZEL_BUILD_TFLITE="--define=runtime=tflite" +fi; +BAZEL_BUILD_FLAGS="${BAZEL_BUILD_TFLITE} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}" + BAZEL_ENV_FLAGS="TF_NEED_CUDA=0" SYSTEM_TARGET=host diff --git a/taskcluster/linux-amd64-tflite-opt.yml b/taskcluster/linux-amd64-tflite-opt.yml new file mode 100644 index 00000000..22901461 --- /dev/null +++ b/taskcluster/linux-amd64-tflite-opt.yml @@ -0,0 +1,24 @@ +build: + template_file: linux-opt-base.tyml + routes: + - "index.project.deepspeech.deepspeech.native_client.${event.head.branchortag}.tflite" + - "index.project.deepspeech.deepspeech.native_client.${event.head.branchortag}.${event.head.sha}.tflite" + - "index.project.deepspeech.deepspeech.native_client.tflite.${event.head.sha}" + - "notify.irc-channel.${notifications.irc}.on-exception" + - "notify.irc-channel.${notifications.irc}.on-failed" + system_setup: + > + ${nodejs.packages_trusty.prep_8} && ${nodejs.packages_trusty.apt_pinning} + && apt-get -qq update && apt-get -qq -y install nodejs python-yaml && + apt-get -qq -y install ${python.packages_trusty.apt} && ${swig.packages.install_script} + system_config: + > + ${swig.patch_nodejs.linux} + tensorflow: "https://index.taskcluster.net/v1/task/project.deepspeech.tensorflow.pip.r1.13.174b4760eb1cba50482ed7d890e654060d360e4b.cpu/artifacts/public/home.tar.xz" + scripts: + build: "taskcluster/host-build.sh tflite" + package: "taskcluster/package.sh" + nc_asset_name: "native_client.amd64.tflite.linux.tar.xz" + metadata: + name: "DeepSpeech Linux AMD64 TFLite" + description: "Building DeepSpeech for Linux/AMD64, TFLite, optimized version" diff --git a/taskcluster/package.sh b/taskcluster/package.sh index 9828a5e5..2acc737a 100755 --- a/taskcluster/package.sh +++ b/taskcluster/package.sh @@ -10,6 +10,8 @@ cp ${DS_ROOT_TASK}/DeepSpeech/tf/bazel*.log ${TASKCLUSTER_ARTIFACTS}/ package_native_client "native_client.tar.xz" +package_libdeepspeech_as_zip "libdeepspeech.zip" + if [ -d ${DS_ROOT_TASK}/DeepSpeech/ds/wheels ]; then cp ${DS_ROOT_TASK}/DeepSpeech/ds/wheels/* ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/javascript/deepspeech-*.tgz ${TASKCLUSTER_ARTIFACTS}/ diff --git a/taskcluster/tc-android-ds-tests.sh b/taskcluster/tc-android-ds-tests.sh index f7296058..0f5e289c 100755 --- a/taskcluster/tc-android-ds-tests.sh +++ b/taskcluster/tc-android-ds-tests.sh @@ -9,6 +9,7 @@ source $(dirname "$0")/tc-tests-utils.sh model_source=${DEEPSPEECH_TEST_MODEL//.pb/.tflite} model_name=$(basename "${model_source}") +export DATA_TMP_DIR=${ANDROID_TMP_DIR}/ds if [ "${arm_flavor}" = "armeabi-v7a" ]; then export DEEPSPEECH_ARTIFACTS_ROOT=${DEEPSPEECH_ARTIFACTS_ROOT_ARMV7} diff --git a/taskcluster/tc-cpp_tflite-ds-tests.sh b/taskcluster/tc-cpp_tflite-ds-tests.sh new file mode 100644 index 00000000..549befcc --- /dev/null +++ b/taskcluster/tc-cpp_tflite-ds-tests.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -xe + +source $(dirname "$0")/tc-tests-utils.sh + +model_source=${DEEPSPEECH_TEST_MODEL//.pb/.tflite} +model_name=$(basename "${model_source}") +export DEEPSPEECH_ARTIFACTS_ROOT=${DEEPSPEECH_ARTIFACTS_TFLITE_ROOT} +export DATA_TMP_DIR=${TASKCLUSTER_TMP_DIR} + +download_material "${TASKCLUSTER_TMP_DIR}/ds" + +export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH + +check_tensorflow_version + +run_tflite_basic_inference_tests diff --git a/taskcluster/tc-tests-utils.sh b/taskcluster/tc-tests-utils.sh index 0aa222ef..31e2de1c 100755 --- a/taskcluster/tc-tests-utils.sh +++ b/taskcluster/tc-tests-utils.sh @@ -309,12 +309,12 @@ check_runtime_electronjs() run_tflite_basic_inference_tests() { set +e - phrase_pbmodel_nolm=$(${DS_BINARY_PREFIX}deepspeech --model ${ANDROID_TMP_DIR}/ds/${model_name} --alphabet ${ANDROID_TMP_DIR}/ds/alphabet.txt --audio ${ANDROID_TMP_DIR}/ds/LDC93S1.wav 2>${TASKCLUSTER_TMP_DIR}/stderr) + phrase_pbmodel_nolm=$(${DS_BINARY_PREFIX}deepspeech --model ${DATA_TMP_DIR}/${model_name} --alphabet ${DATA_TMP_DIR}/alphabet.txt --audio ${DATA_TMP_DIR}/LDC93S1.wav 2>${TASKCLUSTER_TMP_DIR}/stderr) set -e assert_correct_ldc93s1 "${phrase_pbmodel_nolm}" "$?" set +e - phrase_pbmodel_nolm=$(${DS_BINARY_PREFIX}deepspeech --model ${ANDROID_TMP_DIR}/ds/${model_name} --alphabet ${ANDROID_TMP_DIR}/ds/alphabet.txt --audio ${ANDROID_TMP_DIR}/ds/LDC93S1.wav --extended 2>${TASKCLUSTER_TMP_DIR}/stderr) + phrase_pbmodel_nolm=$(${DS_BINARY_PREFIX}deepspeech --model ${DATA_TMP_DIR}/${model_name} --alphabet ${DATA_TMP_DIR}/alphabet.txt --audio ${DATA_TMP_DIR}/LDC93S1.wav --extended 2>${TASKCLUSTER_TMP_DIR}/stderr) set -e assert_correct_ldc93s1 "${phrase_pbmodel_nolm}" "$?" } @@ -1066,7 +1066,7 @@ do_deepspeech_python_build() mkdir -p wheels SETUP_FLAGS="" - if [ "${rename_to_gpu}" ]; then + if [ "${rename_to_gpu}" = "--cuda" ]; then SETUP_FLAGS="--project_name deepspeech-gpu" fi @@ -1199,7 +1199,7 @@ do_deepspeech_nodejs_build() clean node-wrapper done; - if [ "${rename_to_gpu}" ]; then + if [ "${rename_to_gpu}" = "--cuda" ]; then make -C native_client/javascript clean npm-pack PROJECT_NAME=deepspeech-gpu else make -C native_client/javascript clean npm-pack @@ -1235,7 +1235,7 @@ do_deepspeech_npm_package() curl -L https://queue.taskcluster.net/v1/task/${dep}/artifacts/public/wrapper.tar.gz | tar -C native_client/javascript -xzvf - done; - if [ "${rename_to_gpu}" ]; then + if [ "${rename_to_gpu}" = "--cuda" ]; then make -C native_client/javascript clean npm-pack PROJECT_NAME=deepspeech-gpu else make -C native_client/javascript clean npm-pack @@ -1347,6 +1347,26 @@ package_native_client_ndk() | pixz -9 > "${artifacts_dir}/${artifact_name}" } +package_libdeepspeech_as_zip() +{ + tensorflow_dir=${DS_TFDIR} + artifacts_dir=${TASKCLUSTER_ARTIFACTS} + artifact_name=$1 + + if [ ! -d ${tensorflow_dir} -o ! -d ${artifacts_dir} ]; then + echo "Missing directory. Please check:" + echo "tensorflow_dir=${tensorflow_dir}" + echo "artifacts_dir=${artifacts_dir}" + exit 1 + fi; + + if [ -z "${artifact_name}" ]; then + echo "Please specify artifact name." + fi; + + zip -r9 --junk-paths "${artifacts_dir}/${artifact_name}" ${tensorflow_dir}/bazel-bin/native_client/libdeepspeech.so +} + android_sdk_accept_licenses() { pushd "${ANDROID_SDK_HOME}" diff --git a/taskcluster/test-cpp_tflite-darwin-amd64-opt.yml b/taskcluster/test-cpp_tflite-darwin-amd64-opt.yml new file mode 100644 index 00000000..e05b2ed0 --- /dev/null +++ b/taskcluster/test-cpp_tflite-darwin-amd64-opt.yml @@ -0,0 +1,13 @@ +build: + template_file: test-darwin-opt-base.tyml + dependencies: + - "darwin-amd64-tflite-opt" + - "test-training_upstream-linux-amd64-py35m-opt" + system_setup: + > + ${cpp.brew.setup} && ${cpp.brew.packages} && ${cpp.brew.env} + args: + tests_cmdline: "$TASKCLUSTER_TASK_DIR/DeepSpeech/ds/taskcluster/tc-cpp_tflite-ds-tests.sh" + metadata: + name: "DeepSpeech OSX AMD64 TFlite C++ tests" + description: "Testing DeepSpeech C++ for OSX/AMD64, TFLite, optimized version" diff --git a/taskcluster/test-cpp_tflite-linux-amd64-opt.yml b/taskcluster/test-cpp_tflite-linux-amd64-opt.yml new file mode 100755 index 00000000..235c6fbc --- /dev/null +++ b/taskcluster/test-cpp_tflite-linux-amd64-opt.yml @@ -0,0 +1,10 @@ +build: + template_file: test-linux-opt-base.tyml + dependencies: + - "linux-amd64-tflite-opt" + - "test-training_upstream-linux-amd64-py35m-opt" + args: + tests_cmdline: "${system.homedir.linux}/DeepSpeech/ds/taskcluster/tc-cpp_tflite-ds-tests.sh" + metadata: + name: "DeepSpeech Linux AMD64 TFLite C++ tests" + description: "Testing DeepSpeech C++ for Linux/AMD64, TFLite, optimized version" diff --git a/taskcluster/test-cpp_tflite-win-amd64-opt.yml b/taskcluster/test-cpp_tflite-win-amd64-opt.yml new file mode 100644 index 00000000..dda1c6d4 --- /dev/null +++ b/taskcluster/test-cpp_tflite-win-amd64-opt.yml @@ -0,0 +1,10 @@ +build: + template_file: test-win-opt-base.tyml + dependencies: + - "win-amd64-tflite-opt" + - "test-training_upstream-linux-amd64-py35m-opt" + args: + tests_cmdline: "$TASKCLUSTER_TASK_DIR/DeepSpeech/ds/taskcluster/tc-cpp_tflite-ds-tests.sh" + metadata: + name: "DeepSpeech Windows AMD64 TFLite C++ tests" + description: "Testing DeepSpeech C++ for Windows/AMD64, TFLite, optimized version" diff --git a/taskcluster/test-darwin-opt-base.tyml b/taskcluster/test-darwin-opt-base.tyml index f2b655de..b3585e31 100644 --- a/taskcluster/test-darwin-opt-base.tyml +++ b/taskcluster/test-darwin-opt-base.tyml @@ -34,9 +34,11 @@ then: $let: training: { $eval: as_slugid("test-training_upstream-linux-amd64-py35m-opt") } darwin_amd64_build: { $eval: as_slugid("darwin-amd64-cpu-opt") } + darwin_amd64_tflite: { $eval: as_slugid("darwin-amd64-tflite-opt") } node_package_cpu: { $eval: as_slugid("node-package-cpu") } in: DEEPSPEECH_ARTIFACTS_ROOT: https://queue.taskcluster.net/v1/task/${darwin_amd64_build}/artifacts/public + DEEPSPEECH_ARTIFACTS_TFLITE_ROOT: https://queue.taskcluster.net/v1/task/${darwin_amd64_tflite}/artifacts/public DEEPSPEECH_NODEJS: https://queue.taskcluster.net/v1/task/${node_package_cpu}/artifacts/public DEEPSPEECH_TEST_MODEL: https://queue.taskcluster.net/v1/task/${training}/artifacts/public/output_graph.pb DEEPSPEECH_PROD_MODEL: https://github.com/reuben/DeepSpeech/releases/download/v0.6.0-alpha.0/output_graph.pb diff --git a/taskcluster/test-linux-opt-base.tyml b/taskcluster/test-linux-opt-base.tyml index af396ef4..59bb7d43 100644 --- a/taskcluster/test-linux-opt-base.tyml +++ b/taskcluster/test-linux-opt-base.tyml @@ -33,12 +33,14 @@ then: $let: training: { $eval: as_slugid("test-training_upstream-linux-amd64-py35m-opt") } linux_amd64_build: { $eval: as_slugid("linux-amd64-cpu-opt") } + linux_amd64_tflite: { $eval: as_slugid("linux-amd64-tflite-opt") } linux_amd64_ctc: { $eval: as_slugid("linux-amd64-ctc-opt") } node_package_cpu: { $eval: as_slugid("node-package-cpu") } in: CONVERT_GRAPHDEF_MEMMAPPED: ${build.convert_graphdef} BENCHMARK_MODEL_BIN: ${build.benchmark_model_bin} DEEPSPEECH_ARTIFACTS_ROOT: https://queue.taskcluster.net/v1/task/${linux_amd64_build}/artifacts/public + DEEPSPEECH_ARTIFACTS_TFLITE_ROOT: https://queue.taskcluster.net/v1/task/${linux_amd64_tflite}/artifacts/public DEEPSPEECH_NODEJS: https://queue.taskcluster.net/v1/task/${node_package_cpu}/artifacts/public DEEPSPEECH_TEST_MODEL: https://queue.taskcluster.net/v1/task/${training}/artifacts/public/output_graph.pb DEEPSPEECH_PROD_MODEL: https://github.com/reuben/DeepSpeech/releases/download/v0.6.0-alpha.0/output_graph.pb diff --git a/taskcluster/test-win-opt-base.tyml b/taskcluster/test-win-opt-base.tyml index 8c5a93cc..d3249325 100644 --- a/taskcluster/test-win-opt-base.tyml +++ b/taskcluster/test-win-opt-base.tyml @@ -38,9 +38,11 @@ then: $let: training: { $eval: as_slugid("test-training_upstream-linux-amd64-py35m-opt") } win_amd64_build: { $eval: as_slugid("win-amd64-cpu-opt") } + win_amd64_tflite: { $eval: as_slugid("win-amd64-tflite-opt") } node_package_cpu: { $eval: as_slugid("node-package-cpu") } in: DEEPSPEECH_ARTIFACTS_ROOT: https://queue.taskcluster.net/v1/task/${win_amd64_build}/artifacts/public + DEEPSPEECH_ARTIFACTS_TFLITE_ROOT: https://queue.taskcluster.net/v1/task/${win_amd64_tflite}/artifacts/public DEEPSPEECH_NODEJS: https://queue.taskcluster.net/v1/task/${node_package_cpu}/artifacts/public DEEPSPEECH_TEST_MODEL: https://queue.taskcluster.net/v1/task/${training}/artifacts/public/output_graph.pb DEEPSPEECH_PROD_MODEL: https://github.com/reuben/DeepSpeech/releases/download/v0.6.0-alpha.0/output_graph.pb diff --git a/taskcluster/win-amd64-tflite-opt.yml b/taskcluster/win-amd64-tflite-opt.yml new file mode 100644 index 00000000..8b77791e --- /dev/null +++ b/taskcluster/win-amd64-tflite-opt.yml @@ -0,0 +1,17 @@ +build: + template_file: win-opt-base.tyml + routes: + - "index.project.deepspeech.deepspeech.native_client.${event.head.branchortag}.win-tflite" + - "index.project.deepspeech.deepspeech.native_client.${event.head.branchortag}.${event.head.sha}.win-tflite" + - "index.project.deepspeech.deepspeech.native_client.win-tflite.${event.head.sha}" + - "notify.irc-channel.${notifications.irc}.on-exception" + - "notify.irc-channel.${notifications.irc}.on-failed" + tensorflow: "https://index.taskcluster.net/v1/task/project.deepspeech.tensorflow.pip.r1.13.174b4760eb1cba50482ed7d890e654060d360e4b.win/artifacts/public/home.tar.xz" + scripts: + build: "taskcluster/win-build.sh tflite" + package: "taskcluster/win-package.sh" + nc_asset_name: "native_client.amd64.tflite.win.tar.xz" + maxRunTime: 14400 + metadata: + name: "DeepSpeech Windows AMD64 TFLite" + description: "Building DeepSpeech for Windows AMD64, TFLite, optimized version" diff --git a/taskcluster/win-build.sh b/taskcluster/win-build.sh index 7d89a0e5..464b91c8 100755 --- a/taskcluster/win-build.sh +++ b/taskcluster/win-build.sh @@ -3,6 +3,7 @@ set -xe cuda=$1 +runtime=$1 source $(dirname "$0")/tc-tests-utils.sh @@ -19,7 +20,10 @@ if [ "${cuda}" = "--cuda" ]; then PROJECT_NAME="DeepSpeech-GPU" else PROJECT_NAME="DeepSpeech" - BAZEL_BUILD_FLAGS="${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}" + if [ "${runtime}" = "tflite" ]; then + BAZEL_BUILD_TFLITE="--define=runtime=tflite" + fi; + BAZEL_BUILD_FLAGS="${BAZEL_BUILD_TFLITE} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}" BAZEL_ENV_FLAGS="TF_NEED_CUDA=0" fi diff --git a/taskcluster/win-opt-base.tyml b/taskcluster/win-opt-base.tyml index 7dfb3802..4e6bb79d 100644 --- a/taskcluster/win-opt-base.tyml +++ b/taskcluster/win-opt-base.tyml @@ -65,6 +65,7 @@ payload: cd $TASKCLUSTER_TASK_DIR && pacman --noconfirm -R bsdtar && pacman --noconfirm -S tar make && + pacman --noconfirm -S zip && (pacman --noconfirm -S patch swig && (for patch_file in $TASKCLUSTER_TASK_DIR/DeepSpeech/ds/native_client/swig_node_v12_*.patch ; do patch -d /usr/share/swig/4.0.0/ -p2 < $patch_file; done) ) && diff --git a/taskcluster/win-package.sh b/taskcluster/win-package.sh index 546f6afd..f916a91c 100755 --- a/taskcluster/win-package.sh +++ b/taskcluster/win-package.sh @@ -2,8 +2,6 @@ set -xe -arm_flavor=$1 - source $(dirname "$0")/tc-tests-utils.sh mkdir -p ${TASKCLUSTER_ARTIFACTS} || true @@ -12,6 +10,8 @@ cp ${DS_ROOT_TASK}/DeepSpeech/tf/bazel*.log ${TASKCLUSTER_ARTIFACTS}/ package_native_client "native_client.tar.xz" +package_libdeepspeech_as_zip "libdeepspeech.zip" + cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/dotnet/*.nupkg ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/dotnet/DeepSpeechConsole/bin/x64/Release/DeepSpeechConsole.exe ${TASKCLUSTER_ARTIFACTS}/