This PR includes Coverity issues fixes.
**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>
// Decode image, allocating tensor once the image size is known
uint8_t *output = new uint8_t[abs(*height) * *width * *channels];
const uint8_t *bmp_pixels = &img_bytes[header_size];
- return decode_bmp(bmp_pixels, row_size, output, *width, abs(*height),
- *channels, top_down);
+ decode_bmp(bmp_pixels, row_size, output, *width, abs(*height), *channels,
+ top_down);
+ delete[] img_bytes;
+ return output;
}
} // namespace label_image
next_inbatch.push_back({{next_in}});
}
+ nntrainer::Tensor q_in, nq_in;
+ try {
+ q_in = nntrainer::Tensor(inbatch);
+ nq_in = nntrainer::Tensor(next_inbatch);
+ } catch (...) {
+ std::cerr << "Error during tensor constructino" << std::endl;
+ mainNet.finalize();
+ targetNet.finalize();
+ return 0;
+ }
+
/**
* @brief run forward propagation with mainNet
*/
- nntrainer::Tensor Q =
- mainNet.forwarding(nntrainer::Tensor(inbatch), status);
+ nntrainer::Tensor Q = mainNet.forwarding(q_in, status);
/**
* @brief run forward propagation with targetNet
*/
- nntrainer::Tensor NQ =
- targetNet.forwarding(nntrainer::Tensor(next_inbatch), status);
+ nntrainer::Tensor NQ = targetNet.forwarding(nq_in, status);
float *nqa = NQ.getData();
/**
decode_bmp(bmp_pixels, row_size, output, *width, abs(*height), *channels,
top_down);
- delete (img_bytes);
+ delete[] img_bytes;
return output;
}
* @retval true/false false : end of data
*/
bool getData(std::ifstream &F, std::vector<float> &outVec,
- std::vector<float> &outLabel, int id) {
+ std::vector<float> &outLabel, unsigned int id) {
F.clear();
F.seekg(0, std::ios_base::end);
uint64_t file_length = F.tellg();
- uint64_t position =
- (uint64_t)((feature_size + total_label_size) * id * sizeof(float));
+ uint64_t position = (uint64_t)((feature_size + total_label_size) *
+ (uint64_t)id * sizeof(float));
if (position > file_length) {
return false;
len = b * feature_len;
}
- TensorDim(const TensorDim &rhs) :
- TensorDim(rhs.batch(), rhs.channel(), rhs.height(), rhs.width()){};
+ TensorDim(const TensorDim &rhs) = default;
~TensorDim(){};
if (layers.empty()) {
ml_loge("there is no layer section in the ini file");
- return ML_ERROR_INVALID_PARAMETER;
+ status = ML_ERROR_INVALID_PARAMETER;
}
iniparser_freedict(ini);
nntrainer::NeuralNetwork NN;
private:
- void erase_ini() { std::remove((char *)(getIniName().c_str())); }
+ void erase_ini() { name.clear(); }
int failAt;
std::string name;
std::vector<IniSection> sections;
* @retval true/false false : end of data
*/
static bool getData(std::ifstream &F, std::vector<float> &outVec,
- std::vector<float> &outLabel, uint64_t id) {
+ std::vector<float> &outLabel, unsigned int id) {
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) * id * sizeof(float));
+ (uint64_t)((feature_size + num_class) * (uint64_t)id * sizeof(float));
if (position > file_length) {
return false;
status = ml_train_model_destroy(handle);
EXPECT_EQ(status, ML_ERROR_NONE);
- free(sum);
+ delete[] sum;
}
/**