Skip to content

Commit

Permalink
[Tensor] Remove NaN check for integer
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
djeong20 committed Jul 3, 2024
1 parent ed2d27f commit 5e6aebc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions nntrainer/tensor/tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 5e6aebc

Please sign in to comment.