[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 cbfff7fe8f70df9eb1610975e583da032118e1e0..eaef20f6167bd991f3fcce7ca3ed57abb3a3db26 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 1159eab6d7f751ec97585fa49153cee3e3b9b05c..b5fc00046386e64633b485965be754672811550d 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 051d7ab784e3c35f735048cc0040203602c263bd..fe0183dba9e7a026f30f6bef6d0e08b49869d595 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 a757117c5c531b8901f85917b540db14ed325018..19fe554e3b11bb465eb86bb7a4a0afe9094f9ccf 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 acc33081c2f6bb9e33000f3ebca08c5914b99aa1..fe212a4d284ad0706ea7db079dde6c64d1deae81 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 ed536d7e2dab1a4b8a9906bd00d954102e397537..45b446f3830b5079815afb0a7f9971e6d81711e2 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 */