diff --git a/mindspore/ccsrc/backend/common/session/kernel_graph.h b/mindspore/ccsrc/backend/common/session/kernel_graph.h index 0d4c508f81e..a67dbfdb00f 100644 --- a/mindspore/ccsrc/backend/common/session/kernel_graph.h +++ b/mindspore/ccsrc/backend/common/session/kernel_graph.h @@ -132,7 +132,7 @@ class BACKEND_EXPORT KernelGraph : public FuncGraph { void ReplaceGraphInput(const AnfNodePtr &old_parameter, const AnfNodePtr &new_parameter); std::vector outputs() const; CNodePtr NewCNode(std::vector &&inputs) override; - CNodePtr NewCNode(const std::vector &inputs) override; + CNodePtr NewCNode(const std::vector &inputs = std::vector()) override; CNodePtr NewCNodeWithInfos(const std::vector &inputs, const CNodePtr &ori_cnode = nullptr); void CreateKernelInfoFromNewParameter(const CNodePtr &cnode) const; CNodePtr NewCNode(const CNodePtr &cnode); diff --git a/mindspore/core/abstract/abstract_value.cc b/mindspore/core/abstract/abstract_value.cc index d10dd1181ce..a3b027093ba 100644 --- a/mindspore/core/abstract/abstract_value.cc +++ b/mindspore/core/abstract/abstract_value.cc @@ -1444,7 +1444,6 @@ const TypeId AbstractSparseTensor::GetTensorTypeIdAt(size_t index) const { if (index >= shape_idx || index < 0) { MS_LOG(EXCEPTION) << "Index must be in range of [0, " << shape_idx << "), but got " << index << " for " << ToString(); - return kTypeUnknown; } auto abs_tensor = GetAbsPtrAt(index); MS_EXCEPTION_IF_NULL(abs_tensor); @@ -1455,7 +1454,6 @@ const TypeId AbstractSparseTensor::GetShapeTypeIdAt(size_t index) const { if (index >= shape()->size() || index < 0) { MS_LOG(EXCEPTION) << "Index must be in range of [0, " << shape()->size() << "), but got " << index << " for " << ToString(); - return kTypeUnknown; } return shape()->elements()[index]->BuildType()->type_id(); } diff --git a/mindspore/core/abstract/ops/prim_arrays.cc b/mindspore/core/abstract/ops/prim_arrays.cc index 06519bf5286..418560a2dcf 100644 --- a/mindspore/core/abstract/ops/prim_arrays.cc +++ b/mindspore/core/abstract/ops/prim_arrays.cc @@ -924,9 +924,7 @@ AbstractBasePtr InferImplSequenceMask(const AnalysisEnginePtr &, const Primitive ShapeVector lengths_shape = lengths->shape()->shape(); ShapeVector lengths_shape_min = lengths->shape()->min_shape(); - ShapeVector lengths_shape_max = lengths->shape()->max_shape(); - if (!lengths_shape_max.empty() && !lengths_shape_min.empty()) { lengths_shape_min.push_back(maxlen_value); lengths_shape_max.push_back(maxlen_value); diff --git a/mindspore/core/base/complex_storage.h b/mindspore/core/base/complex_storage.h index cd79044c45e..e52c56e5f59 100644 --- a/mindspore/core/base/complex_storage.h +++ b/mindspore/core/base/complex_storage.h @@ -17,6 +17,7 @@ #define MINDSPORE_CORE_BASE_COMPLEX_STORAGE_H_ #include "base/float16.h" +#include "utils/ms_utils.h" namespace mindspore { @@ -62,7 +63,12 @@ struct alignas(sizeof(T) * 2) ComplexStorage { template inline bool operator==(const ComplexStorage &lhs, const ComplexStorage &rhs) { - return (lhs.real_ - rhs.real_ == 0) && (lhs.imag_ - rhs.imag_ == 0); + if constexpr (std::is_same_v) { + return common::IsDoubleEqual(lhs.real_, rhs.real_) && common::IsDoubleEqual(lhs.imag_, rhs.imag_); + } else if constexpr (std::is_same_v) { + return common::IsFloatEqual(lhs.real_, rhs.real_) && common::IsFloatEqual(lhs.imag_, rhs.imag_); + } + return (lhs.real_ == rhs.real_) && (lhs.imag_ == rhs.imag_); } template diff --git a/mindspore/core/ir/dtype/number.h b/mindspore/core/ir/dtype/number.h index 7c199173910..bbb74824907 100644 --- a/mindspore/core/ir/dtype/number.h +++ b/mindspore/core/ir/dtype/number.h @@ -17,7 +17,6 @@ #ifndef MINDSPORE_CORE_IR_DTYPE_NUMBER_H_ #define MINDSPORE_CORE_IR_DTYPE_NUMBER_H_ -#include #include #include #include diff --git a/mindspore/core/ir/dtype/type.h b/mindspore/core/ir/dtype/type.h index 8937c5ccddb..f059b5ba306 100644 --- a/mindspore/core/ir/dtype/type.h +++ b/mindspore/core/ir/dtype/type.h @@ -236,12 +236,12 @@ class MS_CORE_API Object : public Type { // // TypeId name map // -const mindspore::HashMap type_name_map = { +inline const mindspore::HashMap type_name_map = { {kNumberTypeBool, "bool_"}, {kNumberTypeInt8, "int8"}, {kNumberTypeUInt8, "uint8"}, {kNumberTypeInt16, "int16"}, {kNumberTypeInt32, "int32"}, {kNumberTypeInt64, "int64"}, {kNumberTypeFloat16, "float16"}, {kNumberTypeFloat32, "float32"}, {kNumberTypeFloat64, "float64"}}; -const mindspore::HashMap type_priority_map = { +inline const mindspore::HashMap type_priority_map = { {kNumberTypeBool, 0}, {kNumberTypeUInt8, 1}, {kNumberTypeInt8, 2}, {kNumberTypeInt16, 3}, {kNumberTypeInt32, 4}, {kNumberTypeInt64, 5}, {kNumberTypeFloat16, 6}, {kNumberTypeFloat32, 7}, {kNumberTypeFloat64, 8}}; diff --git a/mindspore/core/ir/manager.cc b/mindspore/core/ir/manager.cc index 37708161290..c76c034c901 100644 --- a/mindspore/core/ir/manager.cc +++ b/mindspore/core/ir/manager.cc @@ -298,7 +298,7 @@ bool FuncGraphManager::recursive(const FuncGraphPtr &fg) const { std::shared_ptr> FuncGraphManager::recursive_graphs(const FuncGraphPtr &fg) const { MS_EXCEPTION_IF_NULL(fg); if (recursive(fg)) { - if (!recursive_->recursive_map().count(fg)) { + if (recursive_->recursive_map().count(fg) == 0) { auto trace = std::list(); recursive_->CheckRecursiveGraphs(fg, &trace); } @@ -851,10 +851,9 @@ void FuncGraphTransaction::AddEdge(const AnfNodePtr &src_node, const AnfNodePtr void FuncGraphTransaction::Commit() { manager_->CommitChanges(std::move(changes_)); } -DepComputer::DepComputer(const FuncGraphManager *const manager) : manager_(manager) { +DepComputer::DepComputer(const FuncGraphManager *const manager) : manager_(manager), validate_(false) { MS_EXCEPTION_IF_NULL(manager_); manager_->signals()->InvalidateComputer.connect(this, &DepComputer::OnInvalidateComputer); - validate_ = false; } void DepComputer::Recompute() { @@ -939,7 +938,7 @@ void ParentComputer::RealRecompute(FuncGraphPtr fg) { for (auto &dep : deps) { auto parent_deps = this->manager_->func_graph_parents_total(dep); for (auto &p_d : parent_deps) { - if (deps_copy.count(p_d)) { + if (deps_copy.count(p_d) > 0) { (void)deps_copy.erase(p_d); } } @@ -1085,7 +1084,7 @@ void RecursiveComputer::CheckRecursiveGraphs(const FuncGraphPtr &fg, std::listfirst, trace); } trace->pop_back(); - if (!recursive_map_.count(fg)) { + if (recursive_map_.count(fg) == 0) { recursive_map_[fg] = nullptr; } }