!31581 [GraphKernel]Fix Static Check on master

Merge pull request !31581 from jiaoy1224/staticcheck
This commit is contained in:
i-robot 2022-03-21 02:36:24 +00:00 committed by Gitee
commit e7bad903b8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 18 additions and 18 deletions

View File

@ -28,14 +28,14 @@ class CallbackImpl : public Callback {
ShapeVector GetOutputShape(const AnfNodePtr &node, size_t i) override;
ShapeVector GetInputInferShape(const AnfNodePtr &node, size_t i) override;
ShapeVector GetOutputInferShape(const AnfNodePtr &node, size_t i) override;
TypeId GetInputType(const AnfNodePtr &node, size_t i) override;
TypeId GetOutputType(const AnfNodePtr &node, size_t i) override;
TypeId GetInputInferType(const AnfNodePtr &node, size_t i) override;
TypeId GetOutputInferType(const AnfNodePtr &node, size_t i) override;
std::string GetInputFormat(const AnfNodePtr &node, size_t i) override;
std::string GetOutputFormat(const AnfNodePtr &node, size_t i) override;
std::string GetProcessor(const AnfNodePtr &node) override;
std::string GetTargetFromContext() override;
TypeId GetInputType(const AnfNodePtr &node, size_t i) override;
TypeId GetOutputType(const AnfNodePtr &node, size_t i) override;
TypeId GetInputInferType(const AnfNodePtr &node, size_t i) override;
TypeId GetOutputInferType(const AnfNodePtr &node, size_t i) override;
void SetGraphKernelNodeKernelInfo(const AnfNodePtr &node) override;
void SetBasicNodeKernelInfo(const AnfNodePtr &node, const std::vector<inner::NodeBase> &outputs_info) override;
void SetEmptyKernelInfo(const AnfNodePtr &node) override;

View File

@ -54,7 +54,7 @@ std::set<int64_t> GetUniqReduceAxes(const AnfNodePtr &node, bool is_ascend = fal
if (axis_vec.empty()) {
axis_vec.resize(src_shape_vec.size());
for (size_t i = 0; i < src_shape_vec.size(); ++i) {
axis_vec[i] = i;
axis_vec[i] = SizeToLong(i);
}
} else {
(void)std::transform(axis_vec.begin(), axis_vec.end(), axis_vec.begin(), [&src_shape_vec](int64_t axis) -> int64_t {

View File

@ -626,7 +626,7 @@ std::tuple<std::vector<bool>, std::vector<ParallelInfo>> ParallelOpFusion::Searc
std::vector<size_t> indices;
for (size_t i = 0; i < cs.size(); ++i) {
if (cs[i]) {
origin_indices[cs[i]] = i;
origin_indices[cs[i]] = SizeToInt(i);
indices.push_back(i);
}
}
@ -646,7 +646,7 @@ std::tuple<std::vector<bool>, std::vector<ParallelInfo>> ParallelOpFusion::Searc
std::map<AnfNodePtr, int> sorted_indices;
for (size_t i = 0; i < candidates.size(); ++i) {
sorted_indices[candidates[i]] = i;
sorted_indices[candidates[i]] = SizeToInt(i);
}
return DoSearchInSortedCandidates(cs.size(), candidates, &origin_indices, &sorted_indices);

View File

@ -128,7 +128,7 @@ void Area::FuseInput(const AreaPtr &input_area) {
if (iter == inputs_with_relation_.end()) {
MS_LOG(EXCEPTION) << "The area " << input_area->ToString() << " should be the input of area " << this->ToString();
}
auto input_idx = IntToSize(iter - inputs_with_relation_.begin());
auto input_idx = LongToSize(iter - inputs_with_relation_.begin());
if (input_area->is_output_) {
is_output_ = true;

View File

@ -43,11 +43,11 @@ bool UssAtomicAdd::Run(const FuncGraphPtr &func_graph) {
kernel_graph->set_manager(mng);
}
bool changed = false;
bool has_change = false;
std::shared_ptr<AtomicAddChecker> checker =
std::make_shared<UssChecker>(std::make_shared<Primitive>("UnsortedSegmentSum"));
if (checker == nullptr) {
return changed;
return has_change;
}
auto topo_nodes = TopoSort(kernel_graph->get_return());
@ -57,14 +57,14 @@ bool UssAtomicAdd::Run(const FuncGraphPtr &func_graph) {
}
auto atomic_add_infos = checker->GetAtomicAddInfo();
InsertAtomicClean(kernel_graph, node, atomic_add_infos, mng);
changed = true;
has_change = true;
}
if (changed) {
if (has_change) {
mng->RemoveRoots();
mng->KeepRoots({func_graph});
}
return changed;
return has_change;
}
} // namespace mindspore::graphkernel

View File

@ -42,7 +42,7 @@ class CustomActorNodeManager {
static CustomActorNodeManager &Instance();
void Reset() { custom_nodes_map_.clear(); }
void Register(const AnfNodePtr &node, const RelatedCustomActorNode &custom_nodes) {
custom_nodes_map_.emplace(node, custom_nodes);
(void)custom_nodes_map_.emplace(node, custom_nodes);
}
bool IsRegistered(const AnfNodePtr &node) const { return custom_nodes_map_.find(node) != custom_nodes_map_.end(); }
const RelatedCustomActorNode &GetCustomActorNodes(const AnfNodePtr &node) const {

View File

@ -44,7 +44,7 @@ void InsertDepend(const FuncGraphPtr &g, const AnfNodePtr &prev, const AnfNodePt
MS_EXCEPTION_IF_NULL(prev);
MS_EXCEPTION_IF_NULL(next);
MS_EXCEPTION_IF_NULL(depend_nodes);
static std::set<DependPair, DependPairCmp> added_set;
static std::set<DependPair, DependPairCmp> added_set = std::set<DependPair, DependPairCmp>();
DependPair cur_pair = std::make_pair(prev, next);
if (added_set.count(cur_pair) > 0) {
@ -56,7 +56,7 @@ void InsertDepend(const FuncGraphPtr &g, const AnfNodePtr &prev, const AnfNodePt
std::vector<AnfNodePtr>{NewValueNode(std::make_shared<Primitive>(prim::kPrimDepend->name())), next, prev});
MS_EXCEPTION_IF_NULL(depend_node);
depend_nodes->push_back(depend_node);
added_set.insert(cur_pair);
(void)added_set.insert(cur_pair);
}
bool LinkInternalOp(const FuncGraphPtr &g, const AnfNodePtr &node, AnfNodePtrList *depend_nodes) {
@ -127,7 +127,7 @@ bool LinkDependSync(const FuncGraphPtr &g, const CNodePtr &cnode, AnfNodePtrList
}
for (auto depend_index : dynamic_shape_depends) {
auto prev = common::AnfAlgo::GetPrevNodeOutput(cnode, depend_index);
auto prev = common::AnfAlgo::GetPrevNodeOutput(cnode, LongToSize(depend_index));
const auto &prev_node = prev.first;
if (prev_node == nullptr || !CustomActorNodeManager::Instance().IsRegistered(prev_node)) {
continue;
@ -174,7 +174,7 @@ void AttachDependNodes(const FuncGraphPtr &g, const AnfNodePtrList &depend_nodes
// New MakeTuple node
auto mk_inputs = AnfNodePtrList{NewValueNode(std::make_shared<Primitive>(prim::kPrimMakeTuple->name())),
return_node->input(kFirstDataInputIndex)};
mk_inputs.insert(mk_inputs.end(), depend_nodes.begin(), depend_nodes.end());
(void)mk_inputs.insert(mk_inputs.end(), depend_nodes.begin(), depend_nodes.end());
auto make_tuple_node = g->NewCNode(mk_inputs);
// Get first element item form that maketuple and return.