diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a126054f23133a6753ec0d84e957c1c37b8521df..e49a7dc0cfec2f172044c2c01e840546aefa1e1f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ stages: - pycodestyle - docs - platform_compatible_tests + - build_libraries - ndk_versions_compatible_tests - ops_test - api_test @@ -72,6 +73,11 @@ platform_compatible_tests: script: - bazel build mace/core:core +build_libraries: + stage: build_libraries + script: + - bash tools/build-standalone-lib.sh + ndk_versions_compatible_tests: stage: ndk_versions_compatible_tests script: diff --git a/docs/installation/env_requirement.rst b/docs/installation/env_requirement.rst index c482712418b1e0afb92970ce0a55bb7226e82ed9..6946a524e22f3284f585f46f9e71fa9604f84176 100644 --- a/docs/installation/env_requirement.rst +++ b/docs/installation/env_requirement.rst @@ -30,6 +30,9 @@ Required dependencies * - sh - pip install -I sh==1.12.14 - 1.12.14 + * - Numpy + - pip install -I numpy==1.14.0 + - Required by model validation Optional dependencies --------------------- @@ -52,15 +55,12 @@ Optional dependencies * - Docker - `docker installation guide `__ - Required by docker mode for Caffe model - * - Numpy - - pip install -I numpy==1.14.0 - - Required by model validation * - Scipy - pip install -I scipy==1.0.0 - Required by model validation * - FileLock - pip install -I filelock==3.0.0 - - Required by Android run + - Required by run on Android .. note:: diff --git a/docs/user_guide/advanced_usage.rst b/docs/user_guide/advanced_usage.rst index 280fb09cbe391d4cc5fb25c2d5c47cb0901dbd36..b16091978f57c06837f63422e7cf56ca767bd847 100644 --- a/docs/user_guide/advanced_usage.rst +++ b/docs/user_guide/advanced_usage.rst @@ -160,6 +160,17 @@ There are two common advanced use cases:    ├── mobilenet-v1.a    └── mobilenet_v1.data + # model_graph_format: code + # model_data_format: code + + builds + ├── include + │   └── mace + │   └── public + │   ├── mace_engine_factory.h + │   └── mobilenet_v1.h + └── model +    └── mobilenet-v1.a * **3. Deployment** * Link `libmace.a` and `${library_name}.a` to your target. @@ -182,7 +193,7 @@ There are two common advanced use cases: // Create Engine from compiled code create_engine_status = CreateMaceEngineFromCode(model_name.c_str(), - nullptr, + model_data_file, // empty string if model_data_format is code input_names, output_names, device_type, diff --git a/mace/libmace/mace_runtime.cc b/mace/libmace/mace_runtime.cc index 04f0ccc7e3a141dddcd6113d7e7b25f31ae21df5..d070e5c6fc021e78d319469d177d08d6d52475bb 100644 --- a/mace/libmace/mace_runtime.cc +++ b/mace/libmace/mace_runtime.cc @@ -34,6 +34,7 @@ class FileStorageFactory::Impl { }; FileStorageFactory::Impl::Impl(const std::string &path): path_(path) {} + std::unique_ptr FileStorageFactory::Impl::CreateStorage( const std::string &name) { return std::move(std::unique_ptr( @@ -57,10 +58,13 @@ void SetKVStorageFactory(std::shared_ptr storage_factory) { kStorageFactory = storage_factory; } -#ifdef MACE_ENABLE_OPENCL // Set OpenCL Compiled Binary paths, just call once. (Not thread-safe) void SetOpenCLBinaryPaths(const std::vector &paths) { +#ifdef MACE_ENABLE_OPENCL OpenCLRuntime::ConfigureOpenCLBinaryPath(paths); +#else + MACE_UNUSED(paths); +#endif // MACE_ENABLE_OPENCL } extern std::string kOpenCLParameterPath; @@ -70,11 +74,15 @@ void SetOpenCLParameterPath(const std::string &path) { } void SetGPUHints(GPUPerfHint gpu_perf_hint, GPUPriorityHint gpu_priority_hint) { +#ifdef MACE_ENABLE_OPENCL VLOG(1) << "Set GPU configurations, gpu_perf_hint: " << gpu_perf_hint << ", gpu_priority_hint: " << gpu_priority_hint; OpenCLRuntime::Configure(gpu_perf_hint, gpu_priority_hint); -} +#else + MACE_UNUSED(gpu_perf_hint); + MACE_UNUSED(gpu_priority_hint); #endif // MACE_ENABLE_OPENCL +} MaceStatus SetOpenMPThreadPolicy(int num_threads_hint, CPUAffinityPolicy policy) { diff --git a/mace/python/tools/encrypt_opencl_codegen.py b/mace/python/tools/encrypt_opencl_codegen.py index cfb9c91e1c7f3faf9bcc26e5a17be22796f81f4f..957c8a51ee197e7139ab720ca51923cc7827a202 100644 --- a/mace/python/tools/encrypt_opencl_codegen.py +++ b/mace/python/tools/encrypt_opencl_codegen.py @@ -87,6 +87,8 @@ def encrypt_opencl_codegen(cl_kernel_dir, output_path): with open(output_path, "w") as w_file: w_file.write(cpp_cl_encrypted_kernel) + print('Generate OpenCL kernel done.') + def parse_args(): """Parses command line arguments.""" diff --git a/mace/tools/git/gen_version_source.sh b/mace/tools/git/gen_version_source.sh index 10309b1d1ee4df05308ef074afb3676b1789d98e..e29931a4978b88646eb65293e601cbe65eea931b 100644 --- a/mace/tools/git/gen_version_source.sh +++ b/mace/tools/git/gen_version_source.sh @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -MACE_SOURCE_DIR=$(dirname $0) +MACE_SOURCE_DIR=$(dirname $(dirname $(dirname $(dirname $0)))) OUTPUT_FILENAME=$1 if [[ -z "${OUTPUT_FILENAME}}" ]]; then @@ -28,16 +28,16 @@ fi mkdir -p $OUTPUT_DIR -pushd $MACE_SOURCE_DIR - DATE_STR=$(date +%Y%m%d) -GIT_VERSION=$(git describe --long --tags) +GIT_VERSION=$(git --git-dir=${MACE_SOURCE_DIR}/.git --work-tree=${MACE_SOURCE_DIR} describe --long --tags) if [[ $? != 0 ]]; then GIT_VERSION=unknown-${DATE_STR} else GIT_VERSION=${GIT_VERSION}-${DATE_STR} fi +echo $GIT_VERSION + cat < ${OUTPUT_FILENAME} // Copyright 2018 Xiaomi, Inc. All rights reserved. // @@ -61,4 +61,3 @@ const char *MaceVersion() { return "MACEVER-${GIT_VERSION}" + 8; } } // namespace mace EOF -popd diff --git a/repository/git/git_configure.bzl b/repository/git/git_configure.bzl index b46c74e557fdc061fb3e71216d9938c9eab5b81d..9ef9838f0721af41c6ed765648e716636a1f45ec 100644 --- a/repository/git/git_configure.bzl +++ b/repository/git/git_configure.bzl @@ -9,6 +9,9 @@ def _git_version_conf_impl(repository_ctx): generated_files_path = repository_ctx.path("gen") + unused_var = repository_ctx.path(Label("//:.git/HEAD")) + unused_var = repository_ctx.path(Label("//:.git/refs/heads/master")) + repository_ctx.execute([ 'bash', '%s/mace/tools/git/gen_version_source.sh' % mace_root_path , '%s/version' % generated_files_path @@ -17,5 +20,4 @@ def _git_version_conf_impl(repository_ctx): git_version_repository = repository_rule( implementation = _git_version_conf_impl, - local=True, ) diff --git a/repository/opencl-kernel/opencl_kernel_configure.bzl b/repository/opencl-kernel/opencl_kernel_configure.bzl index a0c715c75eaf2478bd18a7b283915b704855029c..1e650b4f64c01a193f1bf1b209dd12ad8d6be211 100644 --- a/repository/opencl-kernel/opencl_kernel_configure.bzl +++ b/repository/opencl-kernel/opencl_kernel_configure.bzl @@ -5,6 +5,34 @@ def _opencl_encrypt_kernel_impl(repository_ctx): "BUILD", Label("//repository/opencl-kernel:BUILD.tpl")) + unused_var = repository_ctx.path(Label("//:.git/HEAD")) + unused_var = repository_ctx.path(Label("//:.git/refs/heads/master")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/activation.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/addn.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/batch_norm.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/bias_add.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/buffer_to_image.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/channel_shuffle.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/common.h")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/concat.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d_1x1.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d_3x3.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/deconv_2d.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/depth_to_space.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/depthwise_conv2d.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/eltwise.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/fully_connected.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/matmul.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/pad.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/pooling.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/reduce_mean.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/resize_bilinear.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/slice.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/softmax.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/space_to_batch.cl")) + unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/winograd_transform.cl")) + mace_root_path = str(repository_ctx.path(Label("@mace//:BUILD")))[:-len("BUILD")] generated_files_path = repository_ctx.path("gen") @@ -20,5 +48,4 @@ def _opencl_encrypt_kernel_impl(repository_ctx): encrypt_opencl_kernel_repository = repository_rule( implementation = _opencl_encrypt_kernel_impl, - local=True, ) diff --git a/tools/converter.py b/tools/converter.py index 36f513e0cb1cee61c719a1a8c79be940ef4f5446..eba4aa0455932e77b0f7d6fff9b4852fef57823e 100644 --- a/tools/converter.py +++ b/tools/converter.py @@ -13,7 +13,6 @@ # limitations under the License. import argparse -import filelock import glob import hashlib import os diff --git a/tools/sh_commands.py b/tools/sh_commands.py index 1968b37f13d3e077ec75a3e6d4bedf0f0c2edb72..b0adb2c5ae876d26bbfbd62c31cfc415ea92d6fd 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -13,7 +13,6 @@ # limitations under the License. import falcon_cli -import filelock import glob import logging import numpy as np @@ -69,10 +68,12 @@ def device_lock_path(serialno): def device_lock(serialno, timeout=3600): + import filelock return filelock.FileLock(device_lock_path(serialno), timeout=timeout) def is_device_locked(serialno): + import filelock try: with device_lock(serialno, timeout=0.000001): return False