[ SAVCE ] Fix svace issues accepted/tizen/unified/20200813.015359 submit/tizen/20200812.132119
authorjijoong.moon <jijoong.moon@samsung.com>
Wed, 12 Aug 2020 13:03:40 +0000 (22:03 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Wed, 12 Aug 2020 13:18:39 +0000 (22:18 +0900)
This PR includes fixes about SVACE issues

**Self evaluation:**
1. Build test:  [X]Passed [ ]Failed [ ]Skipped
2. Run test:  [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
Applications/Tizen_CAPI/capi_func.c
nntrainer/src/neuralnet.cpp
nntrainer/src/tensor.cpp
nntrainer/src/tensor_dim.cpp
test/nntrainer_test_util.cpp

index 6e64726..0f45e72 100644 (file)
@@ -82,9 +82,6 @@ static bool get_data(const char *file_name, float *outVec, float *outLabel,
   unsigned int i;
   size_t ret;
 
-  if (id < 0)
-    return false;
-
   position =
     (uint64_t)((feature_size + num_class) * (uint64_t)id * sizeof(float));
   if (position > file_length) {
index a174ed4..156b399 100644 (file)
@@ -731,11 +731,6 @@ int NeuralNetwork::train_run() {
             sharedTensor X = MAKE_SHARED_TENSOR(Tensor({in[i]}));
             sharedTensor Y2 = MAKE_SHARED_TENSOR(Tensor({label[i]}));
             sharedConstTensor Y = forwarding(X, Y2);
-            if (status != ML_ERROR_NONE) {
-              ml_loge("Error: forwarding the network resulted in error.");
-              return status;
-            }
-
             if (Y->argmax() == Y2->argmax())
               right++;
             valloss += getLoss();
index ea1a63c..6932be3 100644 (file)
@@ -71,10 +71,6 @@ Tensor::Tensor(const TensorDim &d, const float *buf) :
          : std::shared_ptr<float>(new float[d.getDataLen()],
                                   std::default_delete<float[]>())) {
   if (d.getDataLen() == 0) {
-    if (buf != nullptr) {
-      throw std::runtime_error(
-        "Tensor dimension and source buffer size mismatch");
-    }
     return;
   }
 
index 28811fc..12356a6 100644 (file)
@@ -46,7 +46,7 @@ void TensorDim::resetLen() {
 }
 
 unsigned int TensorDim::getTensorDim(unsigned int idx) {
-  if (idx < 0 || idx > MAXDIM)
+  if (idx > MAXDIM)
     throw std::invalid_argument(
       "[TensorDim] Tensor Dimension index should be between 0 and 4");
 
@@ -54,7 +54,7 @@ unsigned int TensorDim::getTensorDim(unsigned int idx) {
 }
 
 void TensorDim::setTensorDim(unsigned int idx, unsigned int value) {
-  if (idx < 0 || idx > MAXDIM)
+  if (idx > MAXDIM)
     throw std::out_of_range(
       "[TensorDim] Tensor Dimension index should be between 0 and 4");
   if (value <= 0)
index 1f8d02e..00cb03b 100644 (file)
@@ -91,8 +91,7 @@ static bool getData(std::ifstream &F, std::vector<float> &outVec,
   F.clear();
   F.seekg(0, std::ios_base::end);
   uint64_t file_length = F.tellg();
-  if (id < 0)
-    return false;
+
   uint64_t position =
     (uint64_t)((feature_size + num_class) * (uint64_t)id * sizeof(float));