[Tensor] Remove NaN check for integer accepted/tizen_unified_x_asan accepted/tizen/unified/20250120.072844 accepted/tizen/unified/x/20250120.085015 accepted/tizen/unified/x/asan/20250211.003306
authorDonghyeon Jeong <dhyeon.jeong@samsung.com>
Wed, 3 Jul 2024 02:28:28 +0000 (11:28 +0900)
committerjijoong.moon <jijoong.moon@samsung.com>
Fri, 17 Jan 2025 01:23:14 +0000 (10:23 +0900)
Fixed-sized integer formats do not have a way of explicitly indicating invalid data.
Every possible value of an int is a number. Therefore, removing NaN check for int values.

**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>
nntrainer/tensor/tensor.cpp

index b3ac3a8e6ae78bcfcb6d828fee4c001f3da9dcec..391bee49d964ebeb97d349bce9cc687bc9ab9cc6 100644 (file)
@@ -252,11 +252,7 @@ bool Tensor::operator==(const Tensor &rhs) const {
     const uint8_t *_data = getData<uint8_t>();
     const uint8_t *_rdata = rhs.getData<uint8_t>();
     for (size_t i = 0; i < len; ++i) {
-      /** not checking sign change is intentional to avoid float calculation
-       * errors around 0 */
-      if ((std::isnan(_data[i]) && !std::isnan(_rdata[i])) ||
-          (!std::isnan(_data[i]) && std::isnan(_rdata[i])) ||
-          _data[i] != _rdata[i])
+      if (_data[i] != _rdata[i])
         return false;
     }
   } else if (dim.getDataType() == ml::train::TensorDim::DataType::QINT4) {
@@ -269,8 +265,7 @@ bool Tensor::operator==(const Tensor &rhs) const {
       data = decode_qint(_data[i / 2], (i % 2 == 0));
       rdata = decode_qint(_rdata[i / 2], (i % 2 == 0));
 
-      if ((std::isnan(data) && !std::isnan(rdata)) ||
-          (!std::isnan(data) && std::isnan(rdata)) || data != rdata)
+      if (data != rdata)
         return false;
     }
   }