From a25bd49919a9793d69bfea9d3af9c5d5493eb144 Mon Sep 17 00:00:00 2001 From: Liangliang He Date: Thu, 4 Jan 2018 21:04:44 +0800 Subject: [PATCH] Fix generated lib and hexagon lib dependency issue --- mace/BUILD | 18 +++- mace/codegen/BUILD | 34 ++----- mace/core/BUILD | 89 ++++++++++++------- mace/core/public/mace.h | 22 +++++ mace/core/public/version.h | 26 ------ ...ource_linkage.cc => opencl_development.cc} | 13 ++- ...binary_linkage.cc => opencl_production.cc} | 0 mace/examples/BUILD | 13 ++- mace/examples/mace_run.cc | 1 - mace/kernels/BUILD | 21 +++-- mace/mace.bzl | 24 +++-- mace/ops/BUILD | 7 +- mace/tools/benchmark/BUILD | 2 - mace/tools/git/gen_version_source.sh | 12 ++- mace/utils/BUILD | 21 ++--- tools/bazel-adb-run.sh | 18 ++-- tools/validate_gcn.sh | 25 +++--- tools/validate_gcn_dsp.sh | 6 +- tools/validate_icnet.sh | 0 19 files changed, 192 insertions(+), 160 deletions(-) delete mode 100644 mace/core/public/version.h rename mace/core/runtime/opencl/{opencl_source_linkage.cc => opencl_development.cc} (89%) rename mace/core/runtime/opencl/{opencl_binary_linkage.cc => opencl_production.cc} (100%) mode change 100644 => 100755 tools/validate_gcn.sh mode change 100644 => 100755 tools/validate_gcn_dsp.sh mode change 100644 => 100755 tools/validate_icnet.sh diff --git a/mace/BUILD b/mace/BUILD index 65eb1e8d..784be7c5 100644 --- a/mace/BUILD +++ b/mace/BUILD @@ -33,7 +33,15 @@ config_setting( ) config_setting( - name = "enable_neon", + name = "production_mode", + define_values = { + "production": "true", + }, + visibility = ["//visibility:public"], +) + +config_setting( + name = "neon_enabled", define_values = { "neon": "true", }, @@ -41,9 +49,13 @@ config_setting( ) config_setting( - name = "embed_binary_program", + name = "hexagon_enabled", define_values = { - "embed_binary_program": "true", + "hexagon": "true", + }, + values = { + "crosstool_top": "//external:android/crosstool", + "cpu": "armeabi-v7a", }, visibility = ["//visibility:public"], ) diff --git a/mace/codegen/BUILD b/mace/codegen/BUILD index fbb351d5..fcb0b509 100644 --- a/mace/codegen/BUILD +++ b/mace/codegen/BUILD @@ -5,52 +5,36 @@ package( default_visibility = ["//visibility:public"], ) -load("//mace:mace.bzl", "if_embed_binary_program", "if_use_source_program") - cc_library( - name = "generated_models_lib", + name = "generated_models", srcs = glob(["models/*/*.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkstatic = 1, deps = [ "//mace/core", "//mace/ops", - ] + if_embed_binary_program(["//mace/core:opencl_binary_linkage"]) + - if_use_source_program(["//mace/core:opencl_source_linkage"]) + [ - "//mace/codegen:version_lib", - "//mace/codegen:generated_opencl_source_lib", - "//mace/codegen:generated_opencl_compiled_lib", - "//mace/codegen:generated_tuning_lib", ], ) cc_library( - name = "generated_opencl_source_lib", - srcs = glob(["opencl/opencl_encrypt_program.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], + name = "generated_opencl_dev", + srcs = ["opencl/opencl_encrypt_program.cc"], linkstatic = 1, ) cc_library( - name = "generated_opencl_compiled_lib", - srcs = glob(["opencl/opencl_compiled_program.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], + name = "generated_opencl_prod", + srcs = ["opencl/opencl_compiled_program.cc"], linkstatic = 1, ) cc_library( - name = "generated_tuning_lib", - srcs = glob(["tuning/*.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], + name = "generated_tuning_params", + srcs = ["tuning/tuning_params.cc"], linkstatic = 1, ) cc_library( - name = "version_lib", - srcs = glob(["version/*.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], + name = "generated_version", + srcs = ["version/version.cc"], linkstatic = 1, - deps = [ - "//mace/core", - ] ) diff --git a/mace/core/BUILD b/mace/core/BUILD index c7672e59..237b9cce 100644 --- a/mace/core/BUILD +++ b/mace/core/BUILD @@ -7,25 +7,34 @@ package( licenses(["notice"]) # Apache 2.0 -load("//mace:mace.bzl", "if_android", "if_android_armv7", "if_android_arm64", - "if_profiling_enabled") +load( + "//mace:mace.bzl", + "if_android", + "if_profiling_enabled", + "if_hexagon_enabled", + "if_not_hexagon_enabled", + "if_production_mode", + "if_not_production_mode", +) cc_library( name = "core", - srcs = glob([ - "*.cc", - "runtime/opencl/*.cc", - "runtime/hexagon/*.cc", - ], - exclude = [ - "runtime/opencl/opencl_binary_linkage.cc", - "runtime/opencl/opencl_source_linkage.cc", - "*_test.cc", + srcs = glob( + [ + "*.cc", + "runtime/opencl/*.cc", + "runtime/hexagon/*.cc", + ], + exclude = [ + "runtime/opencl/opencl_prod.cc", + "runtime/opencl/opencl_dev.cc", + "*_test.cc", + "runtime/hexagon/hexagon_controller_dummy.cc", + ], + ) + if_not_hexagon_enabled([ "runtime/hexagon/hexagon_controller_dummy.cc", - ]) + if_android_armv7([ + ]) + if_hexagon_enabled([ "runtime/hexagon/libhexagon_controller.so", - ]) + if_android_arm64([ - "runtime/hexagon/hexagon_controller_dummy.cc", ]), hdrs = glob([ "*.h", @@ -34,13 +43,31 @@ cc_library( "runtime/opencl/*.h", "runtime/hexagon/*.h", ]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"] + - if_profiling_enabled(["-DMACE_OPENCL_PROFILING"]), - linkopts = if_android(["-pie", "-ldl"]), + copts = if_profiling_enabled(["-DMACE_OPENCL_PROFILING"]) + if_hexagon_enabled(["-DMACE_HEXAGON_ENABLED"]), + linkopts = if_android([ + "-pie", + "-ldl", + ]), deps = [ - "//mace/utils:utils_hdrs", + ":opencl_headers", "//mace/utils:logging", "//mace/utils:tuner", + "//mace/utils:utils_hdrs", + "//mace/codegen:generated_version", + ] + if_production_mode([ + "//mace/core:opencl_prod", + ]) + if_not_production_mode([ + "//mace/core:opencl_dev", + ]), +) + +cc_library( + name = "opencl_headers", + hdrs = glob([ + "runtime/opencl/cl2.hpp", + "runtime/opencl/*.h", + ]), + deps = [ "@opencl_headers//:opencl20_headers", ], ) @@ -48,37 +75,37 @@ cc_library( cc_library( name = "test_benchmark_main", testonly = 1, - hdrs = [ - "testing/test_benchmark.h", - ], srcs = [ "testing/test_benchmark.cc", "testing/test_benchmark_main.cc", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], - alwayslink = 1, + hdrs = [ + "testing/test_benchmark.h", + ], deps = [ ":core", "//mace/utils:utils_hdrs", ], + alwayslink = 1, ) cc_library( - name = "opencl_source_linkage", - srcs = ["runtime/opencl/opencl_source_linkage.cc"], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], + name = "opencl_dev", + srcs = ["runtime/opencl/opencl_development.cc"], linkstatic = 1, deps = [ - ":core", + ":opencl_headers", + "//mace/codegen:generated_opencl_dev", ], ) cc_library( - name = "opencl_binary_linkage", - srcs = ["runtime/opencl/opencl_binary_linkage.cc"], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], + name = "opencl_prod", + srcs = ["runtime/opencl/opencl_production.cc"], linkstatic = 1, deps = [ - ":core", + ":opencl_headers", + "//mace/codegen:generated_opencl_prod", + "//mace/codegen:generated_tuning_params", ], ) diff --git a/mace/core/public/mace.h b/mace/core/public/mace.h index fb0cd06d..f68b60fd 100644 --- a/mace/core/public/mace.h +++ b/mace/core/public/mace.h @@ -11,6 +11,28 @@ namespace mace { +#define MACE_MAJOR_VERSION 0 +#define MACE_MINOR_VERSION 1 +#define MACE_PATCH_VERSION 0 + +// MACE_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1", +// "-beta", "-rc", "-rc.1") +#define MACE_VERSION_SUFFIX "" + +#define MACE_STR_HELPER(x) #x +#define MACE_STR(x) MACE_STR_HELPER(x) + +// e.g. "0.5.0" or "0.6.0-alpha". +#define MACE_VERSION_STRING \ + (MACE_STR(MACE_MAJOR_VERSION) "." MACE_STR(MACE_MINOR_VERSION) "." MACE_STR( \ + MACE_PATCH_VERSION) MACE_VERSION_SUFFIX) + +inline const char *MaceVersion() { + return MACE_VERSION_STRING; +} + +extern const char *MaceGitVersion(); + enum NetMode { INIT = 0, NORMAL = 1 diff --git a/mace/core/public/version.h b/mace/core/public/version.h deleted file mode 100644 index ee824280..00000000 --- a/mace/core/public/version.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) 2017 XiaoMi All rights reserved. -// - -#ifndef MACE_CORE_PUBLIC_VERSION_H_ -#define MACE_CORE_PUBLIC_VERSION_H_ - -#define MACE_MAJOR_VERSION 0 -#define MACE_MINOR_VERSION 1 -#define MACE_PATCH_VERSION 0 - -// MACE_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1", -// "-beta", "-rc", "-rc.1") -#define MACE_VERSION_SUFFIX "" - -#define MACE_STR_HELPER(x) #x -#define MACE_STR(x) MACE_STR_HELPER(x) - -// e.g. "0.5.0" or "0.6.0-alpha". -#define MACE_VERSION_STRING \ - (MACE_STR(MACE_MAJOR_VERSION) "." MACE_STR(MACE_MINOR_VERSION) "." MACE_STR( \ - MACE_PATCH_VERSION) MACE_VERSION_SUFFIX) - -extern const char *MaceVersion(); -extern const char *MaceGitVersion(); -#endif // MACE_CORE_PUBLIC_VERSION_H_ diff --git a/mace/core/runtime/opencl/opencl_source_linkage.cc b/mace/core/runtime/opencl/opencl_development.cc similarity index 89% rename from mace/core/runtime/opencl/opencl_source_linkage.cc rename to mace/core/runtime/opencl/opencl_development.cc index 9b2fde0e..a13bb9a3 100644 --- a/mace/core/runtime/opencl/opencl_source_linkage.cc +++ b/mace/core/runtime/opencl/opencl_development.cc @@ -49,18 +49,17 @@ bool GetTuningParams(const char *path, if (path != nullptr) { std::ifstream ifs(path, std::ios::binary | std::ios::in); if (ifs.is_open()) { - int32_t key_size = 0; - int32_t params_size = 0; - int32_t params_count = 0; - int64_t num_pramas = 0; - ifs.read(reinterpret_cast(&num_pramas), sizeof(num_pramas)); - while (num_pramas--) { + int64_t num_params = 0; + ifs.read(reinterpret_cast(&num_params), sizeof(num_params)); + while (num_params--) { + int32_t key_size = 0; ifs.read(reinterpret_cast(&key_size), sizeof(key_size)); std::string key(key_size, ' '); ifs.read(&key[0], key_size); + int32_t params_size = 0; ifs.read(reinterpret_cast(¶ms_size), sizeof(params_size)); - params_count = params_size / sizeof(unsigned int); + int32_t params_count = params_size / sizeof(unsigned int); std::vector params(params_count); for (int i = 0; i < params_count; ++i) { ifs.read(reinterpret_cast(¶ms[i]), sizeof(unsigned int)); diff --git a/mace/core/runtime/opencl/opencl_binary_linkage.cc b/mace/core/runtime/opencl/opencl_production.cc similarity index 100% rename from mace/core/runtime/opencl/opencl_binary_linkage.cc rename to mace/core/runtime/opencl/opencl_production.cc diff --git a/mace/examples/BUILD b/mace/examples/BUILD index afc3f982..09667cf4 100644 --- a/mace/examples/BUILD +++ b/mace/examples/BUILD @@ -1,13 +1,12 @@ # Examples -load("//mace:mace.bzl", "if_android", "if_enable_neon") +load("//mace:mace.bzl", "if_android", "if_neon_enabled") cc_binary( name = "helloworld", srcs = [ "helloworld.cc", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], - linkopts = if_enable_neon(["-fopenmp"]), + linkopts = if_neon_enabled(["-fopenmp"]), deps = [ "//mace/core", "//mace/ops", @@ -18,8 +17,7 @@ cc_test( name = "benchmark_example", testonly = 1, srcs = ["benchmark_example.cc"], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], - linkopts = if_enable_neon(["-fopenmp"]), + linkopts = if_neon_enabled(["-fopenmp"]), linkstatic = 1, deps = [ "//mace/core", @@ -30,11 +28,10 @@ cc_test( cc_binary( name = "mace_run", srcs = ["mace_run.cc"], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], - linkopts = if_enable_neon(["-fopenmp"]), + linkopts = if_neon_enabled(["-fopenmp"]), linkstatic = 1, deps = [ - "//mace/codegen:generated_models_lib", + "//mace/codegen:generated_models", "//mace/utils:command_line_flags", ], ) diff --git a/mace/examples/mace_run.cc b/mace/examples/mace_run.cc index 66cf8a7d..35c41dfd 100644 --- a/mace/examples/mace_run.cc +++ b/mace/examples/mace_run.cc @@ -23,7 +23,6 @@ #include "mace/utils/logging.h" #include "mace/core/public/mace.h" -#include "mace/core/public/version.h" using namespace std; using namespace mace; diff --git a/mace/kernels/BUILD b/mace/kernels/BUILD index 78d9ede5..a4646d90 100644 --- a/mace/kernels/BUILD +++ b/mace/kernels/BUILD @@ -7,22 +7,23 @@ package( licenses(["notice"]) # Apache 2.0 -load("//mace:mace.bzl", "if_android", "if_enable_neon") +load("//mace:mace.bzl", "if_android", "if_neon_enabled") cc_library( name = "kernels", - srcs = glob(["*.cc", "opencl/*.cc"]) + if_enable_neon(glob([ + srcs = glob([ + "*.cc", + "opencl/*.cc", + ]) + if_neon_enabled(glob([ "neon/*.cc", ])), - hdrs = glob(["*.h", "opencl/*.h"]) + if_enable_neon(glob([ + hdrs = glob([ + "*.h", + "opencl/*.h", + ]) + if_neon_enabled(glob([ "neon/*.h", ])), - copts = [ - "-std=c++11", - "-D_GLIBCXX_USE_C99_MATH_TR1", - "-Werror=return-type", - ] + - if_enable_neon(["-fopenmp"]), + copts = if_neon_enabled(["-fopenmp"]), linkopts = if_android(["-lm"]), deps = [ "//mace/core", @@ -34,7 +35,6 @@ cc_test( name = "kernel_test", testonly = 1, srcs = glob(["test/*.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkopts = if_android(["-pie"]), linkstatic = 1, deps = [ @@ -48,7 +48,6 @@ cc_test( name = "benchmark", testonly = 1, srcs = glob(["benchmark/*.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkstatic = 1, deps = [ ":kernels", diff --git a/mace/mace.bzl b/mace/mace.bzl index 6894c710..c4e69686 100644 --- a/mace/mace.bzl +++ b/mace/mace.bzl @@ -30,20 +30,32 @@ def if_profiling_enabled(a): "//conditions:default": [], }) -def if_embed_binary_program(a): +def if_production_mode(a): return select({ - "//mace:embed_binary_program": a, + "//mace:production_mode": a, "//conditions:default": [], }) -def if_use_source_program(a): +def if_not_production_mode(a): return select({ - "//mace:embed_binary_program": [], + "//mace:production_mode": [], "//conditions:default": a, }) -def if_enable_neon(a): +def if_neon_enabled(a): return select({ - "//mace:enable_neon": a, + "//mace:neon_enabled": a, "//conditions:default": [], }) + +def if_hexagon_enabled(a): + return select({ + "//mace:hexagon_enabled": a, + "//conditions:default": [], + }) + +def if_not_hexagon_enabled(a): + return select({ + "//mace:hexagon_enabled": [], + "//conditions:default": a, + }) diff --git a/mace/ops/BUILD b/mace/ops/BUILD index 890c46b9..442441e0 100644 --- a/mace/ops/BUILD +++ b/mace/ops/BUILD @@ -7,7 +7,7 @@ package( licenses(["notice"]) # Apache 2.0 -load("//mace:mace.bzl", "if_android", "if_enable_neon") +load("//mace:mace.bzl", "if_android", "if_neon_enabled") cc_library( name = "test", @@ -34,8 +34,7 @@ cc_library( ["*.h"], exclude = ["ops_test_util.h"], ), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"] + - if_enable_neon(["-DMACE_ENABLE_NEON"]), + copts = if_neon_enabled(["-DMACE_ENABLE_NEON"]), deps = [ "//mace/kernels", ], @@ -48,7 +47,6 @@ cc_test( srcs = glob( ["*_test.cc"], ), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkopts = ["-fopenmp"], linkstatic = 1, deps = [ @@ -62,7 +60,6 @@ cc_test( name = "ops_benchmark", testonly = 1, srcs = glob(["*_benchmark.cc"]), - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkopts = ["-fopenmp"], linkstatic = 1, deps = [ diff --git a/mace/tools/benchmark/BUILD b/mace/tools/benchmark/BUILD index 5e026997..5241146b 100644 --- a/mace/tools/benchmark/BUILD +++ b/mace/tools/benchmark/BUILD @@ -7,7 +7,6 @@ cc_library( name = "stat_summarizer", srcs = ["stat_summarizer.cc"], hdrs = ["stat_summarizer.h"], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkstatic = 1, deps = [ "//mace/core", @@ -19,7 +18,6 @@ cc_binary( srcs = [ "benchmark_model.cc", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkstatic = 1, deps = [ ":stat_summarizer", diff --git a/mace/tools/git/gen_version_source.sh b/mace/tools/git/gen_version_source.sh index 5c646eb9..6b17c56c 100644 --- a/mace/tools/git/gen_version_source.sh +++ b/mace/tools/git/gen_version_source.sh @@ -18,7 +18,13 @@ else fi cat < ${OUTPUT_FILENAME} -#include "mace/core/public/version.h" -const char *MaceVersion() { return MACE_VERSION_STRING; } -const char *MaceGitVersion() { return "${GIT_VERSION}"; } +// +// Copyright (c) 2017 XiaoMi All rights reserved. +// + +// This is a generated file, DO NOT EDIT + +namespace mace { + const char *MaceGitVersion() { return "${GIT_VERSION}"; } +} // namespace mace EOF diff --git a/mace/utils/BUILD b/mace/utils/BUILD index 2eb252ff..a9ba154d 100644 --- a/mace/utils/BUILD +++ b/mace/utils/BUILD @@ -17,7 +17,6 @@ cc_library( hdrs = [ "logging.h", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], linkopts = if_android([ "-llog", ]), @@ -31,7 +30,6 @@ cc_library( hdrs = [ "command_line_flags.h", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], deps = [ ":logging", ], @@ -40,13 +38,12 @@ cc_library( cc_library( name = "tuner", hdrs = [ - "tuner.h", "timer.h", + "tuner.h", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], deps = [ - ":utils_hdrs", ":logging", + ":utils_hdrs", ], ) @@ -56,8 +53,10 @@ cc_test( srcs = [ "tuner_test.cc", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], - linkopts = if_android(["-pie", "-lm"]), + linkopts = if_android([ + "-pie", + "-lm", + ]), linkstatic = 1, deps = [ ":tuner", @@ -69,19 +68,17 @@ cc_test( cc_library( name = "utils_hdrs", hdrs = [ - "utils.h", "env_time.h", + "utils.h", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], ) cc_library( name = "utils", deps = [ - ":utils_hdrs", - ":tuner", ":command_line_flags", ":logging", + ":tuner", + ":utils_hdrs", ], - copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1", "-Werror=return-type"], ) diff --git a/tools/bazel-adb-run.sh b/tools/bazel-adb-run.sh index e937524c..b3457c1a 100755 --- a/tools/bazel-adb-run.sh +++ b/tools/bazel-adb-run.sh @@ -6,7 +6,7 @@ if [ "$#" -lt 1 ]; then fi MACE_SOURCE_DIR=`/bin/pwd` -CL_CODEGEN_DIR=${MACE_SOURCE_DIR}/mace/codegen/opencl +CODEGEN_DIR=${MACE_SOURCE_DIR}/mace/codegen DEVICE_PATH=/data/local/tmp/mace DEVICE_CL_PATH=$DEVICE_PATH/cl/ BAZEL_TARGET=$1 @@ -24,25 +24,28 @@ STRIP="--strip always" VLOG_LEVEL=0 PROFILINE="--define profiling=true" -BRANCH=$(git symbolic-ref --short HEAD) -COMMIT_ID=$(git rev-parse --short HEAD) - echo "Step 1: Generate encrypted opencl source" python mace/python/tools/encrypt_opencl_codegen.py \ - --cl_kernel_dir=./mace/kernels/opencl/cl/ --output_path=${CL_CODEGEN_DIR}/opencl_encrypt_program.cc + --cl_kernel_dir=./mace/kernels/opencl/cl/ --output_path=${CODEGEN_DIR}/opencl/opencl_encrypt_program.cc + +echo "Step 2: Generate version source" +bash mace/tools/git/gen_version_source.sh ${CODEGEN_DIR}/version/version.cc -echo "Step 2: Build target" +echo "Step 3: Build target" bazel build -c opt $STRIP --verbose_failures $BAZEL_TARGET \ --crosstool_top=//external:android/crosstool \ --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ --cpu=$ANDROID_ABI \ + --copt="-std=c++11" \ + --copt="-D_GLIBCXX_USE_C99_MATH_TR1" \ + --copt="-Werror=return-type" \ --define neon=false if [ $? -ne 0 ]; then exit 1 fi -echo "Step 3: Run target" +echo "Step 4: Run target" du -hs $BAZEL_BIN_PATH/$BIN_NAME for device in `adb devices | grep "^[A-Za-z0-9]\+[[:space:]]\+device$"| cut -f1`; do @@ -50,6 +53,7 @@ for device in `adb devices | grep "^[A-Za-z0-9]\+[[:space:]]\+device$"| cut -f1` echo "Run on device: ${device}" adb -s ${device} shell "rm -rf $DEVICE_PATH" adb -s ${device} shell "mkdir -p $DEVICE_PATH" + adb -s ${device} shell "mkdir -p $DEVICE_PATH/cl" adb -s ${device} push $BAZEL_BIN_PATH/$BIN_NAME $DEVICE_PATH && \ adb -s ${device} shell "MACE_KERNEL_PATH=$DEVICE_CL_PATH MACE_CPP_MIN_VLOG_LEVEL=$VLOG_LEVEL $DEVICE_PATH/$BIN_NAME $@" done diff --git a/tools/validate_gcn.sh b/tools/validate_gcn.sh old mode 100644 new mode 100755 index 8b8d0be7..bb41cab8 --- a/tools/validate_gcn.sh +++ b/tools/validate_gcn.sh @@ -39,19 +39,22 @@ build_and_run() EMBED_OPENCL_BINARY_BUILD_FLAGS="--define embed_binary_program=true" fi - bazel build -c opt --strip always mace/examples:mace_run \ + bazel build --verbose_failures -c opt --strip always mace/examples:mace_run \ --crosstool_top=//external:android/crosstool \ --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ --cpu=arm64-v8a \ - $EMBED_OPENCL_BINARY_BUILD_FLAGS \ - --copt=-DMACE_MODEL_FUNCTION=Create${MODEL_TAG} + --copt="-std=c++11" \ + --copt="-D_GLIBCXX_USE_C99_MATH_TR1" \ + --copt="-Werror=return-type" \ + --copt="-DMACE_MODEL_FUNCTION=Create${MODEL_TAG}" \ + $EMBED_OPENCL_BINARY_BUILD_FLAGS || exit -1 - adb shell "mkdir -p ${PHONE_DATA_DIR}" + adb shell "mkdir -p ${PHONE_DATA_DIR}" || exit -1 if [ "$EMBED_OPENCL_BINARY" = false ]; then - adb shell "mkdir -p ${KERNEL_DIR}" + adb shell "mkdir -p ${KERNEL_DIR}" || exit -1 fi - adb push ${MODEL_DIR}/${INPUT_FILE_NAME} ${PHONE_DATA_DIR} - adb push bazel-bin/mace/examples/mace_run ${PHONE_DATA_DIR} + adb push ${MODEL_DIR}/${INPUT_FILE_NAME} ${PHONE_DATA_DIR} || exit -1 + adb push bazel-bin/mace/examples/mace_run ${PHONE_DATA_DIR} || exit -1 if [[ "${TUNING_OR_NOT}" != "0" && "$EMBED_OPENCL_BINARY" != true ]];then tuning_flag=1 @@ -71,17 +74,17 @@ build_and_run() --input_file=${PHONE_DATA_DIR}/${INPUT_FILE_NAME} \ --output_file=${PHONE_DATA_DIR}/${OUTPUT_FILE_NAME} \ --device=OPENCL \ - --round=$round + --round=$round || exit -1 } echo "Step 1: Generate input data" rm -rf ${MODEL_DIR}/${INPUT_FILE_NAME} python tools/validate.py --generate_data true \ --input_file=${MODEL_DIR}/${INPUT_FILE_NAME} \ - --input_shape="${IMAGE_SIZE},${IMAGE_SIZE},3" + --input_shape="${IMAGE_SIZE},${IMAGE_SIZE},3" || exit -1 echo "Step 2: Convert tf model to mace model and optimize memory" -bazel build //mace/python/tools:tf_converter +bazel build //mace/python/tools:tf_converter || exit -1 rm -rf ${MODEL_CODEGEN_DIR} mkdir -p ${MODEL_CODEGEN_DIR} bazel-bin/mace/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \ @@ -93,7 +96,7 @@ bazel-bin/mace/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \ --output_type=source \ --template=${MACE_SOURCE_DIR}/mace/python/tools/model.template \ --model_tag=${MODEL_TAG} \ - --confuse=False + --confuse=False || exit -1 echo "Step 3: Generate version source" rm -rf ${VERSION_SOURCE_PATH} diff --git a/tools/validate_gcn_dsp.sh b/tools/validate_gcn_dsp.sh old mode 100644 new mode 100755 index 9e3176f5..06d6ac71 --- a/tools/validate_gcn_dsp.sh +++ b/tools/validate_gcn_dsp.sh @@ -34,7 +34,9 @@ build_and_run() --crosstool_top=//external:android/crosstool \ --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ --cpu=armeabi-v7a \ - --copt=-DMACE_MODEL_FUNCTION=Create${MODEL_TAG} + --copt="-std=c++11" \ + --copt="-D_GLIBCXX_USE_C99_MATH_TR1" \ + --copt="-Werror=return-type" adb shell "mkdir -p ${PHONE_DATA_DIR}" adb push ${MODEL_DIR}/${INPUT_FILE_NAME} ${PHONE_DATA_DIR} @@ -92,4 +94,4 @@ python tools/validate.py --model_file ${TF_MODEL_FILE_PATH} \ --input_node ${TF_INPUT_NODE} \ --output_node ${TF_OUTPUT_NODE} \ --input_shape "${IMAGE_SIZE},${IMAGE_SIZE},3" \ - --output_shape "1,${IMAGE_SIZE},${IMAGE_SIZE},2" \ No newline at end of file + --output_shape "1,${IMAGE_SIZE},${IMAGE_SIZE},2" diff --git a/tools/validate_icnet.sh b/tools/validate_icnet.sh old mode 100644 new mode 100755 -- GitLab