[Ahub] Fix Ahub issue
authorSeoHyungjun <hyungjun.seo@samsung.com>
Thu, 24 Aug 2023 09:41:39 +0000 (18:41 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Wed, 20 Sep 2023 06:47:40 +0000 (15:47 +0900)
The second argument of tensor_dtype is used as std::regex(string).
But it didn't include handling for std::regex_error. created a getRegex()
function because it is used in a similar form in other codes. The
getRegex() function takes a string and retrun a std::regex object.

Signed-off-by: SeoHyungjun <hyungjun.seo@samsung.com>
Applications/meson.build
nntrainer/graph/network_graph.h
nntrainer/tensor/blas_neon.cpp
nntrainer/tensor/manager.h
nntrainer/utils/util_func.cpp
nntrainer/utils/util_func.h

index cbfff7f..eaef20f 100644 (file)
@@ -12,9 +12,9 @@ subdir('Resnet/jni')
 subdir('YOLO/jni')
 subdir('ReinforcementLearning/DeepQ/jni')
 subdir('TransferLearning/CIFAR_Classification/jni')
-if enable_capi
-  subdir('TransferLearning/Draw_Classification/jni')
-endif
+if enable_capi
+  subdir('TransferLearning/Draw_Classification/jni')
+endif
 subdir('Custom')
 subdir('ProductRatings/jni')
 subdir('AlexNet/jni')
index 1159eab..b5fc000 100644 (file)
@@ -50,7 +50,7 @@ public:
     optimize_memory(true),
     exec_mode(ExecutionMode::TRAIN),
     tensor_format("NCHW"),
-    tensor_dtype(split("FP32-FP32", std::regex("\\-"))) {}
+    tensor_dtype(split("FP32-FP32", getRegex("\\-"))) {}
 
   /**
    * @brief     Constructor of NeuralNetwork Graph Class
@@ -72,7 +72,7 @@ public:
     optimize_memory(true),
     exec_mode(ExecutionMode::TRAIN),
     tensor_format(tensor_format_),
-    tensor_dtype(split(tensor_dtype_, std::regex("\\-"))) {}
+    tensor_dtype(split(tensor_dtype_, getRegex("\\-"))) {}
 
   /**
    * @brief   Destructor of the NeuralNetwork Graph class
index 051d7ab..fe0183d 100644 (file)
@@ -515,17 +515,6 @@ void sgemv_transpose_neon_fp16(const __fp16 *A, const __fp16 *X, __fp16 *Y,
       __fp16 x = alpha * X[i];
 
       for (unsigned int j = 0; j < cols; j += 8) {
-        __fp16 *__restrict y = &Y[j];
-
-        float16x8_t y0_7 = vld1q_f16(&Y[j]);
-        float16x8_t wvec0_7 = vld1q_f16(&A[i * cols + j]);
-
-        y0_7 = vfmaq_n_f16(y0_7, wvec0_7, x);
-
-        float16x8_t wvec0_7;
-        const __fp16 *__restrict w;
-
-        w = &A[i * cols + j];
 
         float16x8_t y0_7 = vld1q_f16(&Y[j]);
         float16x8_t wvec0_7 = vld1q_f16(&A[i * cols + j]);
index a757117..19fe554 100644 (file)
@@ -134,7 +134,7 @@ public:
     enable_optimizations(true),
     swap_lookahead(0),
     tensor_format("NCHW"),
-    tensor_dtype(split("FP32-FP32", std::regex("\\-"))) {}
+    tensor_dtype(split("FP32-FP32", getRegex("\\-"))) {}
 
   /**
    * @brief     Constructor of Manager
@@ -147,7 +147,7 @@ public:
     enable_optimizations(true),
     swap_lookahead(lookahead),
     tensor_format(tensor_format_),
-    tensor_dtype(split(tensor_dtype_, std::regex("\\-"))) {}
+    tensor_dtype(split(tensor_dtype_, getRegex("\\-"))) {}
 
   /**
    * @brief Construct a new Manager object (deleted)
index acc3308..fe212a4 100644 (file)
@@ -189,6 +189,7 @@ std::vector<std::string> split(const std::string &s, const std::regex &reg) {
     str.erase(std::remove(str.begin(), str.end(), char_to_remove[i]),
               str.end());
   }
+
   std::regex_token_iterator<std::string::iterator> end;
   std::regex_token_iterator<std::string::iterator> iter(str.begin(), str.end(),
                                                         reg, -1);
@@ -227,4 +228,16 @@ tm *getLocaltime(tm *tp) {
 #endif
 }
 
+std::regex getRegex(const std::string &str) {
+  std::regex result;
+
+  try {
+    result = std::regex(str);
+  } catch (const std::regex_error &e) {
+    ml_loge("regex_error caught: %s", e.what());
+  }
+
+  return result;
+}
+
 } // namespace nntrainer
index ed536d7..45b446f 100644 (file)
@@ -300,6 +300,13 @@ char *getRealpath(const char *name, char *resolved);
  */
 tm *getLocaltime(tm *tp);
 
+/**
+ * @brief Create and return std::regex with the received string
+ * @param str String in regular expression form
+ * @return std::regex
+ */
+std::regex getRegex(const std::string &str);
+
 } /* namespace nntrainer */
 
 #endif /* __cplusplus */