Clean up Utils in common (#799)
author김수진/동작제어Lab(SR)/Engineer/삼성전자 <sjsujin.kim@samsung.com>
Thu, 19 Apr 2018 05:57:14 +0000 (14:57 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 19 Apr 2018 05:57:14 +0000 (14:57 +0900)
This commit cleans up Utils in common.

Signed-off-by: sjsujinkim <sjsujin.kim@samsung.com>
src/runtime/ref/nn/common/Utils.cpp
src/runtime/ref/nn/common/include/Utils.h

index 81ccbb7..af624e5 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_TAG "Utils"
-
 #include "Utils.h"
 #include "NeuralNetworks.h"
-#if 0 // REF-ANN
-#include <android-base/logging.h>
-#include <android-base/properties.h>
-#include <android-base/strings.h>
-#include <sys/system_properties.h>
-#include <unordered_map>
-using ::android::hidl::allocator::V1_0::IAllocator;
-#endif // REF-ANN
 
 namespace android {
 namespace nn {
-#if 0 // REF-ANN
-const char kVLogPropKey[] = "debug.nn.vlog";
-int vLogMask = ~0;
-
-// Split the space separated list of tags from verbose log setting and build the
-// logging mask from it. note that '1' and 'all' are special cases to enable all
-// verbose logging.
-//
-// NN API verbose logging setting comes from system property debug.nn.vlog.
-// Example:
-// setprop debug.nn.vlog 1 : enable all logging tags.
-// setprop debug.nn.vlog "model compilation" : only enable logging for MODEL and
-//                                             COMPILATION tags.
-void initVLogMask() {
-    vLogMask = 0;
-    const std::string vLogSetting = android::base::GetProperty(kVLogPropKey, "");
-    if (vLogSetting.empty()) {
-        return;
-    }
-
-    std::unordered_map<std::string, int> vLogFlags = {
-        {"1", -1},
-        {"all", -1},
-        {"model", MODEL},
-        {"compilation", COMPILATION},
-        {"execution", EXECUTION},
-        {"cpuexe", CPUEXE},
-        {"manager", MANAGER},
-        {"driver", DRIVER}};
-
-    std::vector<std::string> elements = android::base::Split(vLogSetting, " ");
-    for (const auto& elem : elements) {
-        const auto& flag = vLogFlags.find(elem);
-        if (flag == vLogFlags.end()) {
-            LOG(ERROR) << "Unknown trace flag: " << elem;
-            continue;
-        }
 
-        if (flag->second == -1) {
-            // -1 is used for the special values "1" and "all" that enable all
-            // tracing.
-            vLogMask = ~0;
-            return;
-        } else {
-            vLogMask |= 1 << flag->second;
-        }
-    }
-}
-#endif // REF-ANN
 #define COUNT(X) (sizeof(X) / sizeof(X[0]))
 
 const char* kTypeNames[kNumberOfDataTypes] = {
@@ -248,17 +190,7 @@ uint32_t alignBytesNeeded(uint32_t index, size_t length) {
     uint32_t extra = (~(index - 1)) & pattern;
     return extra;
 }
-#if 0 // REF-ANN
-void logModelToInfo(const Model& model) {
-    LOG(INFO) << "Model start";
-    LOG(INFO) << "operands" << toString(model.operands);
-    LOG(INFO) << "operations" << toString(model.operations);
-    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);
-}
-#endif // REF-ANN
+
 // Validates the type. The used dimensions can be underspecified.
 int validateOperandType(const ANeuralNetworksOperandType& type, const char* tag,
                         bool allowPartial) {
@@ -299,7 +231,7 @@ int validateOperandList(uint32_t count, const uint32_t* list, uint32_t operandCo
     }
     return ANEURALNETWORKS_NO_ERROR;
 }
-#if 0 // REF-ANN
+
 static bool validOperandIndexes(const hidl_vec<uint32_t> indexes, size_t operandCount) {
     for (uint32_t i : indexes) {
         if (i >= operandCount) {
@@ -315,7 +247,7 @@ static bool validOperands(const hidl_vec<Operand>& operands, const hidl_vec<uint
     for (auto& operand : operands) {
         if (!validCode(kNumberOfDataTypes, kNumberOfDataTypesOEM,
                        static_cast<uint32_t>(operand.type))) {
-            LOG(ERROR) << "Invalid operand type " << toString(operand.type);
+            LOG(ERROR) << "Invalid operand type ";
             return false;
         }
         /* TODO validate dim with type
@@ -362,7 +294,7 @@ static bool validOperations(const hidl_vec<Operation>& operations, size_t operan
     for (auto& op : operations) {
         if (!validCode(kNumberOfOperationTypes, kNumberOfOperationTypesOEM,
                        static_cast<uint32_t>(op.type))) {
-            LOG(ERROR) << "Invalid operation type " << toString(op.type);
+            LOG(ERROR) << "Invalid operation type ";
             return false;
         }
         if (!validOperandIndexes(op.inputs, operandCount) ||
@@ -448,17 +380,5 @@ bool validateRequest(const Request& request, const Model& model) {
                                   "output"));
 }
 
-#ifdef NN_DEBUGGABLE
-uint32_t getProp(const char* str, uint32_t defaultValue) {
-    const std::string propStr = android::base::GetProperty(str, "");
-    if (propStr.size() > 0) {
-        return std::stoi(propStr);
-    } else {
-        return defaultValue;
-    }
-}
-#endif  // NN_DEBUGGABLE
-#endif // REF-ANN
-
 } // namespace nn
 } // namespace android
index c7a6489..75aafef 100644 (file)
@@ -44,32 +44,6 @@ const int kNumberOfOperationTypesOEM = 1;
 // The lowest number assigned to any OEM Code in NeuralNetworksOEM.h.
 const int kOEMCodeBase = 10000;
 
-#if 0 // REF-ANN
-/* IMPORTANT: if you change the following list, don't
- * forget to update the corresponding 'tags' table in
- * the initVlogMask() function implemented in Utils.cpp.
- */
-enum VLogFlags {
-    MODEL = 0,
-    COMPILATION,
-    EXECUTION,
-    CPUEXE,
-    MANAGER,
-    DRIVER
-};
-
-#define VLOG_IS_ON(TAG) \
-    ((vLogMask & (1 << (TAG))) != 0)
-
-#define VLOG(TAG)         \
-    if (LIKELY(!VLOG_IS_ON(TAG))) \
-        ;                 \
-    else                  \
-        LOG(INFO)
-
-extern int vLogMask;
-void initVLogMask();
-#endif // REF-ANN
 // Assert macro, as Android does not generally support assert.
 #define nnAssert(v)                                                                            \
     do {                                                                                       \
@@ -104,10 +78,7 @@ hidl_memory allocateSharedMemory(int64_t size);
 // TODO: This is arbitrary, more a proof of concept.  We need
 // to determine what this should be.
 uint32_t alignBytesNeeded(uint32_t index, size_t length);
-#if 0 // REF-ANN
-// Does a detailed LOG(INFO) of the model
-void logModelToInfo(const Model& model);
-#endif // REF-ANN
+
 inline void setFromIntList(hidl_vec<uint32_t>* vec, uint32_t count, const uint32_t* data) {
     vec->resize(count);
     for (uint32_t i = 0; i < count; i++) {
@@ -121,7 +92,7 @@ inline void setFromIntList(std::vector<uint32_t>* vec, uint32_t count, const uin
         (*vec)[i] = data[i];
     }
 }
-#if 0 // REF-ANN
+
 inline std::string toString(uint32_t obj) {
     return std::to_string(obj);
 }
@@ -134,7 +105,7 @@ std::string toString(const std::vector<Type>& range) {
     }
     return os += "]";
 }
-#endif // REF-ANN
+
 inline bool validCode(uint32_t codeCount, uint32_t codeCountOEM, uint32_t code) {
     return (code < codeCount) || (code >= kOEMCodeBase && (code - kOEMCodeBase) < codeCountOEM);
 }
@@ -142,19 +113,13 @@ inline bool validCode(uint32_t codeCount, uint32_t codeCountOEM, uint32_t code)
 int validateOperandType(const ANeuralNetworksOperandType& type, const char* tag, bool allowPartial);
 int validateOperandList(uint32_t count, const uint32_t* list, uint32_t operandCount,
                         const char* tag);
-#if 0 // REF-ANN
+
 bool validateModel(const Model& model);
 bool validateRequest(const Request& request, const Model& model);
-#endif // REF-ANN
+
 inline size_t getSizeFromInts(int lower, int higher) {
     return (uint32_t)(lower) + ((uint64_t)(uint32_t)(higher) << 32);
 }
-#if 0 // REF-ANN
-#ifdef NN_DEBUGGABLE
-uint32_t getProp(const char* str, uint32_t defaultValue = 0);
-#endif  // NN_DEBUGGABLE
-
-#endif // REF-ANN
 
 }  // namespace nn
 }  // namespace android