Browse Source

!3343 fix float max value compare

Merge pull request !3343 from fary86/fix_float_max_value_compare
tags/v0.7.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
2ead27f8d5
2 changed files with 13 additions and 2 deletions
  1. +1
    -0
      mindspore/ccsrc/pipeline/jit/static_analysis/program_specialize.cc
  2. +12
    -2
      mindspore/core/ir/value.cc

+ 1
- 0
mindspore/ccsrc/pipeline/jit/static_analysis/program_specialize.cc View File

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


+ 12
- 2
mindspore/core/ir/value.cc View File

@@ -130,7 +130,12 @@ bool FP32Imm::operator==(const Value &other) const {
return false; 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 { bool FP64Imm::operator==(const Value &other) const {
if (other.isa<FP64Imm>()) { if (other.isa<FP64Imm>()) {
auto other_ = static_cast<const FP64Imm &>(other); auto other_ = static_cast<const FP64Imm &>(other);
@@ -179,7 +184,12 @@ std::string ValueSequeue::DumpText() const {
return oss.str(); 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 { bool StringImm::operator==(const Value &other) const {
if (other.isa<StringImm>()) { if (other.isa<StringImm>()) {
auto other_ = static_cast<const StringImm &>(other); auto other_ = static_cast<const StringImm &>(other);


Loading…
Cancel
Save