xref: /aosp_15_r20/external/pytorch/test/mobile/nnc/test_aot_compile.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/bin/bash
2
3set -e -o pipefail
4
5TORCH_INSTALL_DIR=$(python -c "import site; print(site.getsitepackages()[0])")/torch
6TORCH_BIN_DIR="$TORCH_INSTALL_DIR"/bin
7CURRENT_DIR="$(dirname "${BASH_SOURCE[0]}")"
8
9MODEL=aot_test_model.pt
10COMPILED_MODEL=aot_test_model.compiled.pt
11COMPILED_CODE=aot_test_model.compiled.ll
12TMP_DIR=$(mktemp -d -t build_XXX)
13
14test_aot_model_compiler() {
15  python "$CURRENT_DIR"/aot_test_model.py
16  mv "$MODEL" "$TMP_DIR"/
17  pushd "$TMP_DIR"
18  "$TORCH_BIN_DIR"/aot_model_compiler_test --model "$MODEL" --model_name=aot_test_model --output_llvm=$COMPILED_CODE --model_version=v1 --input_dims="2,2,2"
19  if [ ! -f "$COMPILED_MODEL" ] || [ ! -f "$COMPILED_CODE" ]; then
20    echo "AOT model compiler failed to generate $COMPILED_MODEL and $COMPILED_CODE"
21    exit 1
22  fi
23  popd
24}
25
26# Temporarily disable the test since NNC backend is no longer available.
27# test_aot_model_compiler
28