From 198344e7e6df8a8e09329a54a708b97eeb81af4f Mon Sep 17 00:00:00 2001 From: Liangliang He Date: Wed, 28 Feb 2018 11:38:34 +0800 Subject: [PATCH] Minor fixes about logging and const tensor interface --- mace/core/mace.cc | 4 ++-- mace/core/net.cc | 8 +++----- mace/core/workspace.cc | 8 ++++---- mace/public/mace.h | 4 ++-- mace/utils/logging.h | 1 + tools/export_lib.sh | 6 ++++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/mace/core/mace.cc b/mace/core/mace.cc index 83729b79..3e0d642f 100644 --- a/mace/core/mace.cc +++ b/mace/core/mace.cc @@ -10,7 +10,7 @@ namespace mace { ConstTensor::ConstTensor(const std::string &name, - unsigned char *data, + const unsigned char *data, const std::vector &dims, const DataType data_type, uint32_t node_id) : @@ -23,7 +23,7 @@ ConstTensor::ConstTensor(const std::string &name, node_id_(node_id) {} ConstTensor::ConstTensor(const std::string &name, - unsigned char *data, + const unsigned char *data, const std::vector &dims, const int data_type, uint32_t node_id) : diff --git a/mace/core/net.cc b/mace/core/net.cc index 1dcef048..46febc68 100644 --- a/mace/core/net.cc +++ b/mace/core/net.cc @@ -22,7 +22,7 @@ SimpleNet::SimpleNet(const std::shared_ptr op_registry, const NetMode mode) : NetBase(op_registry, net_def, ws, type), device_type_(type) { - VLOG(1) << "Constructing SimpleNet " << net_def->name(); + MACE_LATENCY_LOGGER(1, "Constructing SimpleNet ", net_def->name()); for (int idx = 0; idx < net_def->op_size(); ++idx) { const auto &operator_def = net_def->op(idx); VLOG(3) << "Creating operator " << operator_def.name() << "(" @@ -41,10 +41,8 @@ bool SimpleNet::Run(RunMetadata *run_metadata) { MACE_LATENCY_LOGGER(1, "Running net"); for (auto iter = operators_.begin(); iter != operators_.end(); ++iter) { auto &op = *iter; - VLOG(3) << "Running operator " << op->debug_def().name() << "(" - << op->debug_def().type() << ")."; - MACE_LATENCY_LOGGER(2, "Running operator ", op->debug_def().name()); - + MACE_LATENCY_LOGGER(2, "Running operator ", op->debug_def().name(), + "(", op->debug_def().type(), ")"); bool future_wait = (device_type_ == DeviceType::OPENCL && (run_metadata != nullptr || std::distance(iter, operators_.end()) == 1)); diff --git a/mace/core/workspace.cc b/mace/core/workspace.cc index 2cf55a3b..29491e0f 100644 --- a/mace/core/workspace.cc +++ b/mace/core/workspace.cc @@ -74,11 +74,11 @@ void Workspace::LoadModelTensor(const NetDef &net_def, DeviceType type) { Serializer serializer; for (auto &tensor_proto : net_def.tensors()) { MACE_LATENCY_LOGGER(2, "Load tensor ", tensor_proto.name()); - VLOG(3) << "Load tensor: " << tensor_proto.name() - << ", with data type: " << tensor_proto.data_type() - << ", has shape: " + VLOG(3) << "Tensor name: " << tensor_proto.name() + << ", data type: " << tensor_proto.data_type() + << ", shape: " << MakeString(std::vector(tensor_proto.dims().begin(), - tensor_proto.dims().end())); + tensor_proto.dims().end())); tensor_map_[tensor_proto.name()] = serializer.Deserialize(tensor_proto, type); } diff --git a/mace/public/mace.h b/mace/public/mace.h index ab91e4c7..591987cb 100644 --- a/mace/public/mace.h +++ b/mace/public/mace.h @@ -73,12 +73,12 @@ enum DataType { class ConstTensor { public: ConstTensor(const std::string &name, - unsigned char *data, + const unsigned char *data, const std::vector &dims, const DataType data_type = DT_FLOAT, uint32_t node_id = 0); ConstTensor(const std::string &name, - unsigned char *data, + const unsigned char *data, const std::vector &dims, const int data_type, uint32_t node_id = 0); diff --git a/mace/utils/logging.h b/mace/utils/logging.h index 6dc5658c..59283158 100644 --- a/mace/utils/logging.h +++ b/mace/utils/logging.h @@ -113,6 +113,7 @@ class LatencyLogger { : vlog_level_(vlog_level), message_(message) { if (VLOG_IS_ON(vlog_level_)) { start_micros_ = NowMicros(); + VLOG(vlog_level_) << message_ << " started"; } } ~LatencyLogger() { diff --git a/tools/export_lib.sh b/tools/export_lib.sh index 119dfa15..a178c118 100755 --- a/tools/export_lib.sh +++ b/tools/export_lib.sh @@ -161,8 +161,10 @@ rm -rf ${EXPORT_LIB_DIR} mkdir -p ${EXPORT_LIB_DIR} cp ${MACE_SOURCE_DIR}/mace/public/*.h ${EXPORT_INCLUDE_DIR}/mace/public/ || exit 1 -# utils is noti part of public API -cp ${MACE_SOURCE_DIR}/mace/utils/*.h ${EXPORT_INCLUDE_DIR}/mace/utils/ || exit 1 +# utils is not part of public API +cp ${MACE_SOURCE_DIR}/mace/utils/env_time.h ${EXPORT_INCLUDE_DIR}/mace/utils/ || exit 1 +cp ${MACE_SOURCE_DIR}/mace/utils/logging.h ${EXPORT_INCLUDE_DIR}/mace/utils/ || exit 1 +cp ${MACE_SOURCE_DIR}/mace/utils/string_util.h ${EXPORT_INCLUDE_DIR}/mace/utils/ || exit 1 cp ${LIBMACE_TEMP_DIR}/libmace.a ${LIBMACE_TEMP_DIR}/libmace_dev.a ${LIBMACE_TEMP_DIR}/libmace_prod.a ${EXPORT_LIB_DIR}/ || exit 1 echo "Step 6: Remove temporary file" -- GitLab