!3343 fix float max value compare

Merge pull request !3343 from fary86/fix_float_max_value_compare
This commit is contained in:
mindspore-ci-bot 2020-07-23 11:46:38 +08:00 committed by Gitee
commit 2ead27f8d5
2 changed files with 13 additions and 2 deletions

View File

@ -115,6 +115,7 @@ AnfNodePtr FuncGraphSpecializer::ReplicateDisconnectedNode(const AnfNodePtr &nod
std::shared_ptr<FuncGraphSpecializer> specializer = shared_from_this();
while (fg != nullptr && fg != specializer->func_graph_) {
specializer = specializer->parent_;
MS_EXCEPTION_IF_NULL(specializer);
}
// If had replicated, just return that.
auto iter = specializer->repl_node_->find(node);

View File

@ -130,7 +130,12 @@ bool FP32Imm::operator==(const Value &other) const {
return false;
}
}
bool FP32Imm::operator==(const FP32Imm &other) const { return fabs(v_ - other.v_) < FLT_EPSILON; }
bool FP32Imm::operator==(const FP32Imm &other) const {
if (std::isinf(v_) && std::isinf(other.v_)) {
return true;
}
return fabs(v_ - other.v_) < FLT_EPSILON;
}
bool FP64Imm::operator==(const Value &other) const {
if (other.isa<FP64Imm>()) {
auto other_ = static_cast<const FP64Imm &>(other);
@ -179,7 +184,12 @@ std::string ValueSequeue::DumpText() const {
return oss.str();
}
bool FP64Imm::operator==(const FP64Imm &other) const { return fabs(v_ - other.v_) < DBL_EPSILON; }
bool FP64Imm::operator==(const FP64Imm &other) const {
if (std::isinf(v_) && std::isinf(other.v_)) {
return true;
}
return fabs(v_ - other.v_) < DBL_EPSILON;
}
bool StringImm::operator==(const Value &other) const {
if (other.isa<StringImm>()) {
auto other_ = static_cast<const StringImm &>(other);