generate_production_code.sh 928 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#!/bin/bash

Usage() {
  echo "Usage: bash tools/generate_production_code.sh cl_bin_dirs pull_or_not"
}

if [ $# -lt 2 ]; then
  Usage
  exit 1
fi

CURRENT_DIR=`dirname $0`
source ${CURRENT_DIR}/env.sh

CL_BIN_DIRS=$1
PULL_OR_NOT=$2

if [ "$PULL_OR_NOT" = 1 ]; then
  CL_BIN_DIR=${CL_BIN_DIRS}
  rm -rf ${CL_BIN_DIR}
  mkdir -p ${CL_BIN_DIR}
  if [ x"$RUNTIME" != x"local" ]; then
    adb pull ${KERNEL_DIR}/. ${CL_BIN_DIR}
    adb pull ${PHONE_DATA_DIR}/mace_run.config ${CL_BIN_DIR}
  fi
fi

rm -rf ${CL_CODEGEN_DIR}
mkdir -p ${CL_CODEGEN_DIR}
rm -rf ${TUNING_CODEGEN_DIR}
mkdir -p ${TUNING_CODEGEN_DIR}

set -x

python lib/python/tools/opencl_codegen.py \
  --cl_binary_dirs=${CL_BIN_DIRS} \
  --output_path=${CL_CODEGEN_DIR}/opencl_compiled_program.cc

python lib/python/tools/binary_codegen.py \
  --binary_dirs=${CL_BIN_DIRS} \
  --binary_file_name=mace_run.config \
  --output_path=${TUNING_CODEGEN_DIR}/tuning_params.cc