1#!/usr/bin/env bash 2# Copyright 2019 The TensorFlow Authors. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================== 16# 17# Creates the project file distributions for the TensorFlow Lite Micro test and 18# example targets aimed at embedded platforms. 19 20set -e 21 22SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 23ROOT_DIR=${SCRIPT_DIR}/../../../../.. 24cd "${ROOT_DIR}" 25pwd 26 27# Clean up the intermediate files to avoid errors with Kokoro. 28# See http://b/186570469 for additional context. 29function cleanup() { 30 cd "${ROOT_DIR}" 31 echo "Cleaning up to prevent Kokoro errors (see http://b/186570469)" 32 make -f tensorflow/lite/micro/tools/make/Makefile clean clean_downloads DISABLE_DOWNLOADS=true 33} 34trap cleanup EXIT 35 36echo "Starting to run micro tests at `date`" 37 38make -f tensorflow/lite/micro/tools/make/Makefile clean_downloads DISABLE_DOWNLOADS=true 39make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=cmsis_nn clean DISABLE_DOWNLOADS=true 40if [ -d tensorflow/lite/micro/tools/make/downloads ]; then 41 echo "ERROR: Downloads directory should not exist, but it does." 42 exit 1 43fi 44 45# Check that an incorrect optimized kernel directory results in an error. 46# Without such an error, an incorrect optimized kernel directory can result in 47# an unexpected fallback to reference kernels and which can be hard to debug. We 48# add some complexity to the CI to make sure that we do not repeat the same 49# mistake as described in http://b/183546742. 50INCORRECT_CMD="make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=does_not_exist clean" 51EXT_LIBS_INC=tensorflow/lite/micro/tools/make/ext_libs/does_not_exist.inc 52touch ${EXT_LIBS_INC} 53if ${INCORRECT_CMD} &> /dev/null ; then 54 echo "'${INCORRECT_CMD}' should have failed but it did not have any errors." 55 rm -f ${EXT_LIBS_INC} 56 exit 1 57fi 58rm -f ${EXT_LIBS_INC} 59 60echo "Running code style checks at `date`" 61tensorflow/lite/micro/tools/ci_build/test_code_style.sh PRESUBMIT 62 63# Add all the test scripts for the various supported platforms here. This 64# enables running all the tests together has part of the continuous integration 65# pipeline and reduces duplication associated with setting up the docker 66# environment. 67 68if [[ ${1} == "GITHUB_PRESUBMIT" ]]; then 69 # We enable bazel as part of the github CI only. This is because the same 70 # checks are already part of the internal CI and there isn't a good reason to 71 # duplicate them. 72 # 73 # Another reason is that the bazel checks involve some patching of TF 74 # workspace and BUILD files and this is an experiment to see what the 75 # trade-off should be between the maintenance overhead, increased CI time from 76 # the unnecessary TF downloads. 77 # 78 # See https://github.com/tensorflow/tensorflow/issues/46465 and 79 # http://b/177672856 for more context. 80 echo "Running bazel tests at `date`" 81 tensorflow/lite/micro/tools/ci_build/test_bazel.sh 82 83 # Enabling FVP for github CI only. This is because it currently adds ~4mins to each 84 # Kokoro run and is only relevant for external changes. Given all the other TFLM CI 85 # coverage, it is unlikely that an internal change would break only the corstone build. 86 echo "Running cortex_m_corstone_300 tests at `date`" 87 tensorflow/lite/micro/tools/ci_build/test_cortex_m_corstone_300.sh 88 89 # Only running project generation v2 prototype as part of the github CI while 90 # it is under development. See 91 # https://github.com/tensorflow/tensorflow/issues/47413 for more context. 92 echo "Running project_generation test at `date`" 93 tensorflow/lite/micro/tools/ci_build/test_project_generation.sh 94fi 95 96echo "Running x86 tests at `date`" 97tensorflow/lite/micro/tools/ci_build/test_x86.sh 98 99echo "Running bluepill tests at `date`" 100tensorflow/lite/micro/tools/ci_build/test_bluepill.sh 101 102# TODO(b/174189223): Skipping mbed tests due to: 103# https://github.com/tensorflow/tensorflow/issues/45164 104# echo "Running mbed tests at `date`" 105# tensorflow/lite/micro/tools/ci_build/test_mbed.sh PRESUBMIT 106 107echo "Running Sparkfun tests at `date`" 108tensorflow/lite/micro/tools/ci_build/test_sparkfun.sh 109 110echo "Running stm32f4 tests at `date`" 111tensorflow/lite/micro/tools/ci_build/test_stm32f4.sh PRESUBMIT 112 113echo "Running Arduino tests at `date`" 114tensorflow/lite/micro/tools/ci_build/test_arduino.sh 115 116echo "Running cortex_m_generic tests at `date`" 117tensorflow/lite/micro/tools/ci_build/test_cortex_m_generic.sh 118 119if [[ ${1} == "GITHUB_PRESUBMIT" ]]; then 120 # This is needed to prevent rsync errors with the TFLM github Kokoro build. 121 # See https://github.com/tensorflow/tensorflow/issues/48254 for additional 122 # context. 123 make -f tensorflow/lite/micro/tools/make/Makefile clean_downloads DISABLE_DOWNLOADS=true 124fi 125 126echo "Finished all micro tests at `date`" 127