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

Reenable bazel build

上级 384099e5
bazel-* 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/ build/
cmake-build/
cmake-build-debug/
docs/_build/ docs/_build/
*.a *.a
.idea/
.vscode/ .vscode/
builds/ tags
mace/examples/android/macelibrary/src/main/cpp/mace/
\.project/ \.project/
*swp *swp
*~ *~
*.pyc
.python-version .python-version
mace/examples/android/macelibrary/src/main/cpp/include/mace/public/ mace/codegen/models/
mace/codegen/opencl/
mace/examples/android/macelibrary/src/main/cpp/lib/arm64-v8a/ 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: ...@@ -34,86 +34,70 @@ build_docs:
paths: paths:
- docs/_build - docs/_build
build_android-armeabi-v7a: cmake_build_android-armeabi-v7a:
stage: basic-build stage: basic-build
script: 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 stage: basic-build
script: 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 stage: basic-build
script:
- pushd examples/android/ && bash build.sh static && bash build.sh dynamic && popd
code_footprint_check:
stage: smoke-test
script: script:
- echo check shared library size - 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 stage: smoke-test
script: script:
- echo tests - echo tests
cc_benchmark_smoketest: mace_cc_benchmark_smoketest:
stage: smoke-test stage: smoke-test
script: script:
- echo benchmark - echo benchmark
build_arm-linux-gnueabihf: bazel_build:
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:
stage: build stage: build
script: script:
- sh tools/build-host.sh - sh tools/bazel-build-standalone-lib.sh
only: only:
- triggers - triggers
build_android_demo: cmake_build:
stage: build stage: build
script: script:
- echo build android demo - sh tools/cmake-build-standalone-lib.sh
only: only:
- triggers - triggers
cc_test: cc_test:
stage: test stage: test
script: script:
- echo cc_test - if [ -z "$TARGET_SOCS" ]; then TARGET_SOCS=random; fi
only: - >
- triggers 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
cc_benchmark: DEVICE_CONF_FILE=generic-mobile-devices/devices.yml
stage: test fi
script: - 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
- echo cc_benchmark
only:
- triggers
quantization_test:
stage: test
script:
- echo quantization_test
only:
- triggers
model_test: mace_cc_benchmark:
stage: test stage: test
script: script:
- echo model_test - if [ -z "$TARGET_SOCS" ]; then TARGET_SOCS=random; fi
only: - 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.*"
- triggers
ndk_compatibility_check: ndk_compatibility_check:
stage: extra stage: extra
...@@ -122,20 +106,72 @@ ndk_compatibility_check: ...@@ -122,20 +106,72 @@ ndk_compatibility_check:
only: only:
- triggers - triggers
python_compatibility_check: model_tests:
stage: extra stage: test
script: script:
- echo python3 check - pwd
only: - rm -rf mace-models
- triggers - 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
extra_tests: - 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 stage: extra
script: script:
- ops_test_disable_neon - pwd
- ops_test - rm -rf mace-models
- api_test - rm -rf generic-mobile-devices
- extra_tests - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:XiaoMi/mace-models.git
- dynamic_link_test - CONF_FILE=mace-models/mobilenet-v1/mobilenet-v1.yml
only: - >
- triggers 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) ...@@ -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_DSP "whether to enable Hexagon DSP support" OFF)
option(MACE_ENABLE_HEXAGON_HTA "whether to enable Hexagon HTA 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_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_EXAMPLES "whether to build examples" OFF)
option(MACE_ENABLE_OPT_SIZE "whether to build with optimized binary size" ON) option(MACE_ENABLE_OPT_SIZE "whether to build with optimized binary size" ON)
option(MACE_ENABLE_OBFUSCATE "whether to build with code obfuscation" ON) option(MACE_ENABLE_OBFUSCATE "whether to build with code obfuscation" ON)
...@@ -110,6 +110,6 @@ if(MACE_ENABLE_EXAMPLES) ...@@ -110,6 +110,6 @@ if(MACE_ENABLE_EXAMPLES)
add_subdirectory(examples) add_subdirectory(examples)
endif() endif()
if(MACE_ENABLE_TESTS OR MACE_ENABLE_BENCHMARK) if(MACE_ENABLE_TESTS OR MACE_ENABLE_BENCHMARKS)
add_subdirectory(test) add_subdirectory(test)
endif() endif()
...@@ -114,8 +114,7 @@ RUN apt-get install -y --no-install-recommends \ ...@@ -114,8 +114,7 @@ RUN apt-get install -y --no-install-recommends \
# refer to: https://github.com/jenkinsci/docker/issues/506 # refer to: https://github.com/jenkinsci/docker/issues/506
RUN apt-get install -y libltdl7 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 --upgrade pip setuptools
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 \ RUN pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com \
numpy==1.15.4 \ numpy==1.15.4 \
scipy==1.2.0 \ scipy==1.2.0 \
......
...@@ -69,8 +69,15 @@ RUN cd /opt && \ ...@@ -69,8 +69,15 @@ RUN cd /opt && \
tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz && \ 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 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 CROSS_TOOLCHAIN_PARENT /opt
ENV ANDROID_NDK_VERSION r19c ENV ANDROID_NDK_VERSION r19c
ENV ANDROID_NDK_HOME /opt/android-ndk-${ANDROID_NDK_VERSION} 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_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 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 ...@@ -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. 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), 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 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. MACE op's output.
...@@ -113,7 +113,7 @@ Debug model conversion ...@@ -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`. 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. 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 Debug engine using log
......
...@@ -12,10 +12,10 @@ Run unit tests ...@@ -12,10 +12,10 @@ Run unit tests
MACE use [gtest](https://github.com/google/googletest) for 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 ```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 --run_target=True
``` ```
...@@ -23,7 +23,7 @@ MACE use [gtest](https://github.com/google/googletest) for unit tests. ...@@ -23,7 +23,7 @@ MACE use [gtest](https://github.com/google/googletest) for unit tests.
for example, run `Conv2dOpTest` unit tests: for example, run `Conv2dOpTest` unit tests:
```sh ```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 \ --run_target=True \
--args="--gtest_filter=Conv2dOpTest*" --args="--gtest_filter=Conv2dOpTest*"
``` ```
...@@ -34,10 +34,10 @@ Run micro benchmarks ...@@ -34,10 +34,10 @@ Run micro benchmarks
MACE provides a micro benchmark framework for performance tuning. MACE provides a micro benchmark framework for performance tuning.
* Run all micro benchmarks defined in a Bazel target, for example, run all * Run all micro benchmarks defined in a Bazel target, for example, run all
`ops_benchmark` micro benchmarks: `mace_cc_benchmark` micro benchmarks:
```sh ```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 --run_target=True
``` ```
...@@ -45,7 +45,7 @@ MACE provides a micro benchmark framework for performance tuning. ...@@ -45,7 +45,7 @@ MACE provides a micro benchmark framework for performance tuning.
micro benchmarks: micro benchmarks:
```sh ```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 \ --run_target=True \
--args="--filter=MACE_BM_CONV_2D_.*_GPU" --args="--filter=MACE_BM_CONV_2D_.*_GPU"
``` ```
...@@ -204,15 +204,15 @@ Convert model(s) to C++ code ...@@ -204,15 +204,15 @@ Convert model(s) to C++ code
python tools/converter.py convert --config=/path/to/model_deployment_file.yml 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 The command will generate **${library_name}.a** in **build/${library_name}/model** directory and
** *.h ** in **builds/${library_name}/include** like the following dir-tree. ** *.h ** in **build/${library_name}/include** like the following dir-tree.
.. code:: .. code::
# model_graph_format: code # model_graph_format: code
# model_data_format: file # model_data_format: file
builds build
├── include ├── include
│   └── mace │   └── mace
│   └── public │   └── public
...@@ -225,7 +225,7 @@ Convert model(s) to C++ code ...@@ -225,7 +225,7 @@ Convert model(s) to C++ code
# model_graph_format: code # model_graph_format: code
# model_data_format: code # model_data_format: code
builds build
├── include ├── include
│   └── mace │   └── mace
│   └── public │   └── public
...@@ -305,11 +305,11 @@ Tuning for specific SoC's GPU ...@@ -305,11 +305,11 @@ Tuning for specific SoC's GPU
python tools/converter.py run --config=/path/to/model_deployment_file.yml --validate 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:: .. code::
builds build
└── mobilenet-v2 └── mobilenet-v2
├── model ├── model
│   ├── mobilenet_v2.data │   ├── mobilenet_v2.data
......
...@@ -44,17 +44,17 @@ Here we use the mobilenet-v2 model as an example. ...@@ -44,17 +44,17 @@ Here we use the mobilenet-v2 model as an example.
cd path/to/mace cd path/to/mace
# Build library # Build library
# output lib path: builds/lib # output lib path: build/lib
bash tools/build-standalone-lib.sh bash tools/bazel-build-standalone-lib.sh
.. note:: .. note::
- This step can be skipped if you just want to run a model using ``tools/converter.py``, such as commands in step 5. - 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. 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 ...@@ -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 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. 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:: .. warning::
...@@ -188,10 +188,10 @@ Or use bazel to build MACE source code into a library. ...@@ -188,10 +188,10 @@ Or use bazel to build MACE source code into a library.
cd path/to/mace cd path/to/mace
# Build library # Build library
# output lib path: builds/lib # output lib path: build/lib
bash tools/build-standalone-lib.sh 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:: .. warning::
...@@ -278,7 +278,7 @@ header files. ...@@ -278,7 +278,7 @@ header files.
.. code:: .. code::
builds build
├── include ├── include
│   └── mace │   └── mace
│   └── public │   └── public
......
...@@ -20,7 +20,7 @@ Usage ...@@ -20,7 +20,7 @@ Usage
.. code:: bash .. 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 Output
......
...@@ -20,12 +20,12 @@ fi ...@@ -20,12 +20,12 @@ fi
MACE_LINK_TYPE=$1 MACE_LINK_TYPE=$1
pushd ../../../ pushd ../..
TARGET_ABI=arm64-v8a TARGET_ABI=arm64-v8a
ANDROID_DEMO_DIR=mace/examples/android/ ANDROID_DEMO_DIR=examples/android/
LIBRARY_DIR=$ANDROID_DEMO_DIR/macelibrary/src/main/cpp/ 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/ LIBMACE_DIR=$LIBRARY_DIR/lib/$TARGET_ABI/
LIBGNUSTL_SHARED_SO=libgnustl_shared.so LIBGNUSTL_SHARED_SO=libgnustl_shared.so
LIBCPP_SHARED_SO=libc++_shared.so LIBCPP_SHARED_SO=libc++_shared.so
...@@ -44,20 +44,17 @@ else ...@@ -44,20 +44,17 @@ else
exit 1 exit 1
fi fi
rm -rf $LIBRARY_DIR/include/ python tools/converter.py convert --config=examples/android/mobilenet.yml --target_abis=$TARGET_ABI
mkdir -p $INCLUDE_DIR
rm -rf $LIBRARY_DIR/lib/
mkdir -p $LIBMACE_DIR
rm -rf $INCLUDE_DIR && mkdir -p $INCLUDE_DIR
rm -rf $LIBMACE_DIR && mkdir -p $LIBMACE_DIR
rm -rf $LIBRARY_DIR/model/ rm -rf $LIBRARY_DIR/model/
python tools/converter.py convert --config=mace/examples/android/mobilenet.yml --target_abis=$TARGET_ABI cp -rf include/mace $INCLUDE_DIR
cp -rf builds/mobilenet/include/mace/public/*.h $INCLUDE_DIR cp -rf build/mobilenet/include/mace/public/*.h $INCLUDE_DIR/mace/public/
cp -rf builds/mobilenet/model $LIBRARY_DIR 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 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 cp -rf $BAZEL_GEN_LIBMACE_PATH $LIBMACE_DIR
if [ $MACE_LINK_TYPE == "dynamic" ]; then if [ $MACE_LINK_TYPE == "dynamic" ]; then
......
...@@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.4.1) ...@@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.4.1)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../app/libs/${ANDROID_ABI}) #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../app/libs/${ANDROID_ABI})
include_directories(${CMAKE_SOURCE_DIR}/) include_directories(${CMAKE_SOURCE_DIR}/)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include) include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include)
file(GLOB LIBMACE "${CMAKE_SOURCE_DIR}/src/main/cpp/lib/arm64-v8a/*") file(GLOB LIBMACE "${CMAKE_SOURCE_DIR}/src/main/cpp/lib/arm64-v8a/*")
set(mace_lib ${LIBMACE}) set(mace_lib ${LIBMACE})
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/main/cpp/image_classify.h" #include "image_classify.h"
#include <android/log.h> #include <android/log.h>
#include <jni.h> #include <jni.h>
...@@ -25,9 +25,8 @@ ...@@ -25,9 +25,8 @@
#include <vector> #include <vector>
#include <numeric> #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.h"
#include "mace/public/mace_engine_factory.h"
namespace { namespace {
......
# Description:
# MACE public API.
#
package( package(
default_visibility = ["//visibility:public"], default_visibility = ["//visibility:public"],
) )
...@@ -8,12 +5,12 @@ package( ...@@ -8,12 +5,12 @@ package(
licenses(["notice"]) # Apache 2.0 licenses(["notice"]) # Apache 2.0
cc_library( cc_library(
name = "public", name = "public_headers",
hdrs = [ hdrs = glob([
"mace.h", "mace/public/*.h",
], "mace/port/*.h",
srcs = [ "mace/utils/*.h",
"status.cc", ]),
], strip_include_prefix = "",
copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"],
) )
...@@ -121,13 +121,17 @@ inline MaceStatus GetEnv(const char *name, std::string *value) { ...@@ -121,13 +121,17 @@ inline MaceStatus GetEnv(const char *name, std::string *value) {
if (error != 0) { if (error != 0) {
return MaceStatus::MACE_RUNTIME_ERROR; return MaceStatus::MACE_RUNTIME_ERROR;
} else { } else {
*value = std::string(val); if (val != nullptr) {
free(val); *value = std::string(val);
free(val);
}
return MaceStatus::MACE_SUCCESS; return MaceStatus::MACE_SUCCESS;
} }
#else #else
char *val = getenv(name); char *val = getenv(name);
*value = std::string(val); if (val != nullptr) {
*value = std::string(val);
}
return MaceStatus::MACE_SUCCESS; return MaceStatus::MACE_SUCCESS;
#endif #endif
} }
......
...@@ -8,7 +8,7 @@ package( ...@@ -8,7 +8,7 @@ package(
load("//mace:mace.bzl", "mace_version_genrule", "encrypt_opencl_kernel_genrule") load("//mace:mace.bzl", "mace_version_genrule", "encrypt_opencl_kernel_genrule")
cc_library( cc_library(
name = "libmodels", name = "generated_models",
srcs = glob(["models/*/*.cc"]), srcs = glob(["models/*/*.cc"]),
hdrs = glob(["models/*/*.h"]), hdrs = glob(["models/*/*.h"]),
copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"],
...@@ -17,17 +17,6 @@ cc_library( ...@@ -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() mace_version_genrule()
encrypt_opencl_kernel_genrule() encrypt_opencl_kernel_genrule()
...@@ -61,7 +50,7 @@ cc_library( ...@@ -61,7 +50,7 @@ cc_library(
hdrs = glob(["engine/*.h"]), hdrs = glob(["engine/*.h"]),
copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"],
deps = [ deps = [
"//mace/public", "//include:public_headers",
], ],
) )
......
# Description:
# Mace core.
#
package( package(
default_visibility = ["//visibility:public"], default_visibility = ["//visibility:public"],
) )
...@@ -30,9 +27,6 @@ cc_library( ...@@ -30,9 +27,6 @@ cc_library(
"*.cc", "*.cc",
"runtime/cpu/*.cc", "runtime/cpu/*.cc",
], ],
exclude = [
"*_test.cc",
],
) + if_opencl_enabled(glob( ) + if_opencl_enabled(glob(
[ [
"runtime/opencl/*.cc", "runtime/opencl/*.cc",
...@@ -118,28 +112,3 @@ cc_library( ...@@ -118,28 +112,3 @@ cc_library(
"@opencl_headers//:opencl20_headers", "@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( ...@@ -50,7 +50,7 @@ cc_library(
]), ]),
deps = [ deps = [
"//mace/ops", "//mace/ops",
"//mace/public", "//include:public_headers",
], ],
alwayslink = 1, alwayslink = 1,
) )
...@@ -91,6 +91,7 @@ cc_library( ...@@ -91,6 +91,7 @@ cc_library(
genrule( genrule(
name = "libmace_static", name = "libmace_static",
srcs = [ srcs = [
"//include:public_headers",
"//mace/codegen:generated_version", "//mace/codegen:generated_version",
"//mace/core", "//mace/core",
"//mace/ops:common", "//mace/ops:common",
...@@ -100,7 +101,6 @@ genrule( ...@@ -100,7 +101,6 @@ genrule(
"//mace/libmace", "//mace/libmace",
"//mace/port:port_base", "//mace/port:port_base",
"//mace/port/posix:port_posix", "//mace/port/posix:port_posix",
"//mace/public",
"//mace/utils", "//mace/utils",
"//mace/proto:mace_cc", "//mace/proto:mace_cc",
"@com_google_protobuf//:protobuf_lite", "@com_google_protobuf//:protobuf_lite",
...@@ -155,7 +155,6 @@ genrule( ...@@ -155,7 +155,6 @@ genrule(
"$(locations //mace/port/darwin:port_darwin) ", "$(locations //mace/port/darwin:port_darwin) ",
default_value = "", default_value = "",
) + ) +
"$(locations //mace/public:public) " +
"$(locations //mace/utils:utils) " + "$(locations //mace/utils:utils) " +
"$(locations //mace/proto:mace_cc) " + "$(locations //mace/proto:mace_cc) " +
"$(locations @com_google_protobuf//:protobuf_lite) " + "$(locations @com_google_protobuf//:protobuf_lite) " +
......
...@@ -52,35 +52,6 @@ cc_library( ...@@ -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( cc_library(
name = "ref_kernels", name = "ref_kernels",
srcs = glob( srcs = glob(
...@@ -178,11 +149,6 @@ cc_library( ...@@ -178,11 +149,6 @@ cc_library(
[ [
"opencl/*.cc", "opencl/*.cc",
"opencl/**/*.cc", "opencl/**/*.cc",
"buffer_transform.cc",
"lstm_cell.cc",
],
exclude = [
"opencl/*_test.cc",
], ],
), ),
hdrs = glob( hdrs = glob(
...@@ -215,78 +181,6 @@ cc_library( ...@@ -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( cc_library(
name = "internal_ops", name = "internal_ops",
...@@ -294,32 +188,12 @@ cc_library( ...@@ -294,32 +188,12 @@ cc_library(
[ [
"*.cc", "*.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( hdrs = glob(
[ [
"*.h", "*.h",
], ],
exclude = [ exclude = [
"ops_registry.h",
"ops_test_util.h",
"fixpoint.h", "fixpoint.h",
"common/gemmlowp_util.h", "common/gemmlowp_util.h",
"quantization_util.h", "quantization_util.h",
...@@ -363,16 +237,12 @@ cc_library( ...@@ -363,16 +237,12 @@ cc_library(
cc_library( cc_library(
name = "ops", name = "ops",
srcs = glob( srcs = [
[ "registry/ops_registry.cc",
"ops_registry.cc",
], ],
), hdrs = [
hdrs = glob( "registry/ops_registry.h",
[
"ops_registry.h",
], ],
),
copts = [ copts = [
"-Werror", "-Werror",
"-Wextra", "-Wextra",
...@@ -396,118 +266,3 @@ cc_library( ...@@ -396,118 +266,3 @@ cc_library(
"internal_ops", "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( ...@@ -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( cc_library(
name = "port_base", name = "port_base",
srcs = [ srcs = [
"env.cc", "env.cc",
"logger.cc", "logger.cc",
"file_system.cc",
], ],
deps = [ deps = [
":port_api",
"//mace/utils", "//mace/utils",
], "//include:public_headers",
)
cc_test(
name = "port_test",
testonly = 1,
srcs = glob([
"*_test.cc",
]),
linkstatic = 1,
deps = [
":port",
"@gtest",
"@gtest//:gtest_main",
], ],
) )
...@@ -20,7 +20,7 @@ class NPEncoder(json.JSONEncoder): ...@@ -20,7 +20,7 @@ class NPEncoder(json.JSONEncoder):
class ModelVisualizer(object): class ModelVisualizer(object):
def __init__(self, model_name, proto): 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 self._proto = proto
def render_html(self): def render_html(self):
......
...@@ -26,8 +26,7 @@ cc_library( ...@@ -26,8 +26,7 @@ cc_library(
"-Wno-missing-field-initializers", "-Wno-missing-field-initializers",
], ],
deps = [ deps = [
"//mace/port:port_api", "//include:public_headers",
"//mace/public",
], ],
) )
...@@ -37,9 +36,6 @@ cc_library( ...@@ -37,9 +36,6 @@ cc_library(
[ [
"*.cc", "*.cc",
], ],
exclude = [
"*_test.cc",
],
), ),
copts = [ copts = [
"-Werror", "-Werror",
...@@ -61,25 +57,3 @@ cc_library( ...@@ -61,25 +57,3 @@ cc_library(
], ],
alwayslink = 1, 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) ...@@ -6,6 +6,6 @@ if(MACE_ENABLE_TESTS)
add_subdirectory(ccunit) add_subdirectory(ccunit)
endif() endif()
if(MACE_ENABLE_BENCHMARK) if(MACE_ENABLE_BENCHMARKS)
add_subdirectory(ccbenchmark) add_subdirectory(ccbenchmark)
endif() 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( ...@@ -15,5 +15,6 @@ genrule(
cc_library( cc_library(
name = "opencl_clhpp", name = "opencl_clhpp",
hdrs = ["include/CL/cl.hpp", "include/CL/cl2.hpp"], hdrs = ["include/CL/cl.hpp", "include/CL/cl2.hpp"],
strip_include_prefix = "include",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
...@@ -56,53 +56,65 @@ add_dependencies(libprotobuf_lite protobuf) ...@@ -56,53 +56,65 @@ add_dependencies(libprotobuf_lite protobuf)
install(FILES ${PROTOBUF_LITE_LIBRARIES} DESTINATION lib) install(FILES ${PROTOBUF_LITE_LIBRARIES} DESTINATION lib)
if(NOT APPLE) set(BUILD_PROTOC TRUE)
# Actually this works for iOS build on macOS, but the compatibility is not if(COMMAND protoc)
# thoroughly tested, so we use the downloaded version instead. execute_process(COMMAND protoc OUTPUT_VARIABLE PROTOC_VER)
set(PROTOC_CMAKE_GENERATOR ${CMAKE_GENERATOR}) if(${PROTOC_VER} STREQUAL "libprotoc 3.6.1")
if(APPLE AND ${CMAKE_GENERATOR} STREQUAL "Xcode") set(PROTOC_BIN protoc CACHE FILEPATH "protoc compiler." FORCE)
# Force Xcode to build protoc on host set(BUILD_PROTOC FALSE)
set(PROTOC_CMAKE_GENERATOR "Unix Makefiles") add_custom_target(protoc_bin COMMENT "protoc noop target")
execute_process(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOS_PRODVER) endif(${PROTOC_VER} STREQUAL "libprotoc 3.6.1")
set(EXTRA_MACOS_CMAKE_ARGS endif(COMMAND protoc)
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_PRODVER} if(BUILD_PROTOC)
) if(NOT APPLE)
endif(APPLE AND ${CMAKE_GENERATOR} STREQUAL "Xcode") # 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( ExternalProject_Add(
protoc_bin protoc_bin
URL_HASH "${PROTOBUF_HASH}" URL_HASH "${PROTOBUF_HASH}"
URL "${PROTOBUF_URL}" URL "${PROTOBUF_URL}"
PREFIX "${PROTOC_SRCS_DIR}" PREFIX "${PROTOC_SRCS_DIR}"
BUILD_BYPRODUCTS "${PROTOC_BIN}" BUILD_BYPRODUCTS "${PROTOC_BIN}"
SOURCE_DIR "${PROTOC_SRCS_DIR}/src/protoc" SOURCE_DIR "${PROTOC_SRCS_DIR}/src/protoc"
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../protoc/cmake/ CONFIGURE_COMMAND ${CMAKE_COMMAND} ../protoc/cmake/
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${PROTOC_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${PROTOC_INSTALL_DIR}
-DCMAKE_VERBOSE_MAKEFILE=OFF -DCMAKE_VERBOSE_MAKEFILE=OFF
-Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_TESTS=OFF
-Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_WITH_ZLIB=OFF
-Dprotobuf_BUILD_PROTOC_BINARIES=ON -Dprotobuf_BUILD_PROTOC_BINARIES=ON
-DCMAKE_GENERATOR=${PROTOC_CMAKE_GENERATOR} -DCMAKE_GENERATOR=${PROTOC_CMAKE_GENERATOR}
${EXTRA_MACOS_CMAKE_ARGS} ${EXTRA_MACOS_CMAKE_ARGS}
) )
else(APPLE) else(APPLE)
# This is backup protoc when build doesn't work for macOS+iOS # 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" # 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_URL "https://cnbj1.fds.api.xiaomi.com/mace/third-party/protobuf/protoc-3.6.1-osx-x86_64.zip")
set(PROTOC_HASH "SHA256=0decc6ce5beed07f8c20361ddeb5ac7666f09cf34572cca530e16814093f9c0c") set(PROTOC_HASH "SHA256=0decc6ce5beed07f8c20361ddeb5ac7666f09cf34572cca530e16814093f9c0c")
ExternalProject_Add( ExternalProject_Add(
protoc_bin protoc_bin
URL_HASH "${PROTOC_HASH}" URL_HASH "${PROTOC_HASH}"
URL "${PROTOC_URL}" URL "${PROTOC_URL}"
PREFIX "${PROTOC_SRCS_DIR}" PREFIX "${PROTOC_SRCS_DIR}"
BINARY_DIR "" BINARY_DIR ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND ""
) )
set(PROTOC_BIN set(PROTOC_BIN
"${PROTOC_SRCS_DIR}/src/protoc_bin/bin/protoc" CACHE FILEPATH "protoc compiler." FORCE) "${PROTOC_SRCS_DIR}/src/protoc_bin/bin/protoc" CACHE FILEPATH "protoc compiler." FORCE)
endif(NOT APPLE) 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 @@ ...@@ -16,7 +16,7 @@
# python tools/bazel_adb_run.py \ # python tools/bazel_adb_run.py \
# --target_abis=armeabi-v7a \ # --target_abis=armeabi-v7a \
# --target_socs=sdm845 # --target_socs=sdm845
# --target=//mace/ops:ops_test # --target=//test/ccunit:mace_cc_test
# --stdout_processor=stdout_processor # --stdout_processor=stdout_processor
import argparse import argparse
...@@ -43,22 +43,6 @@ def ops_benchmark_stdout_processor(stdout, dev, abi): ...@@ -43,22 +43,6 @@ def ops_benchmark_stdout_processor(stdout, dev, abi):
for line in stdout_lines: for line in stdout_lines:
if "Aborted" in line or "Segmentation fault" in line: if "Aborted" in line or "Segmentation fault" in line:
raise Exception("Command failed") 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, # TODO: after merge mace/python/tools and tools are merged,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set -e set -e
# build for arm linux aarch64 # 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} rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DCROSSTOOL_ROOT=${LINARO_AARCH64_LINUX_GNU} \ cmake -DCROSSTOOL_ROOT=${LINARO_AARCH64_LINUX_GNU} \
-DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/aarch64-linux-gnu.cmake \ -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/aarch64-linux-gnu.cmake \
...@@ -15,5 +15,5 @@ cmake -DCROSSTOOL_ROOT=${LINARO_AARCH64_LINUX_GNU} \ ...@@ -15,5 +15,5 @@ cmake -DCROSSTOOL_ROOT=${LINARO_AARCH64_LINUX_GNU} \
-DMACE_ENABLE_OBFUSCATE=ON \ -DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
../.. ../..
make -j8 VERBOSE=1 && make install make -j6 VERBOSE=1 && make install
cd ../.. cd ../..
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set -e set -e
# build for android arm64-v8a # 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} rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="arm64-v8a" \ cmake -DANDROID_ABI="arm64-v8a" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \ -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
...@@ -19,5 +19,5 @@ cmake -DANDROID_ABI="arm64-v8a" \ ...@@ -19,5 +19,5 @@ cmake -DANDROID_ABI="arm64-v8a" \
-DMACE_ENABLE_OBFUSCATE=ON \ -DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
../.. ../..
make -j8 VERBOSE=1 && make install make -j6 VERBOSE=1 && make install
cd ../.. cd ../..
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set -e set -e
# build for android arm64-v8a # 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} rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="arm64-v8a" \ cmake -DANDROID_ABI="arm64-v8a" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \ -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
...@@ -19,5 +19,5 @@ cmake -DANDROID_ABI="arm64-v8a" \ ...@@ -19,5 +19,5 @@ cmake -DANDROID_ABI="arm64-v8a" \
-DMACE_ENABLE_OBFUSCATE=ON \ -DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
../.. ../..
make -j8 VERBOSE=1 && make install make -j6 VERBOSE=1 && make install
cd ../.. cd ../..
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set -e set -e
# build for android armeabi-v7a # 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} rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="armeabi-v7a" \ cmake -DANDROID_ABI="armeabi-v7a" \
-DANDROID_ARM_NEON=ON \ -DANDROID_ARM_NEON=ON \
...@@ -20,5 +20,5 @@ cmake -DANDROID_ABI="armeabi-v7a" \ ...@@ -20,5 +20,5 @@ cmake -DANDROID_ABI="armeabi-v7a" \
-DMACE_ENABLE_OBFUSCATE=ON \ -DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
../.. ../..
make -j8 VERBOSE=1 && make install make -j6 VERBOSE=1 && make install
cd ../.. cd ../..
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set -e set -e
# build for android armeabi-v7a # 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} rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DANDROID_ABI="armeabi-v7a" \ cmake -DANDROID_ABI="armeabi-v7a" \
-DANDROID_ARM_NEON=ON \ -DANDROID_ARM_NEON=ON \
...@@ -20,5 +20,5 @@ cmake -DANDROID_ABI="armeabi-v7a" \ ...@@ -20,5 +20,5 @@ cmake -DANDROID_ABI="armeabi-v7a" \
-DMACE_ENABLE_OBFUSCATE=ON \ -DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
../.. ../..
make -j8 VERBOSE=1 && make install make -j6 VERBOSE=1 && make install
cd ../.. cd ../..
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set -e set -e
# build for arm linux gnueabihf # 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} rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DCROSSTOOL_ROOT=${LINARO_ARM_LINUX_GNUEABIHF} \ cmake -DCROSSTOOL_ROOT=${LINARO_ARM_LINUX_GNUEABIHF} \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/arm-linux-gnueabihf.cmake \ -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/arm-linux-gnueabihf.cmake \
...@@ -15,5 +15,5 @@ cmake -DCROSSTOOL_ROOT=${LINARO_ARM_LINUX_GNUEABIHF} \ ...@@ -15,5 +15,5 @@ cmake -DCROSSTOOL_ROOT=${LINARO_ARM_LINUX_GNUEABIHF} \
-DMACE_ENABLE_OBFUSCATE=ON \ -DMACE_ENABLE_OBFUSCATE=ON \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
../.. ../..
make -j8 VERBOSE=1 && make install make -j6 VERBOSE=1 && make install
cd ../.. cd ../..
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
set -e set -e
# build for host # build for host
BUILD_DIR=build/host BUILD_DIR=cmake-build/host
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DMACE_ENABLE_NEON=OFF \ cmake -DMACE_ENABLE_NEON=OFF \
-DMACE_ENABLE_QUANTIZE=OFF \ -DMACE_ENABLE_QUANTIZE=OFF \
-DMACE_ENABLE_OPENCL=ON \ -DMACE_ENABLE_OPENCL=ON \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
../.. ../..
make -j8 VERBOSE=1 && make install make -j6 VERBOSE=1 && make install
cd ../.. cd ../..
...@@ -438,7 +438,7 @@ class SystemType: ...@@ -438,7 +438,7 @@ class SystemType:
PHONE_DATA_DIR = '/data/local/tmp/mace_run' PHONE_DATA_DIR = '/data/local/tmp/mace_run'
DEVICE_DATA_DIR = '/tmp/data/mace_run' DEVICE_DATA_DIR = '/tmp/data/mace_run'
DEVICE_INTERIOR_DIR = PHONE_DATA_DIR + "/interior" DEVICE_INTERIOR_DIR = PHONE_DATA_DIR + "/interior"
BUILD_OUTPUT_DIR = 'builds' BUILD_OUTPUT_DIR = 'build'
BUILD_TMP_DIR_NAME = '_tmp' BUILD_TMP_DIR_NAME = '_tmp'
BUILD_DOWNLOADS_DIR = BUILD_OUTPUT_DIR + '/downloads' BUILD_DOWNLOADS_DIR = BUILD_OUTPUT_DIR + '/downloads'
BUILD_TMP_GENERAL_OUTPUT_DIR_NAME = 'general' BUILD_TMP_GENERAL_OUTPUT_DIR_NAME = 'general'
...@@ -469,7 +469,7 @@ LIBMACE_SO_TARGET = "//mace/libmace:libmace.so" ...@@ -469,7 +469,7 @@ LIBMACE_SO_TARGET = "//mace/libmace:libmace.so"
LIBMACE_STATIC_TARGET = "//mace/libmace:libmace_static" LIBMACE_STATIC_TARGET = "//mace/libmace:libmace_static"
LIBMACE_STATIC_PATH = "bazel-genfiles/mace/libmace/libmace.a" LIBMACE_STATIC_PATH = "bazel-genfiles/mace/libmace/libmace.a"
MODEL_LIB_TARGET = "//mace/codegen:generated_models" 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" QUANTIZE_STAT_TARGET = "//mace/tools/quantization:quantize_stat"
BM_MODEL_STATIC_NAME = "benchmark_model_static" BM_MODEL_STATIC_NAME = "benchmark_model_static"
BM_MODEL_DYNAMIC_NAME = "benchmark_model_dynamic" BM_MODEL_DYNAMIC_NAME = "benchmark_model_dynamic"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册