From 7819bebf03cd51d905fd231f085016bbb65e2629 Mon Sep 17 00:00:00 2001 From: Liangliang He Date: Sun, 27 May 2018 23:52:23 +0800 Subject: [PATCH] refactor third_party --- README.md | 2 +- WORKSPACE | 10 +++++----- mace/benchmark/BUILD | 1 - mace/codegen/BUILD | 4 ---- mace/core/BUILD | 10 +++++++++- mace/core/runtime/hexagon/hexagon_controller.h | 2 +- mace/core/runtime/hexagon/hexagon_nn_ops.h | 4 ++-- mace/python/tools/BUILD | 2 +- mace/python/tools/converter_tool/caffe_converter.py | 3 ++- mace/utils/tuner.h | 2 +- {mace/third_party => third_party}/caffe/BUILD | 0 {mace/third_party => third_party}/caffe/Dockerfile | 0 {mace/third_party => third_party}/caffe/LICENSE | 0 {mace/third_party => third_party}/caffe/caffe.proto | 0 .../third_party => third_party}/gflags/COPYING.txt | 0 .../third_party => third_party}/googletest/LICENSE | 0 .../googletest/googletest.BUILD | 0 {mace/third_party => third_party}/half/LICENSE.txt | 0 {mace/third_party => third_party}/half/half.BUILD | 0 {mace/third_party => third_party}/nnlib/BUILD | 0 .../third_party => third_party}/nnlib/hexagon_nn.h | 6 +++--- .../nnlib/libhexagon_controller.so | Bin {mace/third_party => third_party}/nnlib/license.txt | 0 {mace/third_party => third_party}/nnlib/ops.h | 0 .../opencl-clhpp/LICENSE.txt | 0 .../opencl-clhpp/opencl-clhpp.BUILD | 0 .../opencl-headers/LICENSE | 0 .../opencl-headers/opencl-headers.BUILD | 0 {mace/third_party => third_party}/six/LICENSE | 0 {mace/third_party => third_party}/six/six.BUILD | 0 tools/sh_commands.py | 8 ++++---- 31 files changed, 29 insertions(+), 25 deletions(-) rename {mace/third_party => third_party}/caffe/BUILD (100%) rename {mace/third_party => third_party}/caffe/Dockerfile (100%) rename {mace/third_party => third_party}/caffe/LICENSE (100%) rename {mace/third_party => third_party}/caffe/caffe.proto (100%) rename {mace/third_party => third_party}/gflags/COPYING.txt (100%) rename {mace/third_party => third_party}/googletest/LICENSE (100%) rename {mace/third_party => third_party}/googletest/googletest.BUILD (100%) rename {mace/third_party => third_party}/half/LICENSE.txt (100%) rename {mace/third_party => third_party}/half/half.BUILD (100%) rename {mace/third_party => third_party}/nnlib/BUILD (100%) rename {mace/third_party => third_party}/nnlib/hexagon_nn.h (98%) rename {mace/third_party => third_party}/nnlib/libhexagon_controller.so (100%) rename {mace/third_party => third_party}/nnlib/license.txt (100%) rename {mace/third_party => third_party}/nnlib/ops.h (100%) rename {mace/third_party => third_party}/opencl-clhpp/LICENSE.txt (100%) rename {mace/third_party => third_party}/opencl-clhpp/opencl-clhpp.BUILD (100%) rename {mace/third_party => third_party}/opencl-headers/LICENSE (100%) rename {mace/third_party => third_party}/opencl-headers/opencl-headers.BUILD (100%) rename {mace/third_party => third_party}/six/LICENSE (100%) rename {mace/third_party => third_party}/six/six.BUILD (100%) diff --git a/README.md b/README.md index 29baa67b..7b37dcf0 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ please refer to [the contribution guide](docs/development/contributing.md). ## Acknowledgement MiAI Compute Engine depends on several open source projects located in -[third_party](mace/third_party) directory. Particularly, we learned a lot from +[third_party](third_party) directory. Particularly, we learned a lot from the following projects during the development: * [Qualcomm Hexagon NN Offload Framework](https://source.codeaurora.org/quic/hexagon_nn/nnlib): the Hexagon DSP runtime depends on this library. diff --git a/WORKSPACE b/WORKSPACE index be72e7d2..9b620936 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,7 +15,7 @@ http_archive( new_http_archive( name = "gtest", - build_file = "mace/third_party/googletest/googletest.BUILD", + build_file = "third_party/googletest/googletest.BUILD", sha256 = "f3ed3b58511efd272eb074a3a6d6fb79d7c2e6a0e374323d1e6bcbcc1ef141bf", strip_prefix = "googletest-release-1.8.0", urls = [ @@ -26,7 +26,7 @@ new_http_archive( new_http_archive( name = "opencl_headers", - build_file = "mace/third_party/opencl-headers/opencl-headers.BUILD", + build_file = "third_party/opencl-headers/opencl-headers.BUILD", sha256 = "5dc7087680853b5c825360fc04ca26534f4b9f22ac114c4d3a306bfbec3cd0f2", strip_prefix = "OpenCL-Headers-master", urls = [ @@ -37,7 +37,7 @@ new_http_archive( new_http_archive( name = "opencl_clhpp", - build_file = "mace/third_party/opencl-clhpp/opencl-clhpp.BUILD", + build_file = "third_party/opencl-clhpp/opencl-clhpp.BUILD", sha256 = "dab6f1834ec6e3843438cc0f97d63817902aadd04566418c1fcc7fb78987d4e7", strip_prefix = "OpenCL-CLHPP-4c6f7d56271727e37fb19a9b47649dd175df2b12", urls = [ @@ -48,7 +48,7 @@ new_http_archive( new_http_archive( name = "half", - build_file = "mace/third_party/half/half.BUILD", + build_file = "third_party/half/half.BUILD", sha256 = "0f514a1e877932b21dc5edc26a148ddc700b6af2facfed4c030ca72f74d0219e", strip_prefix = "half-code-356-trunk", urls = [ @@ -59,7 +59,7 @@ new_http_archive( new_http_archive( name = "six_archive", - build_file = "mace/third_party/six/six.BUILD", + build_file = "third_party/six/six.BUILD", sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", strip_prefix = "six-1.10.0", urls = [ diff --git a/mace/benchmark/BUILD b/mace/benchmark/BUILD index 4bbb48e0..3a304b24 100644 --- a/mace/benchmark/BUILD +++ b/mace/benchmark/BUILD @@ -15,7 +15,6 @@ cc_library( name = "statistics", srcs = ["statistics.cc"], hdrs = ["statistics.h"], - linkstatic = 1, copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], deps = [ "//mace/kernels", diff --git a/mace/codegen/BUILD b/mace/codegen/BUILD index 16f09ac6..a38f3295 100644 --- a/mace/codegen/BUILD +++ b/mace/codegen/BUILD @@ -9,7 +9,6 @@ cc_library( name = "generated_models", srcs = glob(["models/*/*.cc"]), hdrs = glob(["models/*/*.h"]), - linkstatic = 1, copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], deps = [ "//mace/core", @@ -21,21 +20,18 @@ cc_library( name = "generated_opencl", srcs = glob(["opencl/*.cc"]), copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], - linkstatic = 1, ) cc_library( name = "generated_tuning_params", srcs = ["tuning/tuning_params.cc"], copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], - linkstatic = 1, ) cc_library( name = "generated_version", srcs = ["version/version.cc"], copts = ["-Werror", "-Wextra", "-Wno-missing-field-initializers"], - linkstatic = 1, ) cc_library( diff --git a/mace/core/BUILD b/mace/core/BUILD index 9917dfe3..01b666ea 100644 --- a/mace/core/BUILD +++ b/mace/core/BUILD @@ -75,7 +75,7 @@ cc_library( ]) + if_not_production_mode([ "//mace/utils:utils_dev", ]) + if_hexagon_enabled([ - "//mace/third_party/nnlib:libhexagon", + "//third_party/nnlib:libhexagon", ]), ) @@ -109,3 +109,11 @@ cc_library( ], alwayslink = 1, ) + +cc_binary( + name = "libmace.so", + linkshared = 1, + deps = [ + "//mace/core", + ], +) diff --git a/mace/core/runtime/hexagon/hexagon_controller.h b/mace/core/runtime/hexagon/hexagon_controller.h index 07b7a453..afe4b727 100644 --- a/mace/core/runtime/hexagon/hexagon_controller.h +++ b/mace/core/runtime/hexagon/hexagon_controller.h @@ -15,7 +15,7 @@ #ifndef MACE_CORE_RUNTIME_HEXAGON_HEXAGON_CONTROLLER_H_ #define MACE_CORE_RUNTIME_HEXAGON_HEXAGON_CONTROLLER_H_ -#include "mace/third_party/nnlib/hexagon_nn.h" +#include "third_party/nnlib/hexagon_nn.h" #ifdef __cplusplus extern "C" { diff --git a/mace/core/runtime/hexagon/hexagon_nn_ops.h b/mace/core/runtime/hexagon/hexagon_nn_ops.h index d7d97cb0..deaba665 100644 --- a/mace/core/runtime/hexagon/hexagon_nn_ops.h +++ b/mace/core/runtime/hexagon/hexagon_nn_ops.h @@ -27,7 +27,7 @@ namespace mace { typedef enum op_type_enum { #define DEF_OP(NAME, ...) OP_##NAME, -#include "mace/third_party/nnlib/ops.h" // NOLINT(build/include) +#include "third_party/nnlib/ops.h" // NOLINT(build/include) NN_OPS_MAX #undef DEF_OP @@ -38,7 +38,7 @@ class OpMap { void Init() { #define DEF_OP(NAME) op_map_[#NAME] = OP_##NAME; -#include "mace/third_party/nnlib/ops.h" // NOLINT(build/include) +#include "third_party/nnlib/ops.h" // NOLINT(build/include) #undef DEF_OP } diff --git a/mace/python/tools/BUILD b/mace/python/tools/BUILD index b466ac72..8230044b 100644 --- a/mace/python/tools/BUILD +++ b/mace/python/tools/BUILD @@ -15,7 +15,7 @@ py_library( deps = [ ":memory_optimizer", "//mace/proto:mace_py", - "//mace/third_party/caffe:caffe_py", + "//third_party/caffe:caffe_py", ], ) diff --git a/mace/python/tools/converter_tool/caffe_converter.py b/mace/python/tools/converter_tool/caffe_converter.py index 25637df5..9e7c4d31 100644 --- a/mace/python/tools/converter_tool/caffe_converter.py +++ b/mace/python/tools/converter_tool/caffe_converter.py @@ -18,7 +18,6 @@ import numpy as np import google.protobuf.text_format from mace.proto import mace_pb2 -from mace.third_party.caffe import caffe_pb2 from mace.python.tools.converter_tool import base_converter from mace.python.tools.converter_tool import shape_inference from mace.python.tools.converter_tool.base_converter import PoolingType @@ -31,6 +30,8 @@ from mace.python.tools.converter_tool.base_converter import MaceKeyword from mace.python.tools.converter_tool.base_converter import ConverterUtil from mace.python.tools.convert_util import mace_check +from third_party.caffe import caffe_pb2 + caffe_group_str = 'group' caffe_kernel_h_str = 'kernel_h' caffe_kernel_w_str = 'kernel_w' diff --git a/mace/utils/tuner.h b/mace/utils/tuner.h index b6e92489..21522587 100644 --- a/mace/utils/tuner.h +++ b/mace/utils/tuner.h @@ -140,7 +140,7 @@ class Tuner { int num_runs, double *time_us, std::vector *tuning_result) { - RetType res; + RetType res = 0; int iter = 0; int64_t total_time_us = 0; for (iter = 0; iter < num_runs; ++iter) { diff --git a/mace/third_party/caffe/BUILD b/third_party/caffe/BUILD similarity index 100% rename from mace/third_party/caffe/BUILD rename to third_party/caffe/BUILD diff --git a/mace/third_party/caffe/Dockerfile b/third_party/caffe/Dockerfile similarity index 100% rename from mace/third_party/caffe/Dockerfile rename to third_party/caffe/Dockerfile diff --git a/mace/third_party/caffe/LICENSE b/third_party/caffe/LICENSE similarity index 100% rename from mace/third_party/caffe/LICENSE rename to third_party/caffe/LICENSE diff --git a/mace/third_party/caffe/caffe.proto b/third_party/caffe/caffe.proto similarity index 100% rename from mace/third_party/caffe/caffe.proto rename to third_party/caffe/caffe.proto diff --git a/mace/third_party/gflags/COPYING.txt b/third_party/gflags/COPYING.txt similarity index 100% rename from mace/third_party/gflags/COPYING.txt rename to third_party/gflags/COPYING.txt diff --git a/mace/third_party/googletest/LICENSE b/third_party/googletest/LICENSE similarity index 100% rename from mace/third_party/googletest/LICENSE rename to third_party/googletest/LICENSE diff --git a/mace/third_party/googletest/googletest.BUILD b/third_party/googletest/googletest.BUILD similarity index 100% rename from mace/third_party/googletest/googletest.BUILD rename to third_party/googletest/googletest.BUILD diff --git a/mace/third_party/half/LICENSE.txt b/third_party/half/LICENSE.txt similarity index 100% rename from mace/third_party/half/LICENSE.txt rename to third_party/half/LICENSE.txt diff --git a/mace/third_party/half/half.BUILD b/third_party/half/half.BUILD similarity index 100% rename from mace/third_party/half/half.BUILD rename to third_party/half/half.BUILD diff --git a/mace/third_party/nnlib/BUILD b/third_party/nnlib/BUILD similarity index 100% rename from mace/third_party/nnlib/BUILD rename to third_party/nnlib/BUILD diff --git a/mace/third_party/nnlib/hexagon_nn.h b/third_party/nnlib/hexagon_nn.h similarity index 98% rename from mace/third_party/nnlib/hexagon_nn.h rename to third_party/nnlib/hexagon_nn.h index e23915bc..82308003 100644 --- a/mace/third_party/nnlib/hexagon_nn.h +++ b/third_party/nnlib/hexagon_nn.h @@ -33,8 +33,8 @@ * */ -#ifndef MACE_THIRD_PARTY_NNLIB_HEXAGON_NN_H_ -#define MACE_THIRD_PARTY_NNLIB_HEXAGON_NN_H_ +#ifndef THIRD_PARTY_NNLIB_HEXAGON_NN_H_ +#define THIRD_PARTY_NNLIB_HEXAGON_NN_H_ #ifndef __QAIC_HEADER #define __QAIC_HEADER(ff) ff #endif // __QAIC_HEADER @@ -221,4 +221,4 @@ __QAIC_HEADER_EXPORT int __QAIC_HEADER(hexagon_nn_execute_new)( #ifdef __cplusplus } #endif -#endif // MACE_THIRD_PARTY_NNLIB_HEXAGON_NN_H_ +#endif // THIRD_PARTY_NNLIB_HEXAGON_NN_H_ diff --git a/mace/third_party/nnlib/libhexagon_controller.so b/third_party/nnlib/libhexagon_controller.so similarity index 100% rename from mace/third_party/nnlib/libhexagon_controller.so rename to third_party/nnlib/libhexagon_controller.so diff --git a/mace/third_party/nnlib/license.txt b/third_party/nnlib/license.txt similarity index 100% rename from mace/third_party/nnlib/license.txt rename to third_party/nnlib/license.txt diff --git a/mace/third_party/nnlib/ops.h b/third_party/nnlib/ops.h similarity index 100% rename from mace/third_party/nnlib/ops.h rename to third_party/nnlib/ops.h diff --git a/mace/third_party/opencl-clhpp/LICENSE.txt b/third_party/opencl-clhpp/LICENSE.txt similarity index 100% rename from mace/third_party/opencl-clhpp/LICENSE.txt rename to third_party/opencl-clhpp/LICENSE.txt diff --git a/mace/third_party/opencl-clhpp/opencl-clhpp.BUILD b/third_party/opencl-clhpp/opencl-clhpp.BUILD similarity index 100% rename from mace/third_party/opencl-clhpp/opencl-clhpp.BUILD rename to third_party/opencl-clhpp/opencl-clhpp.BUILD diff --git a/mace/third_party/opencl-headers/LICENSE b/third_party/opencl-headers/LICENSE similarity index 100% rename from mace/third_party/opencl-headers/LICENSE rename to third_party/opencl-headers/LICENSE diff --git a/mace/third_party/opencl-headers/opencl-headers.BUILD b/third_party/opencl-headers/opencl-headers.BUILD similarity index 100% rename from mace/third_party/opencl-headers/opencl-headers.BUILD rename to third_party/opencl-headers/opencl-headers.BUILD diff --git a/mace/third_party/six/LICENSE b/third_party/six/LICENSE similarity index 100% rename from mace/third_party/six/LICENSE rename to third_party/six/LICENSE diff --git a/mace/third_party/six/six.BUILD b/third_party/six/six.BUILD similarity index 100% rename from mace/third_party/six/six.BUILD rename to third_party/six/six.BUILD diff --git a/tools/sh_commands.py b/tools/sh_commands.py index f3e382bd..0e522e95 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -657,7 +657,7 @@ def tuning_run(abi, if not embed_model_data: adb_push("%s/%s.data" % (model_output_dir, model_tag), phone_data_dir, serialno) - adb_push("mace/third_party/nnlib/libhexagon_controller.so", + adb_push("nnlib/libhexagon_controller.so", phone_data_dir, serialno) if mace_model_dir: @@ -772,7 +772,7 @@ def validate_model(abi, if not docker_image_id: print("Build caffe docker") sh.docker("build", "-t", image_name, - "mace/third_party/caffe") + "third_party/caffe") container_id = sh.docker("ps", "-qa", "-f", "name=%s" % container_name) @@ -866,7 +866,7 @@ def merge_libs(target_soc, project_output_dir = "%s/%s" % (libmace_output_dir, project_name) model_header_dir = "%s/include/mace/public" % project_output_dir model_data_dir = "%s/data" % project_output_dir - hexagon_lib_file = "mace/third_party/nnlib/libhexagon_controller.so" + hexagon_lib_file = "third_party/nnlib/libhexagon_controller.so" model_bin_dir = "%s/%s/" % (project_output_dir, abi) if not os.path.exists(model_bin_dir): @@ -1197,7 +1197,7 @@ def build_run_throughput_test(abi, adb_push("codegen/models/%s/%s.data" % dsp_model_tag, phone_data_dir, serialno) - adb_push("mace/third_party/nnlib/libhexagon_controller.so", + adb_push("third_party/nnlib/libhexagon_controller.so", phone_data_dir, serialno) -- GitLab