summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2018-04-10 15:20:53 -0700
committerMiao Wang <miaowang@google.com>2018-04-16 14:20:38 -0700
commit64031fa26110e6d57896bfdbe1cd58e69cde3dbb (patch)
tree875353676eab0e6751e571f8595bed7131803164
parent984b07d42ce0ed8629a6be2229862d0db4684890 (diff)
downloadml-64031fa26110e6d57896bfdbe1cd58e69cde3dbb.tar.gz
Remove pointer values from the log and hide certain verbose logging
unless building with NN_DEBUGGABLE. Bug: 77605132 Test: mm Test: NeuralNetworksTest_static on walleye-eng with "debug.nn.vlog 1" All tests pass and complete verbose logging are seen in logcat. Test: NeuralNetworksTest_static on walleye-user with "debug.nn.vlog 1" All tests pass and *no* pointers showing in NNAPI verbose logging. Change-Id: Icc7357cded3ec5c197e9a4418d327b10c2ac7178
-rw-r--r--nn/common/CpuExecutor.cpp5
-rw-r--r--nn/common/Utils.cpp6
-rw-r--r--nn/common/include/Utils.h6
-rw-r--r--nn/driver/sample/SampleDriver.cpp2
-rw-r--r--nn/runtime/ExecutionBuilder.cpp7
-rw-r--r--nn/runtime/ExecutionPlan.cpp3
-rw-r--r--nn/runtime/Memory.cpp2
7 files changed, 19 insertions, 12 deletions
diff --git a/nn/common/CpuExecutor.cpp b/nn/common/CpuExecutor.cpp
index 333683acd..283d30720 100644
--- a/nn/common/CpuExecutor.cpp
+++ b/nn/common/CpuExecutor.cpp
@@ -193,9 +193,8 @@ int CpuExecutor::run(const V1_0::Model& model, const Request& request,
int CpuExecutor::run(const V1_1::Model& model, const Request& request,
const std::vector<RunTimePoolInfo>& modelPoolInfos,
const std::vector<RunTimePoolInfo>& requestPoolInfos) {
- VLOG(CPUEXE) << "CpuExecutor::run()";
- // VLOG(CPUEXE) << "model: " << toString(model);
- VLOG(CPUEXE) << "request: " << toString(request);
+ VLOG(CPUEXE) << "CpuExecutor::run() with request("
+ << SHOW_IF_DEBUG(toString(request)) << ")";
mModel = &model;
mRequest = &request; // TODO check if mRequest is needed
diff --git a/nn/common/Utils.cpp b/nn/common/Utils.cpp
index dd5d9d3b2..843fb246c 100644
--- a/nn/common/Utils.cpp
+++ b/nn/common/Utils.cpp
@@ -268,7 +268,7 @@ void logModelToInfo(const V1_0::Model& model) {
LOG(INFO) << "inputIndexes" << toString(model.inputIndexes);
LOG(INFO) << "outputIndexes" << toString(model.outputIndexes);
LOG(INFO) << "operandValues size" << model.operandValues.size();
- LOG(INFO) << "pools" << toString(model.pools);
+ LOG(INFO) << "pools" << SHOW_IF_DEBUG(toString(model.pools));
}
void logModelToInfo(const V1_1::Model& model) {
@@ -278,7 +278,7 @@ void logModelToInfo(const V1_1::Model& model) {
LOG(INFO) << "inputIndexes" << toString(model.inputIndexes);
LOG(INFO) << "outputIndexes" << toString(model.outputIndexes);
LOG(INFO) << "operandValues size" << model.operandValues.size();
- LOG(INFO) << "pools" << toString(model.pools);
+ LOG(INFO) << "pools" << SHOW_IF_DEBUG(toString(model.pools));
}
// Validates the type. The used dimensions can be underspecified.
@@ -1697,7 +1697,7 @@ V1_0::Model convertToV1_0(const V1_0::Model& model) {
V1_0::Model convertToV1_0(const V1_1::Model& model) {
if (!compliantWithV1_0(model)) {
- LOG(ERROR) << "Upcasting non-compliant model " << toString(model)
+ LOG(ERROR) << "Upcasting non-compliant model " << SHOW_IF_DEBUG(toString(model))
<< " from V1_1::Model to V1_0::Model";
}
return {.operands = model.operands,
diff --git a/nn/common/include/Utils.h b/nn/common/include/Utils.h
index d88e13843..96b8e6780 100644
--- a/nn/common/include/Utils.h
+++ b/nn/common/include/Utils.h
@@ -69,6 +69,12 @@ enum VLogFlags {
extern int vLogMask;
void initVLogMask();
+#ifdef NN_DEBUGGABLE
+#define SHOW_IF_DEBUG(msg) msg
+#else
+#define SHOW_IF_DEBUG(msg) ""
+#endif
+
// Assert macro, as Android does not generally support assert.
#define nnAssert(v) \
do { \
diff --git a/nn/driver/sample/SampleDriver.cpp b/nn/driver/sample/SampleDriver.cpp
index 9ebefe580..a608852cb 100644
--- a/nn/driver/sample/SampleDriver.cpp
+++ b/nn/driver/sample/SampleDriver.cpp
@@ -132,7 +132,7 @@ void SamplePreparedModel::asyncExecute(const Request& request,
Return<ErrorStatus> SamplePreparedModel::execute(const Request& request,
const sp<IExecutionCallback>& callback) {
- VLOG(DRIVER) << "execute(" << toString(request) << ")";
+ VLOG(DRIVER) << "execute(" << SHOW_IF_DEBUG(toString(request)) << ")";
if (callback.get() == nullptr) {
LOG(ERROR) << "invalid callback passed to execute";
return ErrorStatus::INVALID_ARGUMENT;
diff --git a/nn/runtime/ExecutionBuilder.cpp b/nn/runtime/ExecutionBuilder.cpp
index 63301b10a..b5a472bc7 100644
--- a/nn/runtime/ExecutionBuilder.cpp
+++ b/nn/runtime/ExecutionBuilder.cpp
@@ -36,8 +36,9 @@ int ModelArgumentInfo::setFromPointer(const Operand& operand,
const ANeuralNetworksOperandType* type, void* data,
uint32_t length) {
if ((data == nullptr) != (length == 0)) {
+ const char* dataPtrMsg = data ? "NOT_NULLPTR" : "NULLPTR";
LOG(ERROR) << "Data pointer must be nullptr if and only if length is zero (data = "
- << data << ", length = " << length << ")";
+ << dataPtrMsg << ", length = " << length << ")";
return ANEURALNETWORKS_BAD_DATA;
}
if (data == nullptr) {
@@ -505,7 +506,7 @@ static void logArguments(const char* kind, const std::vector<ModelArgumentInfo>
std::string prefix = kind + std::string("[") + std::to_string(i) + "] = ";
switch (arg.state) {
case ModelArgumentInfo::POINTER:
- VLOG(EXECUTION) << prefix << "POINTER(" << arg.buffer << ")";
+ VLOG(EXECUTION) << prefix << "POINTER(" << SHOW_IF_DEBUG(arg.buffer) << ")";
break;
case ModelArgumentInfo::MEMORY:
VLOG(EXECUTION) << prefix << "MEMORY("
@@ -629,7 +630,7 @@ int StepExecutor::startComputeOnDevice(sp<ExecutionCallback>* synchronizationCal
// in the design document.
sp<ExecutionCallback> executionCallback = new ExecutionCallback();
- VLOG(EXECUTION) << "Before mPreparedModel->execute() " << toString(request);
+ VLOG(EXECUTION) << "Before mPreparedModel->execute() " << SHOW_IF_DEBUG(toString(request));
// Execute.
// TODO: What happens to the Callback if the service dies abnormally
// -- won't that keep the Callback live forever, because the service
diff --git a/nn/runtime/ExecutionPlan.cpp b/nn/runtime/ExecutionPlan.cpp
index 10470ba39..384de7840 100644
--- a/nn/runtime/ExecutionPlan.cpp
+++ b/nn/runtime/ExecutionPlan.cpp
@@ -583,7 +583,8 @@ int ExecutionPlan::next(std::shared_ptr<Controller> controller,
std::shared_ptr<StepExecutor>* executor) const {
*executor = nullptr;
- VLOG(EXECUTION) << "ExecutionPlan::next(" << controller << ", " << executor
+ VLOG(EXECUTION) << "ExecutionPlan::next("
+ << SHOW_IF_DEBUG(controller << ", " << executor)
<< "): mNextStepIndex = " << controller->mNextStepIndex;
if (controller->mNextStepIndex == Controller::kBadStepIndex) {
diff --git a/nn/runtime/Memory.cpp b/nn/runtime/Memory.cpp
index cbaff17e7..8f76b76d5 100644
--- a/nn/runtime/Memory.cpp
+++ b/nn/runtime/Memory.cpp
@@ -125,7 +125,7 @@ int MemoryFd::getPointer(uint8_t** buffer) const {
}
uint32_t MemoryTracker::add(const Memory* memory) {
- VLOG(MODEL) << __func__ << " for " << memory;
+ VLOG(MODEL) << __func__ << "(" << SHOW_IF_DEBUG(memory) << ")";
// See if we already have this memory. If so,
// return its index.
auto i = mKnown.find(memory);