Merge pull request #2195 from lissyx/tflite-all

TFLite runtime on Linux/macOS/Windows
This commit is contained in:
lissyx 2019-06-26 21:45:07 +02:00 committed by GitHub
commit f50fefda90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 158 additions and 9 deletions

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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}/

View File

@ -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}

View File

@ -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

View File

@ -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}"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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)
) &&

View File

@ -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}/