提交 602300d6 编写于 作者: L Liangliang He

Reenable bazel build

上级 384099e5
bazel-*
tags
.idea/
cmake-build-debug/
*.pyc
mace/codegen/models/
mace/codegen/opencl/
mace/codegen/opencl_bin/
mace/codegen/tuning/
mace/codegen/version/
mace/codegen/engine/
mace/codegen/lib/
build/
cmake-build/
cmake-build-debug/
docs/_build/
*.a
.idea/
.vscode/
builds/
mace/examples/android/macelibrary/src/main/cpp/mace/
tags
\.project/
*swp
*~
*.pyc
.python-version
mace/examples/android/macelibrary/src/main/cpp/include/mace/public/
mace/examples/android/macelibrary/src/main/cpp/lib/arm64-v8a/
mace/codegen/models/
mace/codegen/opencl/
mace/codegen/opencl_bin/
mace/codegen/tuning/
mace/codegen/version/
mace/codegen/engine/
mace/codegen/lib/
mace/examples/android/macelibrary/src/main/jniLibs/arm64-v8a/
examples/android/macelibrary/src/main/cpp/mace/
examples/android/macelibrary/src/main/cpp/include/
examples/android/macelibrary/src/main/cpp/lib/arm64-v8a/
examples/android/macelibrary/src/main/jniLibs/arm64-v8a/
......@@ -34,86 +34,70 @@ build_docs:
paths:
- docs/_build
build_android-armeabi-v7a:
cmake_build_android-armeabi-v7a:
stage: basic-build
script:
- sh tools/build-android-armeabi-v7a-full.sh
- sh tools/cmake-build-android-armeabi-v7a-full.sh
build_android-arm64-v8:
cmake_build_android-arm64-v8:
stage: basic-build
script:
- sh tools/build-android-arm64-v8a-full.sh
- sh tools/cmake-build-android-arm64-v8a-full.sh
code_footprint_check:
build_android_demo:
stage: basic-build
script:
- pushd examples/android/ && bash build.sh static && bash build.sh dynamic && popd
code_footprint_check:
stage: smoke-test
script:
- echo check shared library size
- LIBMACE64_FULL_SIZE=`stat -c%s build/android-arm64-v8a-full/install/lib/libmace.so`
- if (( LIBMACE64_FULL_SIZE > 3100000 )) ; then echo "The libmace.so size too large"; exit 1; fi
- LIBMACE32_FULL_SIZE=`stat -c%s build/android-armeabi-v7a-full/install/lib/libmace.so`
- if (( LIBMACE32_FULL_SIZE > 2200000 )) ; then echo "The libmace.so size too large"; exit 1; fi
cc_test_smoketest:
mace_cc_test_smoketest:
stage: smoke-test
script:
- echo tests
cc_benchmark_smoketest:
mace_cc_benchmark_smoketest:
stage: smoke-test
script:
- echo benchmark
build_arm-linux-gnueabihf:
stage: build
script:
- sh tools/build-arm-linux-gnueabihf-full.sh
only:
- triggers
build_aarch64-linux-gnu:
stage: build
script:
- sh tools/build-aarch64-linux-gnu-full.sh
only:
- triggers
build_host:
bazel_build:
stage: build
script:
- sh tools/build-host.sh
- sh tools/bazel-build-standalone-lib.sh
only:
- triggers
build_android_demo:
cmake_build:
stage: build
script:
- echo build android demo
- sh tools/cmake-build-standalone-lib.sh
only:
- triggers
cc_test:
stage: test
script:
- echo cc_test
only:
- triggers
cc_benchmark:
stage: test
script:
- echo cc_benchmark
only:
- triggers
quantization_test:
stage: test
script:
- echo quantization_test
only:
- triggers
- if [ -z "$TARGET_SOCS" ]; then TARGET_SOCS=random; fi
- >
if ping -c 1 v9.git.n.xiaomi.com 1>/dev/null 2>&1; then
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@v9.git.n.xiaomi.com:deep-computing/generic-mobile-devices.git
DEVICE_CONF_FILE=generic-mobile-devices/devices.yml
fi
- python tools/bazel_adb_run.py --target="//test/ccunit:mace_cc_test" --device_yml=${DEVICE_CONF_FILE} --run_target=True --stdout_processor=unittest_stdout_processor --target_abis=armeabi-v7a,arm64-v8a,arm64 --target_socs=$TARGET_SOCS
model_test:
mace_cc_benchmark:
stage: test
script:
- echo model_test
only:
- triggers
- if [ -z "$TARGET_SOCS" ]; then TARGET_SOCS=random; fi
- python tools/bazel_adb_run.py --target="//test/ccbenchmark:mace_cc_benchmark" --run_target=True --stdout_processor=ops_benchmark_stdout_processor --target_abis=armeabi-v7a,arm64-v8a --target_socs=$TARGET_SOCS --args="--filter=.*SIGMOID.*"
ndk_compatibility_check:
stage: extra
......@@ -122,20 +106,72 @@ ndk_compatibility_check:
only:
- triggers
python_compatibility_check:
stage: extra
model_tests:
stage: test
script:
- echo python3 check
only:
- triggers
extra_tests:
- pwd
- rm -rf mace-models
- rm -rf generic-mobile-devices
- GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:XiaoMi/mace-models.git
- CONF_FILE=mace-models/mobilenet-v1/mobilenet-v1.yml
- >
if ping -c 1 v9.git.n.xiaomi.com 1>/dev/null 2>&1; then
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@v9.git.n.xiaomi.com:deep-computing/generic-mobile-devices.git
DEVICE_CONF_FILE=generic-mobile-devices/devices.yml
fi
- if [ -z "$TARGET_SOCS" ]; then TARGET_SOCS=random; fi
- >
python tools/converter.py convert --config=${CONF_FILE} --target_socs=$TARGET_SOCS --model_graph_format=file --model_data_format=file --cl_mem_type=buffer
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --device_yml=${DEVICE_CONF_FILE} --round=1 --target_abis=armeabi-v7a,arm64 --validate --model_graph_format=file --model_data_format=file
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --device_yml=${DEVICE_CONF_FILE} --example --target_abis=armeabi-v7a,arm64 --round=1 --validate --model_graph_format=file --model_data_format=file
- CONF_FILE=mace-models/mobilenet-v2/mobilenet-v2-host.yml
- >
python tools/converter.py convert --config=${CONF_FILE} --target_socs=$TARGET_SOCS --model_graph_format=file --model_data_format=file
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --round=1 --validate --model_graph_format=file --model_data_format=file --address_sanitizer
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --example --round=1 --validate --model_graph_format=file --model_data_format=file
python tools/converter.py benchmark --config=${CONF_FILE} --target_socs=$TARGET_SOCS --round=5 --model_graph_format=file --model_data_format=file
python tools/converter.py convert --config=${CONF_FILE} --target_socs=$TARGET_SOCS --model_graph_format=code --model_data_format=file
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --round=1 --validate --model_graph_format=code --model_data_format=file
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --example --round=1 --validate --model_graph_format=code --model_data_format=file
python tools/converter.py benchmark --config=${CONF_FILE} --target_socs=$TARGET_SOCS --round=5 --model_graph_format=code --model_data_format=file
- rm -rf mace-models
quantization_tests:
stage: test
script:
- pwd
- rm -rf mace-models
- GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:XiaoMi/mace-models.git
- >
if ping -c 1 v9.git.n.xiaomi.com 1>/dev/null 2>&1; then
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@v9.git.n.xiaomi.com:deep-computing/generic-mobile-devices.git
DEVICE_CONF_FILE=generic-mobile-devices/devices.yml
fi
- if [ -z "$TARGET_SOCS" ]; then TARGET_SOCS=random; fi
- >
for CONF_FILE in mace-models/mobilenet-v1/mobilenet-v1-quantize-friendly.yml mace-models/mobilenet-v1/mobilenet-v1-quantize-retrain-for-check-only.yml mace-models/mobilenet-v1/mobilenet-v1-quantize-retrain-dsp.yml;
do
python tools/converter.py convert --config=${CONF_FILE} --target_socs=$TARGET_SOCS --model_graph_format=file --model_data_format=file
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --device_yml=${DEVICE_CONF_FILE} --round=1 --validate --model_graph_format=file --model_data_format=file
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --device_yml=${DEVICE_CONF_FILE} --example --round=1 --validate --layers=0 --model_graph_format=file --model_data_format=file
done
- rm -rf mace-models
dynamic_linking_test:
stage: extra
script:
- ops_test_disable_neon
- ops_test
- api_test
- extra_tests
- dynamic_link_test
only:
- triggers
- pwd
- rm -rf mace-models
- rm -rf generic-mobile-devices
- GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:XiaoMi/mace-models.git
- CONF_FILE=mace-models/mobilenet-v1/mobilenet-v1.yml
- >
if ping -c 1 v9.git.n.xiaomi.com 1>/dev/null 2>&1; then
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@v9.git.n.xiaomi.com:deep-computing/generic-mobile-devices.git
DEVICE_CONF_FILE=generic-mobile-devices/devices.yml
fi
- if [ -z "$TARGET_SOCS" ]; then TARGET_SOCS=random; fi
- >
python tools/converter.py convert --config=${CONF_FILE} --target_socs=$TARGET_SOCS --model_graph_format=file --model_data_format=file --cl_mem_type=buffer
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --device_yml=${DEVICE_CONF_FILE} --example --mace_lib_type=dynamic --target_abis=armeabi-v7a,arm64 --round=1 --validate --model_graph_format=file --model_data_format=file
- rm -rf mace-models
......@@ -10,7 +10,7 @@ option(MACE_ENABLE_CUDA "whether to enable CUDA support" OFF)
option(MACE_ENABLE_HEXAGON_DSP "whether to enable Hexagon DSP support" OFF)
option(MACE_ENABLE_HEXAGON_HTA "whether to enable Hexagon HTA support" OFF)
option(MACE_ENABLE_TESTS "whether to build c++ unit tests" OFF)
option(MACE_ENABLE_BENCHMARK "whether to build c++ micro benchmarks" OFF)
option(MACE_ENABLE_BENCHMARKS "whether to build c++ micro benchmarks" OFF)
option(MACE_ENABLE_EXAMPLES "whether to build examples" OFF)
option(MACE_ENABLE_OPT_SIZE "whether to build with optimized binary size" ON)
option(MACE_ENABLE_OBFUSCATE "whether to build with code obfuscation" ON)
......@@ -110,6 +110,6 @@ if(MACE_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
if(MACE_ENABLE_TESTS OR MACE_ENABLE_BENCHMARK)
if(MACE_ENABLE_TESTS OR MACE_ENABLE_BENCHMARKS)
add_subdirectory(test)
endif()
......@@ -114,8 +114,7 @@ RUN apt-get install -y --no-install-recommends \
# refer to: https://github.com/jenkinsci/docker/issues/506
RUN apt-get install -y libltdl7
RUN pip install --upgrade pip
RUN pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com setuptools
RUN pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com --upgrade pip setuptools
RUN pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com \
numpy==1.15.4 \
scipy==1.2.0 \
......
......@@ -69,8 +69,15 @@ RUN cd /opt && \
tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz && \
rm -rf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
# install protoc
RUN cd opt/ && \
wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip && \
unzip protoc-3.6.1-linux-x86_64.zip -d protoc-3.6.1 && \
rm -rf protoc-3.6.1-linux-x86_64.zip
ENV CROSS_TOOLCHAIN_PARENT /opt
ENV ANDROID_NDK_VERSION r19c
ENV ANDROID_NDK_HOME /opt/android-ndk-${ANDROID_NDK_VERSION}
ENV LINARO_ARM_LINUX_GNUEABIHF /opt/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf
ENV LINARO_AARCH64_LINUX_GNU /opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu
ENV PATH /opt/protoc-3.6.1/bin:${PATH}
......@@ -72,7 +72,7 @@ If model's output is suspected to be incorrect, it might be useful to debug your
or use binary search method until suspicious layer is found.
You can also specify `--layers` after `--validate` to validate all or some of the layers of the model(excluding some layers changed by MACE, e.g., BatchToSpaceND),
it only supports TensorFlow now. You can find validation results in `builds/your_model/model/runtime_in_yaml/log.csv`.
it only supports TensorFlow now. You can find validation results in `build/your_model/model/runtime_in_yaml/log.csv`.
For quantized model, if you want to check one layer, you can add `check_tensors` and `check_shapes` like in the yaml above. You can only specify
MACE op's output.
......@@ -113,7 +113,7 @@ Debug model conversion
After model is converted to MACE model, a literal model graph is generated in directory `mace/codegen/models/your_model`.
You can refer to it when debugging model conversion.
MACE also provides model visualization HTML generated in `builds` directory, generated after converting model.
MACE also provides model visualization HTML generated in `build` directory, generated after converting model.
Debug engine using log
......
......@@ -12,10 +12,10 @@ Run unit tests
MACE use [gtest](https://github.com/google/googletest) for unit tests.
* Run all unit tests defined in a Bazel target, for example, run `ops_test`:
* Run all unit tests defined in a Bazel target, for example, run `mace_cc_test`:
```sh
python tools/bazel_adb_run.py --target="//mace/ops:ops_test" \
python tools/bazel_adb_run.py --target="//test/ccunit:mace_cc_test" \
--run_target=True
```
......@@ -23,7 +23,7 @@ MACE use [gtest](https://github.com/google/googletest) for unit tests.
for example, run `Conv2dOpTest` unit tests:
```sh
python tools/bazel_adb_run.py --target="//mace/ops:ops_test" \
python tools/bazel_adb_run.py --target="//test/ccunit:mace_cc_test" \
--run_target=True \
--args="--gtest_filter=Conv2dOpTest*"
```
......@@ -34,10 +34,10 @@ Run micro benchmarks
MACE provides a micro benchmark framework for performance tuning.
* Run all micro benchmarks defined in a Bazel target, for example, run all
`ops_benchmark` micro benchmarks:
`mace_cc_benchmark` micro benchmarks:
```sh
python tools/bazel_adb_run.py --target="//mace/ops:ops_benchmark" \
python tools/bazel_adb_run.py --target="//test/ccbenchmark:mace_cc_benchmark" \
--run_target=True
```
......@@ -45,7 +45,7 @@ MACE provides a micro benchmark framework for performance tuning.
micro benchmarks:
```sh
python tools/bazel_adb_run.py --target="//mace/ops:ops_benchmark" \
python tools/bazel_adb_run.py --target="//test/ccbenchmark:mace_cc_benchmark" \
--run_target=True \
--args="--filter=MACE_BM_CONV_2D_.*_GPU"
```
......@@ -204,15 +204,15 @@ Convert model(s) to C++ code
python tools/converter.py convert --config=/path/to/model_deployment_file.yml
The command will generate **${library_name}.a** in **builds/${library_name}/model** directory and
** *.h ** in **builds/${library_name}/include** like the following dir-tree.
The command will generate **${library_name}.a** in **build/${library_name}/model** directory and
** *.h ** in **build/${library_name}/include** like the following dir-tree.
.. code::
# model_graph_format: code
# model_data_format: file
builds
build
├── include
│   └── mace
│   └── public
......@@ -225,7 +225,7 @@ Convert model(s) to C++ code
# model_graph_format: code
# model_data_format: code
builds
build
├── include
│   └── mace
│   └── public
......@@ -305,11 +305,11 @@ Tuning for specific SoC's GPU
python tools/converter.py run --config=/path/to/model_deployment_file.yml --validate
The command will generate two files in `builds/${library_name}/opencl`, like the following dir-tree.
The command will generate two files in `build/${library_name}/opencl`, like the following dir-tree.
.. code::
builds
build
└── mobilenet-v2
├── model
│   ├── mobilenet_v2.data
......
......@@ -44,17 +44,17 @@ Here we use the mobilenet-v2 model as an example.
cd path/to/mace
# Build library
# output lib path: builds/lib
bash tools/build-standalone-lib.sh
# output lib path: build/lib
bash tools/bazel-build-standalone-lib.sh
.. note::
- This step can be skipped if you just want to run a model using ``tools/converter.py``, such as commands in step 5.
- Libraries in ``builds/lib/armeabi-v7a/cpu_gpu/`` means it can run on ``cpu`` or ``gpu`` devices.
- Libraries in ``build/lib/armeabi-v7a/cpu_gpu/`` means it can run on ``cpu`` or ``gpu`` devices.
- The results in ``builds/lib/armeabi-v7a/cpu_gpu_dsp/`` need HVX supported.
- The results in ``build/lib/armeabi-v7a/cpu_gpu_dsp/`` need HVX supported.
4. Convert the pre-trained mobilenet-v2 model to MACE format model.
......@@ -170,7 +170,7 @@ When the deployment file is ready, you can use MACE converter tool to convert yo
python tools/converter.py convert --config=/path/to/your/model_deployment_file.yml
This command will download or load your pre-trained model and convert it to a MACE model proto file and weights data file.
The generated model files will be stored in ``builds/${library_name}/model`` folder.
The generated model files will be stored in ``build/${library_name}/model`` folder.
.. warning::
......@@ -188,10 +188,10 @@ Or use bazel to build MACE source code into a library.
cd path/to/mace
# Build library
# output lib path: builds/lib
bash tools/build-standalone-lib.sh
# output lib path: build/lib
bash tools/bazel-build-standalone-lib.sh
The above command will generate dynamic library ``builds/lib/${ABI}/${DEVICES}/libmace.so`` and static library ``builds/lib/${ABI}/${DEVICES}/libmace.a``.
The above command will generate dynamic library ``build/lib/${ABI}/${DEVICES}/libmace.so`` and static library ``build/lib/${ABI}/${DEVICES}/libmace.a``.
.. warning::
......@@ -278,7 +278,7 @@ header files.
.. code::
builds
build
├── include
│   └── mace
│   └── public
......
......@@ -20,7 +20,7 @@ Usage
.. code:: bash
python tools/bazel_adb_run.py --target="//mace/ops:ops_benchmark" --run_target=True --args="--filter=.*BM_CONV.*"
python tools/bazel_adb_run.py --target="//test/ccbenchmark:mace_cc_benchmark" --run_target=True --args="--filter=.*BM_CONV.*"
======
Output
......
......@@ -20,12 +20,12 @@ fi
MACE_LINK_TYPE=$1
pushd ../../../
pushd ../..
TARGET_ABI=arm64-v8a
ANDROID_DEMO_DIR=mace/examples/android/
ANDROID_DEMO_DIR=examples/android/
LIBRARY_DIR=$ANDROID_DEMO_DIR/macelibrary/src/main/cpp/
INCLUDE_DIR=$LIBRARY_DIR/include/mace/public/
INCLUDE_DIR=$LIBRARY_DIR/include
LIBMACE_DIR=$LIBRARY_DIR/lib/$TARGET_ABI/
LIBGNUSTL_SHARED_SO=libgnustl_shared.so
LIBCPP_SHARED_SO=libc++_shared.so
......@@ -44,20 +44,17 @@ else
exit 1
fi
rm -rf $LIBRARY_DIR/include/
mkdir -p $INCLUDE_DIR
rm -rf $LIBRARY_DIR/lib/
mkdir -p $LIBMACE_DIR
python tools/converter.py convert --config=examples/android/mobilenet.yml --target_abis=$TARGET_ABI
rm -rf $INCLUDE_DIR && mkdir -p $INCLUDE_DIR
rm -rf $LIBMACE_DIR && mkdir -p $LIBMACE_DIR
rm -rf $LIBRARY_DIR/model/
python tools/converter.py convert --config=mace/examples/android/mobilenet.yml --target_abis=$TARGET_ABI
cp -rf builds/mobilenet/include/mace/public/*.h $INCLUDE_DIR
cp -rf builds/mobilenet/model $LIBRARY_DIR
cp -rf include/mace $INCLUDE_DIR
cp -rf build/mobilenet/include/mace/public/*.h $INCLUDE_DIR/mace/public/
cp -rf build/mobilenet/model $LIBRARY_DIR
bazel build --config android --config optimization $BAZEL_LIBMACE_TARGET --define neon=true --define openmp=true --define opencl=true --define quantize=true --cpu=$TARGET_ABI
cp -rf mace/public/*.h $INCLUDE_DIR
cp -rf $BAZEL_GEN_LIBMACE_PATH $LIBMACE_DIR
if [ $MACE_LINK_TYPE == "dynamic" ]; then
......
......@@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.4.1)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../app/libs/${ANDROID_ABI})
include_directories(${CMAKE_SOURCE_DIR}/)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include)
file(GLOB LIBMACE "${CMAKE_SOURCE_DIR}/src/main/cpp/lib/arm64-v8a/*")
set(mace_lib ${LIBMACE})
......
......@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/main/cpp/image_classify.h"
#include "image_classify.h"
#include <android/log.h>
#include <jni.h>
......@@ -25,9 +25,8 @@
#include <vector>
#include <numeric>
#include "src/main/cpp/include/mace/public/mace.h"
#include "src/main/cpp/include/mace/public/mace_engine_factory.h"
#include "mace/public/mace.h"
#include "mace/public/mace_engine_factory.h"
namespace {
......
# Description:
# MACE public API.
#
package(
default_visibility = ["//visibility:public"],
)
......@@ -8,12 +5,12 @@ package(
licenses(["notice"]) # Apache 2.0
cc_library(
name = "public",
hdrs = [
"mace.h",
],
srcs = [
"status.cc",
],
name = "public_headers",
hdrs = glob([
"mace/public/*.h",
"mace/port/*.h",
"mace/utils/*.h",
]),
strip_include_prefix = "",
copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"],
)
......@@ -121,13 +121,17 @@ inline MaceStatus GetEnv(const char *name, std::string *value) {
if (error != 0) {
return MaceStatus::MACE_RUNTIME_ERROR;
} else {
*value = std::string(val);
free(val);
if (val != nullptr) {
*value = std::string(val);
free(val);
}
return MaceStatus::MACE_SUCCESS;
}
#else
char *val = getenv(name);
*value = std::string(val);
if (val != nullptr) {
*value = std::string(val);
}
return MaceStatus::MACE_SUCCESS;
#endif
}
......
......@@ -8,7 +8,7 @@ package(
load("//mace:mace.bzl", "mace_version_genrule", "encrypt_opencl_kernel_genrule")
cc_library(
name = "libmodels",
name = "generated_models",
srcs = glob(["models/*/*.cc"]),
hdrs = glob(["models/*/*.h"]),
copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"],
......@@ -17,17 +17,6 @@ cc_library(
],
)
genrule(
name = "generated_models",
srcs = [
":libmodels",
],
outs = ["libgenerated_models.a"],
cmd = "binary=`echo $(locations :libmodels) | xargs -n 1 | grep libmodels.a`;" +
"$(STRIP) -x $$binary -o $@",
visibility = ["//visibility:public"],
)
mace_version_genrule()
encrypt_opencl_kernel_genrule()
......@@ -61,7 +50,7 @@ cc_library(
hdrs = glob(["engine/*.h"]),
copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"],
deps = [
"//mace/public",
"//include:public_headers",
],
)
......
# Description:
# Mace core.
#
package(
default_visibility = ["//visibility:public"],
)
......@@ -30,9 +27,6 @@ cc_library(
"*.cc",
"runtime/cpu/*.cc",
],
exclude = [
"*_test.cc",
],
) + if_opencl_enabled(glob(
[
"runtime/opencl/*.cc",
......@@ -118,28 +112,3 @@ cc_library(
"@opencl_headers//:opencl20_headers",
],
)
cc_library(
name = "test_benchmark_main",
testonly = 1,
srcs = [
"testing/test_benchmark.cc",
"testing/test_benchmark_main.cc",
],
hdrs = [
"testing/test_benchmark.h",
],
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_openmp_enabled(["-fopenmp"]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]),
deps = [
":core",
"//external:gflags_nothreads",
"//mace/ops:test",
"//mace/utils",
],
)
......@@ -50,7 +50,7 @@ cc_library(
]),
deps = [
"//mace/ops",
"//mace/public",
"//include:public_headers",
],
alwayslink = 1,
)
......@@ -91,6 +91,7 @@ cc_library(
genrule(
name = "libmace_static",
srcs = [
"//include:public_headers",
"//mace/codegen:generated_version",
"//mace/core",
"//mace/ops:common",
......@@ -100,7 +101,6 @@ genrule(
"//mace/libmace",
"//mace/port:port_base",
"//mace/port/posix:port_posix",
"//mace/public",
"//mace/utils",
"//mace/proto:mace_cc",
"@com_google_protobuf//:protobuf_lite",
......@@ -155,7 +155,6 @@ genrule(
"$(locations //mace/port/darwin:port_darwin) ",
default_value = "",
) +
"$(locations //mace/public:public) " +
"$(locations //mace/utils:utils) " +
"$(locations //mace/proto:mace_cc) " +
"$(locations @com_google_protobuf//:protobuf_lite) " +
......
......@@ -52,35 +52,6 @@ cc_library(
],
)
cc_library(
name = "testing",
hdrs = [
"testing/test_utils.h",
],
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_openmp_enabled([
"-fopenmp",
]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_quantize_enabled([
"-DMACE_ENABLE_QUANTIZE",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
deps = [
"//mace/core",
"@gtest",
],
)
cc_library(
name = "ref_kernels",
srcs = glob(
......@@ -178,11 +149,6 @@ cc_library(
[
"opencl/*.cc",
"opencl/**/*.cc",
"buffer_transform.cc",
"lstm_cell.cc",
],
exclude = [
"opencl/*_test.cc",
],
),
hdrs = glob(
......@@ -215,78 +181,6 @@ cc_library(
],
)
cc_library(
name = "arm_neon_kernels_test",
srcs = glob(
[
"arm/fp32/*_test.cc",
],
) + if_quantize_enabled(glob(
[
"arm/q8/*_test.cc",
],
)),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_openmp_enabled([
"-fopenmp",
]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_quantize_enabled([
"-DMACE_ENABLE_QUANTIZE",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
deps = [
":arm_neon_kernels",
":ref_kernels",
":testing",
"@gtest",
],
alwayslink = 1,
)
cc_library(
name = "opencl_kernels_test",
srcs = glob(
[
"opencl/*_test.cc",
"opencl/**/*_test.cc",
],
),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_openmp_enabled([
"-fopenmp",
]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_quantize_enabled([
"-DMACE_ENABLE_QUANTIZE",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
deps = [
":opencl_kernels",
":ref_kernels",
":testing",
"@gtest",
],
alwayslink = 1,
)
cc_library(
name = "internal_ops",
......@@ -294,32 +188,12 @@ cc_library(
[
"*.cc",
],
exclude = [
"*_test.cc",
"*_benchmark.cc",
"ops_registry.cc",
"ops_test_util.cc",
"lstm_cell.cc", # TODO: move it into opencl
"buffer_transform.cc", # TODO: move it into opencl
"quantize.cc",
"quantization_util.cc",
"arm/*_test.cc", # remove it after refactor
],
) + if_quantize_enabled(
glob(
[
"quantize.cc",
"quantization_util.cc",
],
),
),
hdrs = glob(
[
"*.h",
],
exclude = [
"ops_registry.h",
"ops_test_util.h",
"fixpoint.h",
"common/gemmlowp_util.h",
"quantization_util.h",
......@@ -363,16 +237,12 @@ cc_library(
cc_library(
name = "ops",
srcs = glob(
[
"ops_registry.cc",
srcs = [
"registry/ops_registry.cc",
],
),
hdrs = glob(
[
"ops_registry.h",
hdrs = [
"registry/ops_registry.h",
],
),
copts = [
"-Werror",
"-Wextra",
......@@ -396,118 +266,3 @@ cc_library(
"internal_ops",
],
)
cc_library(
name = "test",
testonly = 1,
srcs = [
"ops_test_util.cc",
],
hdrs = glob([
"*_test_util.h",
]),
copts = [
"-Werror",
"-Wextra",
] + if_openmp_enabled(["-fopenmp"]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
]) + if_android_armv7([
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
deps = [
"ops",
"testing",
"@gtest",
],
)
cc_test(
name = "ops_test",
testonly = 1,
srcs = glob(
[
"*_test.cc",
"arm/*_test.cc", # remove it after refactor
"ops_test_util.cc",
],
exclude = [
"fixpoint_test.cc",
],
) + if_quantize_enabled(glob(
[
"fixpoint_test.cc",
],
)),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_openmp_enabled([
"-fopenmp",
]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_quantize_enabled([
"-DMACE_ENABLE_QUANTIZE",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
linkopts = if_openmp_enabled([
"-fopenmp",
]),
linkstatic = 1,
deps = [
":ops",
":test",
"@gtest//:gtest_main",
] + if_neon_enabled([
":arm_neon_kernels_test",
]) + if_opencl_enabled([
":opencl_kernels_test",
]),
)
cc_test(
name = "ops_benchmark",
testonly = 1,
srcs = glob(["*_benchmark.cc"]),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_openmp_enabled([
"-fopenmp",
]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_quantize_enabled([
"-DMACE_ENABLE_QUANTIZE",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
linkopts = if_openmp_enabled([
"-fopenmp",
]),
linkstatic = 1,
deps = [
":ops",
"//mace/benchmark:statistics",
"//mace/core:test_benchmark_main",
"//third_party/eigen3",
"@gemmlowp",
],
)
......@@ -13,42 +13,15 @@ cc_library(
],
)
cc_library(
name = "port_api",
hdrs = [
"env.h",
"file_system.h",
"logger.h",
"port.h",
"port-arch.h",
],
deps = [
"//mace/public",
],
)
cc_library(
name = "port_base",
srcs = [
"env.cc",
"logger.cc",
"file_system.cc",
],
deps = [
":port_api",
"//mace/utils",
],
)
cc_test(
name = "port_test",
testonly = 1,
srcs = glob([
"*_test.cc",
]),
linkstatic = 1,
deps = [
":port",
"@gtest",
"@gtest//:gtest_main",
"//include:public_headers",
],
)
......@@ -20,7 +20,7 @@ class NPEncoder(json.JSONEncoder):
class ModelVisualizer(object):
def __init__(self, model_name, proto):
self._output_file = "builds/%s_index.html" % model_name
self._output_file = "build/%s_index.html" % model_name
self._proto = proto
def render_html(self):
......
......@@ -26,8 +26,7 @@ cc_library(
"-Wno-missing-field-initializers",
],
deps = [
"//mace/port:port_api",
"//mace/public",
"//include:public_headers",
],
)
......@@ -37,9 +36,6 @@ cc_library(
[
"*.cc",
],
exclude = [
"*_test.cc",
],
),
copts = [
"-Werror",
......@@ -61,25 +57,3 @@ cc_library(
],
alwayslink = 1,
)
cc_test(
name = "utils_test",
testonly = 1,
srcs = glob(
[
"*_test.cc",
],
),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
],
linkstatic = 1,
deps = [
":utils",
"//mace/port",
"@gtest//:gtest",
"@gtest//:gtest_main",
],
)
......@@ -6,6 +6,6 @@ if(MACE_ENABLE_TESTS)
add_subdirectory(ccunit)
endif()
if(MACE_ENABLE_BENCHMARK)
if(MACE_ENABLE_BENCHMARKS)
add_subdirectory(ccbenchmark)
endif()
package(
default_visibility = ["//visibility:public"],
)
licenses(["notice"]) # Apache 2.0
load(
"//mace:mace.bzl",
"if_android",
"if_android_armv7",
"if_hexagon_enabled",
"if_neon_enabled",
"if_opencl_enabled",
"if_openmp_enabled",
"if_quantize_enabled",
)
cc_library(
name = "benchmark_utils",
testonly = 1,
hdrs = glob([
"mace/benchmark_utils/*.h",
]),
srcs = glob([
"mace/benchmark_utils/*.cc",
]),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
],
strip_include_prefix = "",
deps = [
"//mace/core",
"//test/ccutils",
"//external:gflags_nothreads",
],
)
cc_test(
name = "mace_cc_benchmark",
testonly = 1,
srcs = glob(
[
"mace/ops/*.cc",
],
),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
"-fopenmp",
] + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_quantize_enabled([
"-DMACE_ENABLE_QUANTIZE",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
linkopts = [
"-fopenmp",
],
linkstatic = 1,
deps = [
"benchmark_utils",
"//mace/ops",
"//third_party/eigen3",
"@gemmlowp",
],
)
package(
default_visibility = ["//visibility:public"],
)
licenses(["notice"]) # Apache 2.0
load(
"//mace:mace.bzl",
"if_android",
"if_android_armv7",
"if_hexagon_enabled",
"if_neon_enabled",
"if_opencl_enabled",
"if_openmp_enabled",
"if_quantize_enabled",
)
cc_test(
name = "mace_cc_test",
testonly = 1,
srcs = glob(
[
"mace/libmace/*.cc",
"mace/ops/*.cc",
"mace/port/*.cc",
"mace/utils/*.cc",
],
exclude = [
"mace/ops/fixpoint_test.cc",
],
) + if_neon_enabled(glob(
[
"mace/ops/arm/fp32/*.cc",
]
)) + if_quantize_enabled(glob(
[
"mace/ops/arm/q8/*.cc",
"mace/ops/fixpoint_test.cc",
]
)) + if_opencl_enabled(glob(
[
"mace/ops/opencl/*.cc",
]
)),
copts = [
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_openmp_enabled([
"-fopenmp",
]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_quantize_enabled([
"-DMACE_ENABLE_QUANTIZE",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
linkopts = if_openmp_enabled([
"-fopenmp",
]),
linkstatic = 1,
deps = [
"//mace/ops",
"//test/ccutils",
"@gtest//:gtest_main",
],
)
package(
default_visibility = ["//visibility:public"],
)
licenses(["notice"]) # Apache 2.0
load(
"//mace:mace.bzl",
"if_android",
"if_android_armv7",
"if_hexagon_enabled",
"if_neon_enabled",
"if_opencl_enabled",
"if_openmp_enabled",
"if_quantize_enabled",
)
cc_library(
name = "ccutils",
testonly = 1,
srcs = glob([
"mace/ops/*.cc",
]),
hdrs = glob([
"mace/ops/*.h",
"mace/ops/testing/*.h",
]),
strip_include_prefix = "",
copts = [
"-Werror",
"-Wextra",
] + if_openmp_enabled(["-fopenmp"]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]) + if_android_armv7([
"-mfpu=neon-fp16",
]) + if_android_armv7([
"-mfloat-abi=softfp",
]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]),
deps = [
"//mace/ops",
"@gtest",
],
)
......@@ -15,5 +15,6 @@ genrule(
cc_library(
name = "opencl_clhpp",
hdrs = ["include/CL/cl.hpp", "include/CL/cl2.hpp"],
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)
......@@ -56,53 +56,65 @@ add_dependencies(libprotobuf_lite protobuf)
install(FILES ${PROTOBUF_LITE_LIBRARIES} DESTINATION lib)
if(NOT APPLE)
# Actually this works for iOS build on macOS, but the compatibility is not
# thoroughly tested, so we use the downloaded version instead.
set(PROTOC_CMAKE_GENERATOR ${CMAKE_GENERATOR})
if(APPLE AND ${CMAKE_GENERATOR} STREQUAL "Xcode")
# Force Xcode to build protoc on host
set(PROTOC_CMAKE_GENERATOR "Unix Makefiles")
execute_process(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOS_PRODVER)
set(EXTRA_MACOS_CMAKE_ARGS
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_PRODVER}
)
endif(APPLE AND ${CMAKE_GENERATOR} STREQUAL "Xcode")
set(BUILD_PROTOC TRUE)
if(COMMAND protoc)
execute_process(COMMAND protoc OUTPUT_VARIABLE PROTOC_VER)
if(${PROTOC_VER} STREQUAL "libprotoc 3.6.1")
set(PROTOC_BIN protoc CACHE FILEPATH "protoc compiler." FORCE)
set(BUILD_PROTOC FALSE)
add_custom_target(protoc_bin COMMENT "protoc noop target")
endif(${PROTOC_VER} STREQUAL "libprotoc 3.6.1")
endif(COMMAND protoc)
if(BUILD_PROTOC)
if(NOT APPLE)
# Actually this works for iOS build on macOS, but the compatibility is not
# thoroughly tested, so we use the downloaded version instead.
set(PROTOC_CMAKE_GENERATOR ${CMAKE_GENERATOR})
if(APPLE AND ${CMAKE_GENERATOR} STREQUAL "Xcode")
# Force Xcode to build protoc on host
set(PROTOC_CMAKE_GENERATOR "Unix Makefiles")
execute_process(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOS_PRODVER)
set(EXTRA_MACOS_CMAKE_ARGS
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_PRODVER}
)
endif(APPLE AND ${CMAKE_GENERATOR} STREQUAL "Xcode")
ExternalProject_Add(
protoc_bin
URL_HASH "${PROTOBUF_HASH}"
URL "${PROTOBUF_URL}"
PREFIX "${PROTOC_SRCS_DIR}"
BUILD_BYPRODUCTS "${PROTOC_BIN}"
SOURCE_DIR "${PROTOC_SRCS_DIR}/src/protoc"
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../protoc/cmake/
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${PROTOC_INSTALL_DIR}
-DCMAKE_VERBOSE_MAKEFILE=OFF
-Dprotobuf_BUILD_TESTS=OFF
-Dprotobuf_WITH_ZLIB=OFF
-Dprotobuf_BUILD_PROTOC_BINARIES=ON
-DCMAKE_GENERATOR=${PROTOC_CMAKE_GENERATOR}
${EXTRA_MACOS_CMAKE_ARGS}
ExternalProject_Add(
protoc_bin
URL_HASH "${PROTOBUF_HASH}"
URL "${PROTOBUF_URL}"
PREFIX "${PROTOC_SRCS_DIR}"
BUILD_BYPRODUCTS "${PROTOC_BIN}"
SOURCE_DIR "${PROTOC_SRCS_DIR}/src/protoc"
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../protoc/cmake/
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${PROTOC_INSTALL_DIR}
-DCMAKE_VERBOSE_MAKEFILE=OFF
-Dprotobuf_BUILD_TESTS=OFF
-Dprotobuf_WITH_ZLIB=OFF
-Dprotobuf_BUILD_PROTOC_BINARIES=ON
-DCMAKE_GENERATOR=${PROTOC_CMAKE_GENERATOR}
${EXTRA_MACOS_CMAKE_ARGS}
)
else(APPLE)
# This is backup protoc when build doesn't work for macOS+iOS
# Mirror of "https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-osx-x86_64.zip"
set(PROTOC_URL "https://cnbj1.fds.api.xiaomi.com/mace/third-party/protobuf/protoc-3.6.1-osx-x86_64.zip")
set(PROTOC_HASH "SHA256=0decc6ce5beed07f8c20361ddeb5ac7666f09cf34572cca530e16814093f9c0c")
ExternalProject_Add(
protoc_bin
URL_HASH "${PROTOC_HASH}"
URL "${PROTOC_URL}"
PREFIX "${PROTOC_SRCS_DIR}"
BINARY_DIR ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(PROTOC_BIN
"${PROTOC_SRCS_DIR}/src/protoc_bin/bin/protoc" CACHE FILEPATH "protoc compiler." FORCE)
endif(NOT APPLE)
else(APPLE)
# This is backup protoc when build doesn't work for macOS+iOS
# Mirror of "https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-osx-x86_64.zip"
set(PROTOC_URL "https://cnbj1.fds.api.xiaomi.com/mace/third-party/protobuf/protoc-3.6.1-osx-x86_64.zip")
set(PROTOC_HASH "SHA256=0decc6ce5beed07f8c20361ddeb5ac7666f09cf34572cca530e16814093f9c0c")
ExternalProject_Add(
protoc_bin
URL_HASH "${PROTOC_HASH}"
URL "${PROTOC_URL}"
PREFIX "${PROTOC_SRCS_DIR}"
BINARY_DIR ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(PROTOC_BIN
"${PROTOC_SRCS_DIR}/src/protoc_bin/bin/protoc" CACHE FILEPATH "protoc compiler." FORCE)
endif(NOT APPLE)
endif(BUILD_PROTOC)
#!/bin/bash
set -e
LIB_DIR=build/lib
INCLUDE_DIR=build/include
mkdir -p $LIB_DIR
mkdir -p $INCLUDE_DIR
# copy include headers
cp -R include/mace $INCLUDE_DIR/
# make directories
rm -rf $LIB_DIR/armeabi-v7a
mkdir -p $LIB_DIR/armeabi-v7a/cpu_gpu_dsp
mkdir -p $LIB_DIR/armeabi-v7a/cpu_gpu
rm -rf $LIB_DIR/arm64-v8a
mkdir -p $LIB_DIR/arm64-v8a/cpu_gpu_dsp
mkdir -p $LIB_DIR/arm64-v8a/cpu_gpu
rm -rf $LIB_DIR/linux-x86-64
mkdir -p $LIB_DIR/linux-x86-64
rm -rf $LIB_DIR/arm_linux_gnueabihf
mkdir -p $LIB_DIR/arm_linux_gnueabihf/cpu_gpu
rm -rf $LIB_DIR/aarch64_linux_gnu
mkdir -p $LIB_DIR/aarch64_linux_gnu/cpu_gpu
# build shared libraries
echo "build shared lib for armeabi-v7a + cpu_gpu_dsp"
bazel build --config android --config optimization mace/libmace:libmace_dynamic --define neon=true --define openmp=false --define opencl=true --define hexagon=true --define quantize=true --cpu=armeabi-v7a
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/armeabi-v7a/cpu_gpu_dsp/
cp third_party/nnlib/armeabi-v7a/*so $LIB_DIR/armeabi-v7a/cpu_gpu_dsp/
echo "build shared lib for arm64-v8a + cpu_gpu_dsp"
bazel build --config android --config optimization mace/libmace:libmace_dynamic --define neon=true --define openmp=false --define opencl=true --define hexagon=true --define quantize=true --cpu=arm64-v8a
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/arm64-v8a/cpu_gpu_dsp/
cp third_party/nnlib/arm64-v8a/*so $LIB_DIR/arm64-v8a/cpu_gpu_dsp/
echo "build shared lib for armeabi-v7a + cpu_gpu"
bazel build --config android --config optimization mace/libmace:libmace_dynamic --define neon=true --define openmp=false --define opencl=true --define quantize=true --cpu=armeabi-v7a
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/armeabi-v7a/cpu_gpu/
echo "build shared lib for arm64-v8a + cpu_gpu"
bazel build --config android --config optimization mace/libmace:libmace_dynamic --define neon=true --define openmp=false --define opencl=true --define quantize=true --cpu=arm64-v8a
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/arm64-v8a/cpu_gpu/
echo "build shared lib for arm_linux_gnueabihf + cpu_gpu"
bazel build --config arm_linux_gnueabihf --config optimization mace/libmace:libmace_dynamic --define neon=true --define openmp=false --define opencl=true --define quantize=true
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/arm_linux_gnueabihf/cpu_gpu/
echo "build shared lib for aarch64_linux_gnu + cpu_gpu"
bazel build --config aarch64_linux_gnu --config optimization mace/libmace:libmace_dynamic --define neon=true --define openmp=false --define opencl=true --define quantize=true
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/aarch64_linux_gnu/cpu_gpu/
if [[ "$OSTYPE" != "darwin"* ]];then
echo "build shared lib for linux-x86-64"
bazel build mace/libmace:libmace_dynamic --config optimization --define openmp=false
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/linux-x86-64/
fi
# build static libraries
echo "build static lib for armeabi-v7a + cpu_gpu_dsp"
bazel build --config android --config optimization mace/libmace:libmace_static --config symbol_hidden --define neon=true --define openmp=false --define opencl=true --define hexagon=true --define quantize=true --cpu=armeabi-v7a
cp bazel-genfiles/mace/libmace/libmace.a $LIB_DIR/armeabi-v7a/cpu_gpu_dsp/
cp third_party/nnlib/armeabi-v7a/*so $LIB_DIR/armeabi-v7a/cpu_gpu_dsp/
echo "build static lib for arm64-v8a + cpu_gpu_dsp"
bazel build --config android --config optimization mace/libmace:libmace_static --config symbol_hidden --define neon=true --define openmp=false --define opencl=true --define hexagon=true --define quantize=true --cpu=arm64-v8a
cp bazel-genfiles/mace/libmace/libmace.a $LIB_DIR/arm64-v8a/cpu_gpu_dsp/
cp third_party/nnlib/arm64-v8a/*so $LIB_DIR/arm64-v8a/cpu_gpu_dsp/
echo "build static lib for armeabi-v7a + cpu_gpu"
bazel build --config android --config optimization mace/libmace:libmace_static --config symbol_hidden --define neon=true --define openmp=false --define opencl=true --define quantize=true --cpu=armeabi-v7a
cp bazel-genfiles/mace/libmace/libmace.a $LIB_DIR/armeabi-v7a/cpu_gpu/
echo "build static lib for arm64-v8a + cpu_gpu"
bazel build --config android --config optimization mace/libmace:libmace_static --config symbol_hidden --define neon=true --define openmp=false --define opencl=true --define quantize=true --cpu=arm64-v8a
cp bazel-genfiles/mace/libmace/libmace.a $LIB_DIR/arm64-v8a/cpu_gpu/
echo "build static lib for arm_linux_gnueabihf + cpu_gpu"
bazel build --config arm_linux_gnueabihf --config optimization mace/libmace:libmace_static --config symbol_hidden --define neon=true --define openmp=false --define opencl=true --define quantize=true
cp bazel-genfiles/mace/libmace/libmace.a $LIB_DIR/arm_linux_gnueabihf/cpu_gpu/
echo "build static lib for aarch64_linux_gnu + cpu_gpu"
bazel build --config aarch64_linux_gnu --config optimization mace/libmace:libmace_static --config symbol_hidden --define neon=true --define openmp=false --define opencl=true --define quantize=true
cp bazel-genfiles/mace/libmace/libmace.a $LIB_DIR/aarch64_linux_gnu/cpu_gpu/
if [[ "$OSTYPE" != "darwin"* ]];then
echo "build static lib for linux-x86-64"
bazel build mace/libmace:libmace_static --config optimization --define openmp=false
cp bazel-genfiles/mace/libmace/libmace.a $LIB_DIR/linux-x86-64/
fi
echo "LIB PATH: $LIB_DIR"
echo "INCLUDE FILE PATH: $INCLUDE_DIR"
......@@ -16,7 +16,7 @@
# python tools/bazel_adb_run.py \
# --target_abis=armeabi-v7a \
# --target_socs=sdm845
# --target=//mace/ops:ops_test
# --target=//test/ccunit:mace_cc_test
# --stdout_processor=stdout_processor
import argparse
......@@ -43,22 +43,6 @@ def ops_benchmark_stdout_processor(stdout, dev, abi):
for line in stdout_lines:
if "Aborted" in line or "Segmentation fault" in line:
raise Exception("Command failed")
line = line.strip()
parts = line.split()
if len(parts) == 5 and parts[0].startswith("BM_"):
metrics["%s.time_ms" % parts[0]] = str(float(parts[1]) / 1e6)
metrics["%s.input_mb_per_sec" % parts[0]] = parts[3]
metrics["%s.gmac_per_sec" % parts[0]] = parts[4]
# platform = dev[YAMLKeyword.target_socs]
# model = dev[YAMLKeyword.device_name]
# tags = {
# "ro.board.platform": platform,
# "ro.product.model": model,
# "abi": abi
# }
# sh_commands.falcon_push_metrics(server,
# metrics, tags=tags, endpoint="mace_ops_benchmark")
# TODO: after merge mace/python/tools and tools are merged,
......
......@@ -3,7 +3,7 @@
set -e
# build for arm linux aarch64
BUILD_DIR=build/aarch64-linux-gnu-full
BUILD_DIR=cmake-build/aarch64-linux-gnu-full
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DCROSSTOOL_ROOT=${LINARO_AARCH64_LINUX_GNU} \
-DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/aarch64-linux-gnu.cmake \
......@@ -15,5 +15,5 @@ cmake -DCROSSTOOL_ROOT=${LINARO_AARCH64_LINUX_GNU} \
-DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \
../..
make -j8 VERBOSE=1 && make install
make -j6 VERBOSE=1 && make install
cd ../..
......@@ -3,7 +3,7 @@
set -e
# build for android arm64-v8a
BUILD_DIR=build/android-arm64-v8a-cpu
BUILD_DIR=cmake-build/android-arm64-v8a-cpu
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="arm64-v8a" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
......@@ -19,5 +19,5 @@ cmake -DANDROID_ABI="arm64-v8a" \
-DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \
../..
make -j8 VERBOSE=1 && make install
make -j6 VERBOSE=1 && make install
cd ../..
......@@ -3,7 +3,7 @@
set -e
# build for android arm64-v8a
BUILD_DIR=build/android-arm64-v8a-full
BUILD_DIR=cmake-build/android-arm64-v8a-full
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="arm64-v8a" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
......@@ -19,5 +19,5 @@ cmake -DANDROID_ABI="arm64-v8a" \
-DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \
../..
make -j8 VERBOSE=1 && make install
make -j6 VERBOSE=1 && make install
cd ../..
......@@ -3,7 +3,7 @@
set -e
# build for android armeabi-v7a
BUILD_DIR=build/android-armeabi-v7a-cpu
BUILD_DIR=cmake-build/android-armeabi-v7a-cpu
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="armeabi-v7a" \
-DANDROID_ARM_NEON=ON \
......@@ -20,5 +20,5 @@ cmake -DANDROID_ABI="armeabi-v7a" \
-DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \
../..
make -j8 VERBOSE=1 && make install
make -j6 VERBOSE=1 && make install
cd ../..
......@@ -3,7 +3,7 @@
set -e
# build for android armeabi-v7a
BUILD_DIR=build/android-armeabi-v7a-full
BUILD_DIR=cmake-build/android-armeabi-v7a-full
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="armeabi-v7a" \
-DANDROID_ARM_NEON=ON \
......@@ -20,5 +20,5 @@ cmake -DANDROID_ABI="armeabi-v7a" \
-DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \
../..
make -j8 VERBOSE=1 && make install
make -j6 VERBOSE=1 && make install
cd ../..
......@@ -3,7 +3,7 @@
set -e
# build for arm linux gnueabihf
BUILD_DIR=build/arm-linux-gnueabihf-full
BUILD_DIR=cmake-build/arm-linux-gnueabihf-full
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DCROSSTOOL_ROOT=${LINARO_ARM_LINUX_GNUEABIHF} \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/arm-linux-gnueabihf.cmake \
......@@ -15,5 +15,5 @@ cmake -DCROSSTOOL_ROOT=${LINARO_ARM_LINUX_GNUEABIHF} \
-DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \
../..
make -j8 VERBOSE=1 && make install
make -j6 VERBOSE=1 && make install
cd ../..
......@@ -3,12 +3,12 @@
set -e
# build for host
BUILD_DIR=build/host
BUILD_DIR=cmake-build/host
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DMACE_ENABLE_NEON=OFF \
-DMACE_ENABLE_QUANTIZE=OFF \
-DMACE_ENABLE_OPENCL=ON \
-DCMAKE_INSTALL_PREFIX=install \
../..
make -j8 VERBOSE=1 && make install
make -j6 VERBOSE=1 && make install
cd ../..
......@@ -438,7 +438,7 @@ class SystemType:
PHONE_DATA_DIR = '/data/local/tmp/mace_run'
DEVICE_DATA_DIR = '/tmp/data/mace_run'
DEVICE_INTERIOR_DIR = PHONE_DATA_DIR + "/interior"
BUILD_OUTPUT_DIR = 'builds'
BUILD_OUTPUT_DIR = 'build'
BUILD_TMP_DIR_NAME = '_tmp'
BUILD_DOWNLOADS_DIR = BUILD_OUTPUT_DIR + '/downloads'
BUILD_TMP_GENERAL_OUTPUT_DIR_NAME = 'general'
......@@ -469,7 +469,7 @@ LIBMACE_SO_TARGET = "//mace/libmace:libmace.so"
LIBMACE_STATIC_TARGET = "//mace/libmace:libmace_static"
LIBMACE_STATIC_PATH = "bazel-genfiles/mace/libmace/libmace.a"
MODEL_LIB_TARGET = "//mace/codegen:generated_models"
MODEL_LIB_PATH = "bazel-genfiles/mace/codegen/libgenerated_models.a"
MODEL_LIB_PATH = "bazel-bin/mace/codegen/libgenerated_models.a"
QUANTIZE_STAT_TARGET = "//mace/tools/quantization:quantize_stat"
BM_MODEL_STATIC_NAME = "benchmark_model_static"
BM_MODEL_DYNAMIC_NAME = "benchmark_model_dynamic"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册