Skip to content

Commit

Permalink
Produce TFLite NuGet package
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Lissy committed Jan 30, 2020
1 parent 0428c84 commit f6c2678
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 15 deletions.
2 changes: 2 additions & 0 deletions taskcluster/scriptworker-task-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ build:
- "android-armv7-cpu-opt"
- "win-amd64-cpu-opt"
- "win-amd64-gpu-opt"
- "win-amd64-tflite-opt"
java_aar:
- "android-java-opt"
nuget:
- "win-amd64-cpu-opt"
- "win-amd64-gpu-opt"
- "win-amd64-tflite-opt"
metadata:
name: "DeepSpeech GitHub Packages"
description: "Trigger Uploading of DeepSpeech Packages to GitHub release page"
2 changes: 2 additions & 0 deletions taskcluster/scriptworker-task-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build:
# Make sure builds are ready
- "win-amd64-cpu-opt"
- "win-amd64-gpu-opt"
- "win-amd64-tflite-opt"
allowed:
- "tag"
ref_match: "refs/tags/"
Expand All @@ -20,6 +21,7 @@ build:
nuget:
- "win-amd64-cpu-opt"
- "win-amd64-gpu-opt"
- "win-amd64-tflite-opt"
metadata:
name: "DeepSpeech NuGet Packages"
description: "Trigger Uploading of DeepSpeech .Net Framework bindings to NuGet"
7 changes: 5 additions & 2 deletions taskcluster/tc-netframework-ds-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

set -xe

cuda=$1
bitrate=$1
package_option=$2

source $(dirname "$0")/tc-tests-utils.sh

bitrate=$1
set_ldc_sample_filename "${bitrate}"

if [ "${cuda}" = "--cuda" ]; then
if [ "${package_option}" = "--cuda" ]; then
PROJECT_NAME="DeepSpeech-GPU"
elif [ "${package_option}" = "--tflite" ]; then
PROJECT_NAME="DeepSpeech-TFLite"
else
PROJECT_NAME="DeepSpeech"
fi
Expand Down
26 changes: 24 additions & 2 deletions taskcluster/tc-tests-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,11 @@ install_nuget()
mkdir -p "${TASKCLUSTER_TMP_DIR}/repo/"
mkdir -p "${TASKCLUSTER_TMP_DIR}/ds/"

${WGET} -O - "${DEEPSPEECH_ARTIFACTS_ROOT}/${nuget}" | gunzip > "${TASKCLUSTER_TMP_DIR}/${PROJECT_NAME}.${DS_VERSION}.nupkg"
${WGET} -O - "${DEEPSPEECH_ARTIFACTS_ROOT}/DeepSpeechConsole.exe" | gunzip > "${TASKCLUSTER_TMP_DIR}/ds/DeepSpeechConsole.exe"
nuget_pkg_url=$(get_dep_nuget_pkg_url "${nuget}")
console_pkg_url=$(get_dep_nuget_pkg_url "DeepSpeechConsole.exe")

${WGET} -O - "${nuget_pkg_url}" | gunzip > "${TASKCLUSTER_TMP_DIR}/${PROJECT_NAME}.${DS_VERSION}.nupkg"
${WGET} -O - "${console_pkg_url}" | gunzip > "${TASKCLUSTER_TMP_DIR}/ds/DeepSpeechConsole.exe"

nuget sources add -Name repo -Source $(cygpath -w "${TASKCLUSTER_TMP_DIR}/repo/")

Expand Down Expand Up @@ -1207,6 +1210,25 @@ get_dep_npm_pkg_url()
exit 1
}

# Will inspect this task's dependencies for one that provides a matching NuGet package
get_dep_nuget_pkg_url()
{
local deepspeech_pkg=$1
local all_deps="$(curl -s https://community-tc.services.mozilla.com/api/queue/v1/task/${TASK_ID} | python -c 'import json; import sys; print(" ".join(json.loads(sys.stdin.read())["dependencies"]));')"

for dep in ${all_deps}; do
local has_artifact=$(curl -s https://community-tc.services.mozilla.com/api/queue/v1/task/${dep}/artifacts | python -c 'import json; import sys; has_artifact = True in [ e["name"].find("'${deepspeech_pkg}'") > 0 for e in json.loads(sys.stdin.read())["artifacts"] ]; print(has_artifact)')
if [ "${has_artifact}" = "True" ]; then
echo "https://community-tc.services.mozilla.com/api/queue/v1/task/${dep}/artifacts/public/${deepspeech_pkg}"
exit 0
fi;
done;

echo ""
# This should not be reached, otherwise it means we could not find a matching nodejs package
exit 1
}

extract_python_versions()
{
# call extract_python_versions ${pyver_full} pyver pyver_pkg py_unicode_type pyconf pyalias
Expand Down
11 changes: 11 additions & 0 deletions taskcluster/test-netframework-win-tflite-opt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
build:
template_file: test-win-opt-base.tyml
dependencies:
- "win-amd64-tflite-opt"
- "test-training_16k-linux-amd64-py36m-opt"
test_model_task: "test-training_16k-linux-amd64-py36m-opt"
args:
tests_cmdline: "$TASKCLUSTER_TASK_DIR/DeepSpeech/ds/taskcluster/tc-netframework-ds-tests.sh 16k --tflite"
metadata:
name: "DeepSpeech Windows AMD64 TFLite .Net Framework tests"
description: "Testing DeepSpeech .Net Framework for Windows/AMD64, TFLite, optimized version"
2 changes: 1 addition & 1 deletion taskcluster/win-amd64-tflite-opt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
- "notify.irc-channel.${notifications.irc}.on-failed"
tensorflow: "https://community-tc.services.mozilla.com/api/index/v1/task/project.deepspeech.tensorflow.pip.r1.15.ceb46aae5836a0f648a2c3da5942af2b7d1b98bf.win/artifacts/public/home.tar.xz"
scripts:
build: "taskcluster/win-build.sh tflite"
build: "taskcluster/win-build.sh --tflite"
package: "taskcluster/win-package.sh"
nc_asset_name: "native_client.amd64.tflite.win.tar.xz"
maxRunTime: 14400
Expand Down
20 changes: 10 additions & 10 deletions taskcluster/win-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

set -xe

cuda=$1
runtime=$1
package_option=$1

source $(dirname "$0")/tc-tests-utils.sh

Expand All @@ -14,24 +13,25 @@ BAZEL_TARGETS="
//native_client:generate_trie
"

if [ "${cuda}" = "--cuda" ]; then
if [ "${package_option}" = "--cuda" ]; then
BAZEL_ENV_FLAGS="TF_NEED_CUDA=1 ${TF_CUDA_FLAGS}"
BAZEL_BUILD_FLAGS="${BAZEL_CUDA_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BAZEL_OPT_FLAGS}"
PROJECT_NAME="DeepSpeech-GPU"
elif [ "${package_option}" = "--tflite" ]; then
PROJECT_NAME="DeepSpeech-TFLite"
BAZEL_BUILD_FLAGS="--define=runtime=tflite ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}"
BAZEL_ENV_FLAGS="TF_NEED_CUDA=0"
else
PROJECT_NAME="DeepSpeech"
if [ "${runtime}" = "tflite" ]; then
BAZEL_BUILD_TFLITE="--define=runtime=tflite"
fi;
BAZEL_BUILD_FLAGS="${BAZEL_BUILD_TFLITE} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}"
BAZEL_BUILD_FLAGS="${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}"
BAZEL_ENV_FLAGS="TF_NEED_CUDA=0"
fi

SYSTEM_TARGET=host-win

do_bazel_build

if [ "${cuda}" = "--cuda" ]; then
if [ "${package_option}" = "--cuda" ]; then
cp ${DS_ROOT_TASK}/DeepSpeech/tf/bazel-bin/native_client/liblibdeepspeech.so.ifso ${DS_ROOT_TASK}/DeepSpeech/tf/bazel-bin/native_client/libdeepspeech.so.if.lib
fi

Expand All @@ -44,10 +44,10 @@ export SUPPORTED_PYTHON_VERSIONS="3.5.4 3.6.8 3.7.6 3.8.1"
if [ "${runtime}" = "tflite" ]; then
do_deepspeech_python_build "--tflite"
else
do_deepspeech_python_build "${cuda}"
do_deepspeech_python_build "${package_option}"
fi

do_deepspeech_nodejs_build "${cuda}"
do_deepspeech_nodejs_build "${package_option}"

do_deepspeech_netframework_build

Expand Down

0 comments on commit f6c2678

Please sign in to comment.