From 78611b5d5be132ca4fdb798b23b9dbe19f5c0a85 Mon Sep 17 00:00:00 2001 From: wuyongkang Date: Thu, 13 Aug 2020 17:48:48 +0800 Subject: [PATCH] fix static check problems --- mindspore/ccsrc/debug/trace.cc | 1 - .../ccsrc/frontend/operator/composite/do_signature.cc | 6 +++--- mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.cc | 4 ---- mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.h | 2 -- .../frontend/optimizer/irpass/arithmetic_simplify.cc | 1 - .../ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h | 1 - .../ccsrc/frontend/optimizer/irpass/branch_culling.h | 1 - .../frontend/optimizer/irpass/mark_interface_fusion.h | 2 -- .../frontend/optimizer/irpass/special_op_eliminate.h | 1 - .../ccsrc/frontend/optimizer/irpass/symbol_resolver.h | 2 -- .../frontend/optimizer/irpass/value_based_eliminate.cc | 1 - .../frontend/optimizer/irpass/value_based_eliminate.h | 1 - mindspore/ccsrc/frontend/optimizer/pass_group.cc | 1 - mindspore/ccsrc/frontend/optimizer/pattern.h | 8 ++++++++ mindspore/ccsrc/utils/utils.h | 1 - mindspore/ccsrc/vm/backend.cc | 1 + mindspore/ccsrc/vm/segment_runner.cc | 2 +- mindspore/core/abstract/prim_structures.cc | 1 - mindspore/core/c_ops/conv2d.h | 1 + mindspore/core/c_ops/primitive_c.h | 1 + mindspore/core/gvar/typeid_manager.cc | 2 -- mindspore/core/ir/graph_utils.h | 1 - mindspore/core/ir/meta_func_graph.cc | 1 - mindspore/core/ir/pattern_matcher.h | 7 ------- mindspore/core/ir/primitive.cc | 2 +- mindspore/core/ir/tensor.cc | 4 ++-- mindspore/core/utils/any.cc | 2 -- mindspore/core/utils/any.h | 1 - mindspore/core/utils/counter.h | 1 - mindspore/core/utils/log_adapter.cc | 1 - mindspore/core/utils/misc.h | 1 - mindspore/core/utils/ordered_set.h | 2 -- mindspore/core/utils/profile.cc | 1 - mindspore/core/utils/profile.h | 1 - mindspore/core/utils/symbolic.cc | 2 -- mindspore/core/utils/symbolic.h | 2 -- mindspore/core/utils/visible.h | 1 - 37 files changed, 18 insertions(+), 53 deletions(-) diff --git a/mindspore/ccsrc/debug/trace.cc b/mindspore/ccsrc/debug/trace.cc index 605d09ce7f..ecb1dca441 100644 --- a/mindspore/ccsrc/debug/trace.cc +++ b/mindspore/ccsrc/debug/trace.cc @@ -507,6 +507,5 @@ struct TraceProviderRegister { } ~TraceProviderRegister() = default; } trace_provider_regsiter; - } // namespace trace } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/operator/composite/do_signature.cc b/mindspore/ccsrc/frontend/operator/composite/do_signature.cc index 248e42cb5b..b5d17d2764 100644 --- a/mindspore/ccsrc/frontend/operator/composite/do_signature.cc +++ b/mindspore/ccsrc/frontend/operator/composite/do_signature.cc @@ -162,9 +162,9 @@ TypeId GetMaxTypeId(const abstract::AbstractBasePtrList &args_spec_list, std::ve } // Get the largest type of index in the same SignatureEnumDType of arguments. -std::map GetMaxDtype(const std::vector &dtypes, - const abstract::AbstractBasePtrList &args_spec_list, - const std::set &write_indices) { +using MaxTypeMap = std::map; +MaxTypeMap GetMaxDtype(const std::vector &dtypes, + const abstract::AbstractBasePtrList &args_spec_list, const std::set &write_indices) { // record index for signature.dtypes of the same type // eg. [T, T1, T, T2, T, T1, T3] -> {{T:(0,2,4)}, {T1:(1,5)}, {T2:(3)}, {T3:(6)}} std::map> type_indices; diff --git a/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.cc b/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.cc index ef526559e5..1bc00122d1 100644 --- a/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.cc +++ b/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.cc @@ -24,12 +24,10 @@ namespace mindspore { /* namespace to support opt */ namespace opt { - bool GraphKernelReuse::CompareNode(const AnfNodePtr a, const AnfNodePtr b) { if (a->abstract() && b->abstract()) { auto a_type = a->abstract()->GetTypeTrack(); auto b_type = b->abstract()->GetTypeTrack(); - if (a_type != b_type) { return false; } @@ -132,7 +130,6 @@ bool GraphKernelReuse::DoReplace(const FuncGraphManagerPtr manager) { manager->Replace(iter.first->first, new_cnode); changed = true; } - } else { // Add current fg to map graph_kernel_ops[key].push_back(fg); @@ -152,6 +149,5 @@ bool GraphKernelReuse::ReuseGraphKernel(const FuncGraphPtr root, const FuncGraph return DoReplace(manager); } - } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.h b/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.h index 0a786e8ead..fcfdcb02b0 100644 --- a/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.h +++ b/mindspore/ccsrc/frontend/optimizer/graph_kernel_reuse.h @@ -25,7 +25,6 @@ namespace mindspore { namespace opt { - // Common subexpression elimination. class GraphKernelReuse { public: @@ -46,7 +45,6 @@ class GraphKernelReuse { std::unordered_map> graph_kernel_ops; int count; }; - } // namespace opt } // namespace mindspore #endif // MINDSPORE_CCSRC_FRONTEND_OPTIMIZER_GRAPH_KERNEL_OP_REUSE_H diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.cc b/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.cc index 3a0e6f6e14..32172a3bb7 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.cc +++ b/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.cc @@ -147,7 +147,6 @@ void AdjustAllReduceMulAdd::ProcessDependEdge(const FuncGraphPtr &fg, const AnfN } } } - } // namespace irpass } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h b/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h index 177a66fb09..b9f0c284e9 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h @@ -62,7 +62,6 @@ class ArithmeticSimplify2 : public OptimizerCaller { public: AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override; }; - } // namespace irpass } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.h b/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.h index 72a6a4df9f..163d72ddab 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.h @@ -141,7 +141,6 @@ class ConvertSwitchReplacement : public OptimizerCaller { return nullptr; } }; - } // namespace irpass } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/mark_interface_fusion.h b/mindspore/ccsrc/frontend/optimizer/irpass/mark_interface_fusion.h index ffa383cc7a..ac635ca97b 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/mark_interface_fusion.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/mark_interface_fusion.h @@ -32,7 +32,6 @@ namespace mindspore { namespace opt { namespace irpass { - static int count = 0; std::string GetFusionNumber() { @@ -79,7 +78,6 @@ class MarkInterfaceFusion : public AnfVisitor { private: AnfNodePtr y_{nullptr}; }; - } // namespace irpass } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h index 09b54afb75..9ad50b8b33 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h @@ -203,7 +203,6 @@ class DependValueElim : public OptimizerCaller { return nullptr; } }; - } // namespace irpass } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/symbol_resolver.h b/mindspore/ccsrc/frontend/optimizer/irpass/symbol_resolver.h index e529c7ce04..16ce1088e9 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/symbol_resolver.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/symbol_resolver.h @@ -33,7 +33,6 @@ namespace mindspore { namespace opt { namespace irpass { - const char PARSE_SUPER_NAME[] = "namespace"; // {prim::kPrimResolve, Ns, Sym} @@ -108,7 +107,6 @@ class ResolveAttr : public OptimizerCaller { auto ns_ = GetValueNode(ns_node.GetNode(node)); auto sym_ = GetValueNode(sym_node.GetNode(node)); - if (ns_->module() == parse::RESOLVE_NAMESPACE_NAME_CLASS_MEMBER && sym_->symbol() != PARSE_SUPER_NAME) { // deal with the case of getting attr from a class member // and avoid the case of getting attr from self (the result of ParseSuper) diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.cc b/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.cc index 38b59afe96..4bbe3f671c 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.cc +++ b/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.cc @@ -122,7 +122,6 @@ AnfNodePtr ValueBasedEliminate::operator()(const OptimizerPtr &, const AnfNodePt return nullptr; } - } // namespace irpass } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.h index 3ae2d90a5c..56043c5f5f 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/value_based_eliminate.h @@ -30,7 +30,6 @@ namespace mindspore { namespace opt { namespace irpass { - // {prim::kPrimSelect, {prim::kPrimGreater, X, 0}, Y, Z}} -> Y when X is always greater than 0 // {prim::kPrimMaximum, X, Y} -> X when Y is smaller than LOWER_FLT_LIMIT // {prim::kPrimMinimum, X, Y} -> X when Y is greater than UPPER_FLT_LIMIT diff --git a/mindspore/ccsrc/frontend/optimizer/pass_group.cc b/mindspore/ccsrc/frontend/optimizer/pass_group.cc index 3619396215..7f7544c41e 100644 --- a/mindspore/ccsrc/frontend/optimizer/pass_group.cc +++ b/mindspore/ccsrc/frontend/optimizer/pass_group.cc @@ -63,7 +63,6 @@ bool PassGroup::Run(const FuncGraphPtr &func_graph) const { } return changed; } - } // namespace python_pass } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/pattern.h b/mindspore/ccsrc/frontend/optimizer/pattern.h index 189a437846..4dd94bfeba 100644 --- a/mindspore/ccsrc/frontend/optimizer/pattern.h +++ b/mindspore/ccsrc/frontend/optimizer/pattern.h @@ -49,6 +49,7 @@ using PatternNodeMap = std::unordered_map prims, string name, bool should_replace) : primitives_(prims), name_(name), matched_prim_(nullptr) { unique_name_ = std::to_string(g_id_++) + "_" + name; @@ -120,6 +122,7 @@ class IsPrimTypeOf : public Pattern { class CallWith : public Pattern { public: CallWith() { unique_name_ = std::to_string(g_id_++); } + ~CallWith() = default; CallWith(PatternPtr prim_pattern, vector inputs, bool should_replace) { // NOTE: should_replace is ignored in this case, since each sub-pattern has its own setting prim_pattern_ = prim_pattern; @@ -154,6 +157,7 @@ class CallWith : public Pattern { class IsIn : public Pattern { public: IsIn() { unique_name_ = std::to_string(g_id_++); } + ~IsIn() = default; explicit IsIn(vector patterns) : patterns_(patterns) { unique_name_ = std::to_string(g_id_++); for (auto &iter : patterns) { @@ -170,6 +174,7 @@ class IsIn : public Pattern { class IsNot : public Pattern { public: IsNot() { unique_name_ = std::to_string(g_id_++); } + ~IsNot() = default; explicit IsNot(vector patterns) : patterns_(patterns) { unique_name_ = std::to_string(g_id_++); for (auto &iter : patterns) { @@ -186,6 +191,7 @@ class IsNot : public Pattern { class AnyPattern : public Pattern { public: AnyPattern() { unique_name_ = std::to_string(g_id_++) + "_AnyPattern"; } + ~AnyPattern() = default; MS_DECLARE_PARENT(AnyPattern, Pattern); MatchResultPtr match(const AnfNodePtr &node) override; }; @@ -193,6 +199,7 @@ class AnyPattern : public Pattern { class NewTensor : public Pattern { public: NewTensor() { unique_name_ = std::to_string(g_id_++); } + ~NewTensor() = default; explicit NewTensor(tensor::TensorPtr input_tensor) : input_tensor_(input_tensor) { should_replace_ = false; } MS_DECLARE_PARENT(NewTensor, Pattern); MatchResultPtr match(const AnfNodePtr &node) override { @@ -207,6 +214,7 @@ class NewTensor : public Pattern { class MatchResult { public: MatchResult() {} + ~MatchResult() = default; void add_entry(PatternPtr pattern, AnfNodePtr node) { match_result_[pattern] = node; } PatternNodeMap _result() { return match_result_; } AnfNodePtr get_node(const PatternPtr &pattern); diff --git a/mindspore/ccsrc/utils/utils.h b/mindspore/ccsrc/utils/utils.h index 8b8c22adbc..dcd1d84a2e 100644 --- a/mindspore/ccsrc/utils/utils.h +++ b/mindspore/ccsrc/utils/utils.h @@ -386,6 +386,5 @@ static inline uint64_t GetCurrentUSec() { do { \ MS_LOG(INFO) << #stage << " called " << count_##stage << " times, costs " << total_##stage << " usec."; \ } while (0) - } // namespace mindspore #endif // MINDSPORE_CCSRC_UTILS_UTILS_H_ diff --git a/mindspore/ccsrc/vm/backend.cc b/mindspore/ccsrc/vm/backend.cc index 42af5541f2..b94c275596 100644 --- a/mindspore/ccsrc/vm/backend.cc +++ b/mindspore/ccsrc/vm/backend.cc @@ -146,6 +146,7 @@ void MsBackend::Link(GraphId graph_id) { Backend::Backend(const std::string &name) : name_(name) { MS_LOG(DEBUG) << "select backend:" << name; convert_fn_ = backends[name_]; + is_multi_graph_sink_ = false; } MsBackend::MsBackend(const std::string &name, const std::string &target, uint32_t device_id) : Backend(name) { diff --git a/mindspore/ccsrc/vm/segment_runner.cc b/mindspore/ccsrc/vm/segment_runner.cc index 141adc1bff..c264d419b7 100644 --- a/mindspore/ccsrc/vm/segment_runner.cc +++ b/mindspore/ccsrc/vm/segment_runner.cc @@ -80,7 +80,7 @@ AnfNodePtrList GetOutput(const AnfNodePtrList &lst, const NodeUsersMap &users, c } namespace { -AnfNodePtr RefSubGraphNode(const FuncGraphPtr &fg, const AnfNodePtr &node, AnfNodePtrList *inputs_ptr, +AnfNodePtr RefSubGraphNode(const FuncGraphPtr &fg, const AnfNodePtr &node, AnfNodePtrList *const inputs_ptr, AnfNodePtrToAnfNodePtrMap *eqv_ptr) { MS_EXCEPTION_IF_NULL(fg); MS_EXCEPTION_IF_NULL(inputs_ptr); diff --git a/mindspore/core/abstract/prim_structures.cc b/mindspore/core/abstract/prim_structures.cc index 8cdfc5d20f..c218ecdcb8 100644 --- a/mindspore/core/abstract/prim_structures.cc +++ b/mindspore/core/abstract/prim_structures.cc @@ -215,7 +215,6 @@ AbstractBasePtr InferImplDictGetItem(const AnalysisEnginePtr &, const PrimitiveP std::vector dict_elems = dict->elements(); auto it = std::find_if(dict_elems.begin(), dict_elems.end(), [key_str](const AbstractAttribute &item) { return item.first == key_str; }); - if (it == dict_elems.end()) { MS_LOG(EXCEPTION) << "The key " << key_str << " does not exist in the dict:" << args_spec_list[0]->ToString(); } diff --git a/mindspore/core/c_ops/conv2d.h b/mindspore/core/c_ops/conv2d.h index 89b5259fc7..7e70937a50 100644 --- a/mindspore/core/c_ops/conv2d.h +++ b/mindspore/core/c_ops/conv2d.h @@ -30,6 +30,7 @@ namespace mindspore { class Conv2d : public PrimitiveC { public: Conv2d(); + ~Conv2d() = default; void Init(int out_channel, const std::vector &kernel_size, int mode = 1, const std::string &pad_mode = "valid", const std::vector &pad = {0, 0, 0, 0}, const std::vector &stride = {1, 1, 1, 1}, const std::vector &dilation = {1, 1, 1, 1}, int group = 1); diff --git a/mindspore/core/c_ops/primitive_c.h b/mindspore/core/c_ops/primitive_c.h index a006eb9aca..b1ee808de6 100644 --- a/mindspore/core/c_ops/primitive_c.h +++ b/mindspore/core/c_ops/primitive_c.h @@ -27,6 +27,7 @@ namespace mindspore { class PrimitiveC : public Primitive { public: explicit PrimitiveC(const std::string &name) : Primitive(name) {} + ~PrimitiveC() = default; AbstractBasePtr Infer(const AbstractBasePtrList &abstract_list); protected: diff --git a/mindspore/core/gvar/typeid_manager.cc b/mindspore/core/gvar/typeid_manager.cc index bc74f3a0df..9f73086c7d 100644 --- a/mindspore/core/gvar/typeid_manager.cc +++ b/mindspore/core/gvar/typeid_manager.cc @@ -23,10 +23,8 @@ #include "base/base.h" namespace mindspore { - struct TypeIdManager *TypeIdManager::Get() { static TypeIdManager manager; return &manager; } - } // namespace mindspore diff --git a/mindspore/core/ir/graph_utils.h b/mindspore/core/ir/graph_utils.h index 1e915db47c..b1b42fea6d 100644 --- a/mindspore/core/ir/graph_utils.h +++ b/mindspore/core/ir/graph_utils.h @@ -35,7 +35,6 @@ #include "utils/label.h" namespace mindspore { - enum IncludeType { FOLLOW, NOFOLLOW, EXCLUDE }; using IncludeFunc = std::function; diff --git a/mindspore/core/ir/meta_func_graph.cc b/mindspore/core/ir/meta_func_graph.cc index 141b495a37..9aefcac52c 100644 --- a/mindspore/core/ir/meta_func_graph.cc +++ b/mindspore/core/ir/meta_func_graph.cc @@ -23,7 +23,6 @@ // namespace to support intermediate representation definition namespace mindspore { - abstract::AbstractBasePtr MetaFuncGraph::ToAbstract() { return std::make_shared(shared_from_base()); } diff --git a/mindspore/core/ir/pattern_matcher.h b/mindspore/core/ir/pattern_matcher.h index b04fbed11f..2ba5730d45 100644 --- a/mindspore/core/ir/pattern_matcher.h +++ b/mindspore/core/ir/pattern_matcher.h @@ -579,7 +579,6 @@ class PConstant : public PBase > { if (!node->isa()) { return nullptr; } - auto value = node->cast()->value(); if (!value->isa()) { @@ -622,7 +621,6 @@ class PConstant : public PBase > { } auto x_abstract = x->abstract()->cast(); std::vector x_shape = x_abstract->shape()->shape(); - if (x_shape != tensor_shape) { return nullptr; } @@ -638,7 +636,6 @@ class PConstant : public PBase > { } auto x_tensor_ptr = dyn_cast(x_value); - if ((x_tensor_ptr->DataSize() > 1) && (x_tensor_ptr->DataSize() != new_tensor_ptr->DataSize())) { return nullptr; } @@ -729,7 +726,6 @@ class PConstant : public PBase > { auto value_1 = GetValueNode(vnode_1); auto value_2 = GetValueNode(vnode_2); - if (!value_1->isa() || !value_2->isa()) { return nullptr; } @@ -744,14 +740,12 @@ class PConstant : public PBase > { TypePtr tensor_1_type_ptr = tensor_1_abstract->element()->BuildType(); TypePtr tensor_2_type_ptr = tensor_2_abstract->element()->BuildType(); TypePtr tensor_3_type_ptr = tensor_3_abstract->element()->BuildType(); - if ((tensor_1_type_ptr->type_id() != tensor_3_type_ptr->type_id()) || (tensor_2_type_ptr->type_id() != tensor_3_type_ptr->type_id())) { return nullptr; } std::vector tensor_out_shape = tensor_3_abstract->shape()->shape(); - int data_out_size = std::accumulate(tensor_out_shape.begin(), tensor_out_shape.end(), 1, std::multiplies()); if ((tensor_ptr_1->DataSize() > 1) && (tensor_ptr_1->DataSize() != data_out_size)) { @@ -872,7 +866,6 @@ BIN_OPERATION_PATTERN(operator*, prim::kPrimMul, true); return rep; \ } \ } - } // namespace mindspore #endif // MINDSPORE_CORE_IR_PATTERN_MATCHER_H_ diff --git a/mindspore/core/ir/primitive.cc b/mindspore/core/ir/primitive.cc index 07e43cf54e..1e690d7b47 100644 --- a/mindspore/core/ir/primitive.cc +++ b/mindspore/core/ir/primitive.cc @@ -20,7 +20,6 @@ #include "abstract/abstract_function.h" namespace mindspore { - static std::string MakeId() { // Use atomic to make id generator thread safe. static std::atomic last_id{1}; @@ -44,6 +43,7 @@ Primitive::Primitive(const Primitive &prim) has_signature_(prim.has_signature_), prim_type_(prim.prim_type_), record_evaluate_add_attr_(false), + is_const_value_(false), id_(prim.id_) {} abstract::AbstractBasePtr Primitive::ToAbstract() { diff --git a/mindspore/core/ir/tensor.cc b/mindspore/core/ir/tensor.cc index edcabc67be..5fd309d1e5 100644 --- a/mindspore/core/ir/tensor.cc +++ b/mindspore/core/ir/tensor.cc @@ -81,7 +81,7 @@ std::unique_ptr NewData(Scalar scalar) { } template -std::unique_ptr CopyData(const std::vector &shape, void *data, TypeId data_type) { +std::unique_ptr CopyData(const std::vector &shape, void *const data, TypeId data_type) { const size_t size = SizeOf(shape); switch (data_type) { case kNumberTypeBool: @@ -136,7 +136,7 @@ std::unique_ptr CopyData(const std::vector &shape, void *data, TypeId } template -std::unique_ptr CopyData(const std::vector &shape, void *data, size_t data_len) { +std::unique_ptr CopyData(const std::vector &shape, void *const data, size_t data_len) { size_t size = SizeOf(shape); if (size * sizeof(T) != data_len) { MS_LOG(EXCEPTION) << "Incorrect tensor input data length " << data_len << ", expect " << size * sizeof(T) diff --git a/mindspore/core/utils/any.cc b/mindspore/core/utils/any.cc index 8f4039922c..190ec84ebb 100644 --- a/mindspore/core/utils/any.cc +++ b/mindspore/core/utils/any.cc @@ -19,7 +19,6 @@ #include namespace mindspore { - // only support (int, float, bool) as Literal bool AnyIsLiteral(const Any &any) { static const std::type_index typeid_int = std::type_index(typeid(int)); @@ -53,5 +52,4 @@ Any &Any::operator=(Any &&other) { } return *this; } - } // namespace mindspore diff --git a/mindspore/core/utils/any.h b/mindspore/core/utils/any.h index 20a20ed006..966b9df30f 100644 --- a/mindspore/core/utils/any.h +++ b/mindspore/core/utils/any.h @@ -208,7 +208,6 @@ struct AnyLess { }; bool AnyIsLiteral(const Any &any); - } // namespace mindspore #endif // MINDSPORE_CORE_UTILS_ANY_H_ diff --git a/mindspore/core/utils/counter.h b/mindspore/core/utils/counter.h index f70271d37f..342f4589f5 100644 --- a/mindspore/core/utils/counter.h +++ b/mindspore/core/utils/counter.h @@ -20,7 +20,6 @@ #include "utils/ordered_map.h" namespace mindspore { - template , class Equal = std::equal_to> class Counter { using counter_type = Counter; diff --git a/mindspore/core/utils/log_adapter.cc b/mindspore/core/utils/log_adapter.cc index 070de0351d..033c4280fe 100644 --- a/mindspore/core/utils/log_adapter.cc +++ b/mindspore/core/utils/log_adapter.cc @@ -395,7 +395,6 @@ class LogConfigParser { bool flag_error = false; std::string text; auto tok = lexer.GetNext(&text); - // empty string if (tok == LogConfigToken::EOS) { return log_levels; diff --git a/mindspore/core/utils/misc.h b/mindspore/core/utils/misc.h index 9fae5abbcf..7c63fb299e 100644 --- a/mindspore/core/utils/misc.h +++ b/mindspore/core/utils/misc.h @@ -33,6 +33,5 @@ extern const int RET_BREAK; // demangle the name to make it human reablable. extern std::string demangle(const char *name); - } // namespace mindspore #endif // MINDSPORE_CORE_UTILS_MISC_H_ diff --git a/mindspore/core/utils/ordered_set.h b/mindspore/core/utils/ordered_set.h index ee3aef46f3..5336ceb38c 100644 --- a/mindspore/core/utils/ordered_set.h +++ b/mindspore/core/utils/ordered_set.h @@ -30,7 +30,6 @@ #include "utils/log_adapter.h" namespace mindspore { - // Implementation of OrderedSet that keeps insertion order // using map as set, and use list as a sequential container to record elements to keep insertion order template , class KeyEqual = std::equal_to> @@ -277,7 +276,6 @@ class OrderedSet { map_type mapped_data_; sequential_type ordered_data_; }; - } // namespace mindspore #endif // MINDSPORE_CORE_UTILS_ORDERED_SET_H_ diff --git a/mindspore/core/utils/profile.cc b/mindspore/core/utils/profile.cc index 384c2511a3..39e92983f3 100644 --- a/mindspore/core/utils/profile.cc +++ b/mindspore/core/utils/profile.cc @@ -361,5 +361,4 @@ void MsProfile::Print() { (void)printf("\nTime group info:\n%s", text.c_str()); (void)fflush(stdout); } - } // namespace mindspore diff --git a/mindspore/core/utils/profile.h b/mindspore/core/utils/profile.h index 4478e236b8..3651a6ae59 100644 --- a/mindspore/core/utils/profile.h +++ b/mindspore/core/utils/profile.h @@ -221,7 +221,6 @@ class MsProfile { std::map time_stat_; // record time and count info from some activity ProfileBase *profile_ = nullptr; // record hierarchical profile info }; - } // namespace mindspore #ifdef ENABLE_PROFILE diff --git a/mindspore/core/utils/symbolic.cc b/mindspore/core/utils/symbolic.cc index 8ad16e50c8..4bc20ff617 100644 --- a/mindspore/core/utils/symbolic.cc +++ b/mindspore/core/utils/symbolic.cc @@ -21,7 +21,6 @@ #include namespace mindspore { - std::ostream &operator<<(std::ostream &out, const std::shared_ptr &objPtr) { out << "("; MS_EXCEPTION_IF_NULL(objPtr); @@ -50,5 +49,4 @@ bool EnvInstance::operator==(const Value &other) const { return false; } std::shared_ptr newenv = std::make_shared(); - } // namespace mindspore diff --git a/mindspore/core/utils/symbolic.h b/mindspore/core/utils/symbolic.h index 903d25794e..d6cd7c0bce 100644 --- a/mindspore/core/utils/symbolic.h +++ b/mindspore/core/utils/symbolic.h @@ -29,7 +29,6 @@ #include "abstract/abstract_value.h" namespace mindspore { - class SymbolicKeyInstance : public Value { public: SymbolicKeyInstance(const AnfNodePtr &node, const abstract::AbstractBasePtr &abstract) @@ -168,7 +167,6 @@ class EnvInstance : public Value { using EnvInstancePtr = std::shared_ptr; extern std::shared_ptr newenv; - } // namespace mindspore #endif // MINDSPORE_CORE_UTILS_SYMBOLIC_H_ diff --git a/mindspore/core/utils/visible.h b/mindspore/core/utils/visible.h index b206876d3e..afa9b4a46b 100644 --- a/mindspore/core/utils/visible.h +++ b/mindspore/core/utils/visible.h @@ -38,7 +38,6 @@ namespace mindspore { #define MS_EXPORT __attribute__((visibility("default"))) #define MS_LOCAL __attribute__((visibility("hidden"))) #endif - } // namespace mindspore #endif // MINDSPORE_CORE_UTILS_VISIBLE_H_