From e55ac2c72e6bcee850313c7dde353154879074bf Mon Sep 17 00:00:00 2001 From: Eunju Yang Date: Wed, 11 Dec 2024 14:04:38 +0900 Subject: [PATCH] [ minor ] bugfix in model_commo_properties / LossScale - This commit fixes a minor error to print error log. - This commit adds a condition to print the error log. Signed-off-by: Eunju Yang --- nntrainer/models/model_common_properties.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nntrainer/models/model_common_properties.cpp b/nntrainer/models/model_common_properties.cpp index 9fc78d5602..c25d1cea7e 100644 --- a/nntrainer/models/model_common_properties.cpp +++ b/nntrainer/models/model_common_properties.cpp @@ -43,8 +43,10 @@ ModelTensorDataType::ModelTensorDataType(ModelTensorDataTypeInfo::Enum value) { LossScale::LossScale(float value) { set(value); } bool LossScale::isValid(const float &value) const { - ml_loge("Loss scale cannot be 0"); - return value != 0; + bool is_valid = (std::fpclassify(value) != FP_ZERO); + if (!is_valid) + ml_loge("Loss scale cannot be 0"); + return is_valid; } } // namespace nntrainer::props