-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and test TF integrations (#9927)
- Loading branch information
1 parent
2f48a95
commit 8aa3c3d
Showing
4 changed files
with
214 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Build the IREE TF integration binaries. Despite the name, also runs the few | ||
# lit tests for these that are enabled through Bazel. These take seconds to run | ||
# all of them and it's easiest to just run themm here rather than trying to | ||
# figure out how to pass prebuilt binaries to Bazel tests. | ||
|
||
set -xeuo pipefail | ||
|
||
ROOT_DIR="${ROOT_DIR:-$(git rev-parse --show-toplevel)}" | ||
IREE_USE_WORKSPACE_RC="${IREE_USE_WORKSPACE_RC:-0}" | ||
IREE_BAZEL_READ_REMOTE_CACHE="${IREE_BAZEL_READ_REMOTE_CACHE:-1}" | ||
IREE_BAZEL_WRITE_REMOTE_CACHE="${IREE_BAZEL_WRITE_REMOTE_CACHE:-0}" | ||
IREE_TF_BINARIES_OUTPUT_DIR="${IREE_TF_BINARIES_OUTPUT_DIR:-}" | ||
|
||
if (( ${IREE_BAZEL_WRITE_REMOTE_CACHE} == 1 && ${IREE_BAZEL_READ_REMOTE_CACHE} != 1 )); then | ||
echo "Can't have 'IREE_BAZEL_WRITE_REMOTE_CACHE' (${IREE_BAZEL_WRITE_REMOTE_CACHE}) set without 'IREE_BAZEL_READ_REMOTE_CACHE' (${IREE_BAZEL_READ_REMOTE_CACHE})" | ||
fi | ||
|
||
cd "${ROOT_DIR}/integrations/tensorflow" | ||
|
||
BAZEL_BIN=${BAZEL_BIN:-$(which bazel)} | ||
|
||
BAZEL_STARTUP_CMD=("${BAZEL_BIN}") | ||
|
||
if [[ "${IREE_USE_WORKSPACE_RC}" == 0 ]]; then | ||
BAZEL_STARTUP_CMD+=(--noworkspace_rc --bazelrc=build_tools/bazel/iree-tf.bazelrc) | ||
fi | ||
|
||
if [[ "${IREE_BAZEL_OUTPUT_BASE:-}" != "" ]]; then | ||
BAZEL_STARTUP_CMD+=("--output_base=${IREE_BAZEL_OUTPUT_BASE}") | ||
mkdir -p "${IREE_BAZEL_OUTPUT_BASE}" | ||
fi | ||
|
||
BAZEL_TEST_CMD=("${BAZEL_STARTUP_CMD[@]}" test) | ||
|
||
if (( IREE_BAZEL_READ_REMOTE_CACHE == 1 )); then | ||
BAZEL_TEST_CMD+=(--config=remote_cache_bazel_ci) | ||
fi | ||
|
||
if (( IREE_BAZEL_WRITE_REMOTE_CACHE != 1 )); then | ||
BAZEL_TEST_CMD+=(--noremote_upload_local_results) | ||
fi | ||
|
||
BAZEL_TEST_CMD+=( | ||
--config=generic_clang | ||
--test_tag_filters="-nokokoro" | ||
--build_tag_filters="-nokokoro" | ||
) | ||
|
||
# xargs is set to high arg limits to avoid multiple Bazel invocations and will | ||
# hard fail if the limits are exceeded. | ||
# See https://github.com/bazelbuild/bazel/issues/12479 | ||
"${BAZEL_STARTUP_CMD[@]}" query //iree_tf_compiler/... | \ | ||
xargs --max-args 1000000 --max-chars 1000000 --exit \ | ||
"${BAZEL_TEST_CMD[@]}" | ||
|
||
|
||
if [[ "${IREE_TF_BINARIES_OUTPUT_DIR}" != "" ]]; then | ||
mkdir -p "${IREE_TF_BINARIES_OUTPUT_DIR}" | ||
cp \ | ||
bazel-bin/iree_tf_compiler/iree-import-tf \ | ||
bazel-bin/iree_tf_compiler/iree-import-tflite \ | ||
bazel-bin/iree_tf_compiler/iree-import-xla \ | ||
"${IREE_TF_BINARIES_OUTPUT_DIR}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
set -xeuo pipefail | ||
|
||
ROOT_DIR="${ROOT_DIR:-$(git rev-parse --show-toplevel)}" | ||
cd "${ROOT_DIR}" | ||
|
||
BUILD_DIR="$1" | ||
IREE_VULKAN_DISABLE="${IREE_VULKAN_DISABLE:-0}" | ||
|
||
source "${BUILD_DIR}/.env" && export PYTHONPATH | ||
|
||
echo "***** Running TensorFlow integration tests *****" | ||
# TODO: Use "--timeout 900" instead of --max-time below. Requires that | ||
# `psutil` python package be installed in the VM for per test timeout. | ||
LIT_SCRIPT="${ROOT_DIR}/third_party/llvm-project/llvm/utils/lit/lit.py" | ||
|
||
CMD=( | ||
python3 | ||
"${LIT_SCRIPT}" | ||
-v integrations/tensorflow/test | ||
--max-time 1800 | ||
) | ||
|
||
if (( ${IREE_VULKAN_DISABLE} != 1 )); then | ||
CMD+=(-D FEATURES=vulkan) | ||
fi | ||
|
||
if "${CMD[@]}"; then | ||
tests_passed=1 | ||
else | ||
tests_passed=0 | ||
fi | ||
|
||
if (( ${tests_passed} != 1 )); then | ||
echo "Some tests failed!!!" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters