1#!/bin/bash 2# This script should be called from .ci/pytorch/build.sh. Assuming we are at pytorch source root directory. 3 4# Required environment variable: $BUILD_ENVIRONMENT 5# (This is set by default in the Docker images we build, so you don't 6# need to set it yourself. 7 8set -ex -o pipefail 9 10# shellcheck disable=SC2034 11echo "Build lite interpreter with lightweight dispatch." 12 13CUSTOM_TEST_ARTIFACT_BUILD_DIR=${CUSTOM_TEST_ARTIFACT_BUILD_DIR:-"build/custom_test_artifacts"} 14mkdir -pv "${CUSTOM_TEST_ARTIFACT_BUILD_DIR}" 15 16BUILD_LIBTORCH_PY="$PWD/tools/build_libtorch.py" 17TEST_SRC_ROOT="$PWD/test/mobile/lightweight_dispatch" 18 19pushd "$CUSTOM_TEST_ARTIFACT_BUILD_DIR" 20 21# prepare test 22OP_LIST="lightweight_dispatch_ops.yaml" 23export SELECTED_OP_LIST=$TEST_SRC_ROOT/$OP_LIST 24python "$TEST_SRC_ROOT/tests_setup.py" setup "$SELECTED_OP_LIST" 25 26export USE_DISTRIBUTED=0 27export USE_LIGHTWEIGHT_DISPATCH=1 28export STATIC_DISPATCH_BACKEND="CPU" 29export BUILD_LITE_INTERPRETER=1 30 31export USE_FBGEMM=0 32python "${BUILD_LIBTORCH_PY}" 33ret=$? 34 35if [ "$ret" -ne 0 ]; then 36 echo "Lite interpreter build failed!" 37 exit "$ret" 38fi 39 40 41# run test 42if ! build/bin/test_codegen_unboxing; then 43 echo "test_codegen_unboxing has failure!" 44 exit 1 45fi 46 47# shutdown test 48python "$TEST_SRC_ROOT/tests_setup.py" shutdown "$SELECTED_OP_LIST" 49 50popd 51 52exit 0 53