[Tensor] Remove NaN check for integer
authorDonghyeon Jeong <dhyeon.jeong@samsung.com>
Wed, 3 Jul 2024 02:28:28 +0000 (11:28 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 3 Jul 2024 04:34:34 +0000 (13:34 +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 df97fc7a44298830e71e47f36c8e6a2856470d0b..c3c2362b5be8dd36a02dbc41db809dd7a2a6bab0 100644 (file)
@@ -249,11 +249,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) {
@@ -266,8 +262,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;
     }
   }