This PR resolves coverity issues in the ShortTensor class.
Replace max_abs() implementation with maxValue() since the maximum absolute value of unsigned int equals to the maximum value.
**Self-evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped
Signed-off-by: Donghyeon Jeong <dhyeon.jeong@samsung.com>
switch (from.getDataType()) {
case ml::train::TensorDim::DataType::UINT16:
copy(from.getData());
+ break;
default:
throw std::invalid_argument("Error: Unsupported data type");
break;
return result;
}
-float ShortTensor::max_abs() const {
- const uint16_t *data = (uint16_t *)getData();
- unsigned int idx;
-
- uint16_t max_val = data[0];
- for (unsigned int i = 1; i < size(); i += 1) {
- uint16_t cur_val = (data[i] >= 0) ? data[i] : -1 * data[i];
- if (cur_val > max_val) {
- max_val = cur_val;
- }
- }
-
- return max_val;
-}
+float ShortTensor::max_abs() const { return maxValue(); }
float ShortTensor::maxValue() const {
const uint16_t *data = (uint16_t *)getData();