提交 9698e6e7 编写于 作者: L Liangliang He

Merge branch 'remove_unneeded_so' into 'master'

remove unneeded dynamic library

See merge request !591
...@@ -123,9 +123,3 @@ android_ndk_repository( ...@@ -123,9 +123,3 @@ android_ndk_repository(
# Android 5.0 # Android 5.0
api_level = 21, api_level = 21,
) )
new_local_repository(
name = "libmace",
path = "./dynamic_lib/",
build_file = "./dynamic_lib/libmace.BUILD"
)
cc_library(
name = "libmace",
srcs = ["libmace.so"],
visibility = ["//visibility:public"],
)
...@@ -74,3 +74,9 @@ cc_binary( ...@@ -74,3 +74,9 @@ cc_binary(
":mace_version_script.lds", ":mace_version_script.lds",
], ],
) )
cc_library(
name = "libmace",
srcs = ["libmace.so"],
visibility = ["//visibility:public"],
)
...@@ -20,7 +20,7 @@ cc_library( ...@@ -20,7 +20,7 @@ cc_library(
) )
cc_binary( cc_binary(
name = "benchmark_model", name = "benchmark_model_static",
srcs = [ srcs = [
"benchmark_model.cc", "benchmark_model.cc",
], ],
...@@ -40,7 +40,7 @@ cc_binary( ...@@ -40,7 +40,7 @@ cc_binary(
) )
cc_binary( cc_binary(
name = "benchmark_model_deps_so", name = "benchmark_model_shared",
srcs = [ srcs = [
"benchmark_model.cc", "benchmark_model.cc",
], ],
...@@ -55,7 +55,7 @@ cc_binary( ...@@ -55,7 +55,7 @@ cc_binary(
":statistics", ":statistics",
"//external:gflags_nothreads", "//external:gflags_nothreads",
"//mace/codegen:generated_mace_engine_factory", "//mace/codegen:generated_mace_engine_factory",
"@libmace//:libmace", "//mace:libmace",
], ],
) )
......
...@@ -34,6 +34,6 @@ cc_binary( ...@@ -34,6 +34,6 @@ cc_binary(
"//external:gflags_nothreads", "//external:gflags_nothreads",
"//mace/codegen:generated_mace_engine_factory", "//mace/codegen:generated_mace_engine_factory",
"//mace/utils:utils", "//mace/utils:utils",
"@libmace//:libmace", "//mace:libmace",
], ],
) )
...@@ -596,23 +596,21 @@ def update_libmace_shared_library(serial_num, ...@@ -596,23 +596,21 @@ def update_libmace_shared_library(serial_num,
project_name, project_name,
build_output_dir, build_output_dir,
library_output_dir): library_output_dir):
libmace_name = "libmace.so"
mace_library_dir = "./dynamic_lib/"
library_dir = "%s/%s/%s/%s" % ( library_dir = "%s/%s/%s/%s" % (
build_output_dir, project_name, library_output_dir, abi) build_output_dir, project_name, library_output_dir, abi)
libmace_file = "%s/%s" % (library_dir, libmace_name)
if os.path.exists(libmace_file): if os.path.exists(library_dir):
sh.rm("-rf", library_dir) sh.rm("-rf", library_dir)
sh.mkdir("-p", library_dir) sh.mkdir("-p", library_dir)
sh.cp("-f", "bazel-bin/mace/libmace.so", library_dir) sh.cp("-f", "bazel-bin/mace/libmace.so", library_dir)
sh.cp("-f", "%s/%s/libgnustl_shared.so" % (mace_library_dir, abi), sh.cp("-f",
"%s/sources/cxx-stl/gnu-libstdc++/4.9/libs/%s/libgnustl_shared.so" %
(os.environ["ANDROID_NDK"], abi),
library_dir) library_dir)
libmace_load_path = "%s/%s" % (mace_library_dir, libmace_name) if os.path.exists("mace/libmace.so"):
if os.path.exists(libmace_load_path): sh.rm("-f", "mace/libmace.so")
sh.rm("-f", libmace_load_path) sh.cp("-f", "bazel-bin/mace/libmace.so", "mace/")
sh.cp("-f", "bazel-bin/mace/libmace.so", mace_library_dir)
def tuning_run(abi, def tuning_run(abi,
...@@ -1049,23 +1047,23 @@ def build_benchmark_model(abi, ...@@ -1049,23 +1047,23 @@ def build_benchmark_model(abi,
model_output_dir, model_output_dir,
hexagon_mode, hexagon_mode,
linkshared=False): linkshared=False):
benchmark_binary_file = "%s/benchmark_model" % model_output_dir
if os.path.exists(benchmark_binary_file):
sh.rm("-rf", benchmark_binary_file)
if linkshared == 0: if linkshared == 0:
benchmark_target = "//mace/benchmark:benchmark_model" target_name = "benchmark_model_static"
else: else:
benchmark_target = "//mace/benchmark:benchmark_model_deps_so" target_name = "benchmark_model_shared"
benchmark_target = "//mace/benchmark:benchmark_model_shared"
benchmark_target = "//mace/benchmark:%s" % target_name
bazel_build(benchmark_target, bazel_build(benchmark_target,
abi=abi, abi=abi,
hexagon_mode=hexagon_mode) hexagon_mode=hexagon_mode)
benchmark_binary_file = "%s/%s" % (model_output_dir, target_name)
if os.path.exists(benchmark_binary_file):
sh.rm("-rf", benchmark_binary_file)
target_bin = "/".join(bazel_target_to_bin(benchmark_target)) target_bin = "/".join(bazel_target_to_bin(benchmark_target))
if linkshared == 0:
sh.cp("-f", target_bin, model_output_dir) sh.cp("-f", target_bin, model_output_dir)
else:
sh.cp("-f", target_bin, "%s/benchmark_model" % model_output_dir)
def benchmark_model(abi, def benchmark_model(abi,
...@@ -1093,6 +1091,11 @@ def benchmark_model(abi, ...@@ -1093,6 +1091,11 @@ def benchmark_model(abi,
linkshared=0): linkshared=0):
print("* Benchmark for %s" % model_tag) print("* Benchmark for %s" % model_tag)
if linkshared == 0:
benchmark_model_target = "benchmark_model_static"
else:
benchmark_model_target = "benchmark_model_shared"
mace_model_path = "" mace_model_path = ""
if build_type == BuildType.proto: if build_type == BuildType.proto:
mace_model_path = "%s/%s.pb" % (mace_model_dir, model_tag) mace_model_path = "%s/%s.pb" % (mace_model_dir, model_tag)
...@@ -1101,7 +1104,7 @@ def benchmark_model(abi, ...@@ -1101,7 +1104,7 @@ def benchmark_model(abi,
[ [
"env", "env",
"MACE_CPP_MIN_VLOG_LEVEL=%s" % vlog_level, "MACE_CPP_MIN_VLOG_LEVEL=%s" % vlog_level,
"%s/benchmark_model" % benchmark_binary_dir, "%s/%s" % (benchmark_binary_dir, benchmark_model_target),
"--model_name=%s" % model_tag, "--model_name=%s" % model_tag,
"--input_node=%s" % ",".join(input_nodes), "--input_node=%s" % ",".join(input_nodes),
"--output_node=%s" % ",".join(output_nodes), "--output_node=%s" % ",".join(output_nodes),
...@@ -1146,7 +1149,8 @@ def benchmark_model(abi, ...@@ -1146,7 +1149,8 @@ def benchmark_model(abi,
adb_push("%s/libgnustl_shared.so" % shared_library_dir, adb_push("%s/libgnustl_shared.so" % shared_library_dir,
phone_data_dir, phone_data_dir,
serialno) serialno)
adb_push("%s/benchmark_model" % benchmark_binary_dir, phone_data_dir, adb_push("%s/%s" % (benchmark_binary_dir, benchmark_model_target),
phone_data_dir,
serialno) serialno)
sh.adb( sh.adb(
...@@ -1159,7 +1163,7 @@ def benchmark_model(abi, ...@@ -1159,7 +1163,7 @@ def benchmark_model(abi,
phone_data_dir, phone_data_dir,
"MACE_INTERNAL_STORAGE_PATH=%s" % internal_storage_dir, "MACE_INTERNAL_STORAGE_PATH=%s" % internal_storage_dir,
"MACE_OPENCL_PROFILING=1", "MACE_OPENCL_PROFILING=1",
"%s/benchmark_model" % phone_data_dir, "%s/%s" % (phone_data_dir, benchmark_model_target),
"--model_name=%s" % model_tag, "--model_name=%s" % model_tag,
"--input_node=%s" % ",".join(input_nodes), "--input_node=%s" % ",".join(input_nodes),
"--output_node=%s" % ",".join(output_nodes), "--output_node=%s" % ",".join(output_nodes),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册