From 2446ddfdcf37ad2a0212dd396f8c148e3440d408 Mon Sep 17 00:00:00 2001 From: liuqi Date: Wed, 4 Apr 2018 15:44:33 +0800 Subject: [PATCH] Format codes. --- .gitignore | 1 + mace/core/file_storage_engine.cc | 7 ++++--- mace/core/file_storage_engine.h | 2 +- mace/core/runtime/opencl/opencl_runtime.cc | 4 ++-- mace/core/runtime/opencl/opencl_runtime.h | 1 + mace/utils/utils.h | 1 + tools/generate_opencl_code.sh | 2 ++ tools/generate_tuning_param_code.sh | 2 ++ tools/sh_commands.py | 2 ++ 9 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b3a51dd8..c78b060c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ cmake-build-debug/ mace/codegen/models/ mace/codegen/opencl/ mace/codegen/opencl_bin/ +mace/codegen/tuning/ mace/codegen/version/ build/ diff --git a/mace/core/file_storage_engine.cc b/mace/core/file_storage_engine.cc index 9cb53cf2..a3cd12f1 100644 --- a/mace/core/file_storage_engine.cc +++ b/mace/core/file_storage_engine.cc @@ -10,10 +10,11 @@ namespace mace { -std::string FileStorageEngine::kStoragePath = "/data/local/tmp"; +std::string FileStorageEngine::kStoragePath // NOLINT(runtime/string) + = "/data/local/tmp"; FileStorageEngine::FileStorageEngine(const std::string &file_name): - file_name_(file_name){} + file_name_(file_name) {} void FileStorageEngine::Write( const std::map> &data) { @@ -25,7 +26,7 @@ void FileStorageEngine::Write( int64_t data_size = data.size(); ofs.write(reinterpret_cast(&data_size), sizeof(data_size)); - for (auto &kv: data) { + for (auto &kv : data) { int32_t key_size = static_cast(kv.first.size()); ofs.write(reinterpret_cast(&key_size), sizeof(key_size)); ofs.write(kv.first.c_str(), key_size); diff --git a/mace/core/file_storage_engine.h b/mace/core/file_storage_engine.h index f54071fc..9ce742a4 100644 --- a/mace/core/file_storage_engine.h +++ b/mace/core/file_storage_engine.h @@ -15,7 +15,7 @@ namespace mace { class FileStorageEngine : public KVStorageEngine { public: - FileStorageEngine(const std::string &file_name); + explicit FileStorageEngine(const std::string &file_name); public: void Write( const std::map> &data) override; diff --git a/mace/core/runtime/opencl/opencl_runtime.cc b/mace/core/runtime/opencl/opencl_runtime.cc index 5b9d3d45..89db2e9b 100644 --- a/mace/core/runtime/opencl/opencl_runtime.cc +++ b/mace/core/runtime/opencl/opencl_runtime.cc @@ -10,6 +10,7 @@ #include // NOLINT(build/c++11) #include #include +#include #include "mace/core/file_storage_engine.h" #include "mace/core/runtime/opencl/opencl_extension.h" @@ -453,7 +454,7 @@ void OpenCLRuntime::BuildProgramFromSource( this->program_content_map_.emplace(built_program_key, content); this->program_map_changed = true; - VLOG(3) << "Program from source: " << built_program_key ; + VLOG(3) << "Program from source: " << built_program_key; } } @@ -477,7 +478,6 @@ void OpenCLRuntime::BuildProgram(const std::string &program_name, build_options_str, program); } } - } cl::Kernel OpenCLRuntime::BuildKernel( diff --git a/mace/core/runtime/opencl/opencl_runtime.h b/mace/core/runtime/opencl/opencl_runtime.h index b38c0b3a..d0a50932 100644 --- a/mace/core/runtime/opencl/opencl_runtime.h +++ b/mace/core/runtime/opencl/opencl_runtime.h @@ -10,6 +10,7 @@ #include // NOLINT(build/c++11) #include #include +#include #include "mace/core/future.h" #include "mace/core/runtime/opencl/cl2_header.h" diff --git a/mace/utils/utils.h b/mace/utils/utils.h index 4fe46375..a9ca2a40 100644 --- a/mace/utils/utils.h +++ b/mace/utils/utils.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace mace { template diff --git a/tools/generate_opencl_code.sh b/tools/generate_opencl_code.sh index 69f5ce5a..381ce19d 100644 --- a/tools/generate_opencl_code.sh +++ b/tools/generate_opencl_code.sh @@ -17,6 +17,8 @@ TARGET_SOC=$2 CL_BIN_DIRS=$3 PULL_OR_NOT=$4 +mkdir -p ${CL_CODEGEN_DIR} + if [ x"$TYPE" == x"source" ];then python mace/python/tools/encrypt_opencl_codegen.py \ --cl_kernel_dir=./mace/kernels/opencl/cl/ \ diff --git a/tools/generate_tuning_param_code.sh b/tools/generate_tuning_param_code.sh index 353ebc60..11d250e4 100644 --- a/tools/generate_tuning_param_code.sh +++ b/tools/generate_tuning_param_code.sh @@ -3,6 +3,8 @@ CURRENT_DIR=`dirname $0` source ${CURRENT_DIR}/env.sh +mkdir -p ${TUNING_CODEGEN_DIR} + if [ "$#" -eq "0" ]; then python mace/python/tools/binary_codegen.py \ --binary_file_name=mace_run.config \ diff --git a/tools/sh_commands.py b/tools/sh_commands.py index ed5ba51f..c0742c5d 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -128,6 +128,7 @@ def bazel_target_to_bin(target): ################################ # TODO this should be refactored def gen_encrypted_opencl_source(codegen_path="mace/codegen"): + sh.mkdir("-p", "%s/opencl" % codegen_path) sh.python("mace/python/tools/encrypt_opencl_codegen.py", "--cl_kernel_dir=./mace/kernels/opencl/cl/", "--output_path=%s/opencl/opencl_encrypt_program.cc" % codegen_path) @@ -138,6 +139,7 @@ def gen_mace_version(codegen_path="mace/codegen"): "%s/version/version.cc" % codegen_path) def gen_compiled_opencl_source(codegen_path="mace/codegen"): + sh.mkdir("-p", "%s/opencl" % codegen_path) sh.python("mace/python/tools/opencl_codegen.py", "--output_path=%s/opencl/opencl_compiled_program.cc" % codegen_path) -- GitLab