Building TFLite runtime on Linux/macOS/Windows

This commit is contained in:
Alexandre Lissy 2019-06-22 01:18:53 +02:00
parent 87a9605886
commit a9ec2b5cd6
9 changed files with 98 additions and 7 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

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