diff --git a/mindspore/ccsrc/cxx_api/model/ms/ms_model.cc b/mindspore/ccsrc/cxx_api/model/ms/ms_model.cc index fb27309c0e7..41b047fd684 100644 --- a/mindspore/ccsrc/cxx_api/model/ms/ms_model.cc +++ b/mindspore/ccsrc/cxx_api/model/ms/ms_model.cc @@ -68,7 +68,7 @@ std::shared_ptr MsModel::GenerateGraphCell(const std::vectorDebugString(); return nullptr; } - shape_ptr->shape() = dims[i]; + shape_ptr->set_shape(dims[i]); } auto graph = std::make_shared(std::make_shared(func_graph, ModelType::kMindIR)); diff --git a/mindspore/ccsrc/frontend/optimizer/graph_transform.h b/mindspore/ccsrc/frontend/optimizer/graph_transform.h index dff7e700063..6b4e00d250d 100644 --- a/mindspore/ccsrc/frontend/optimizer/graph_transform.h +++ b/mindspore/ccsrc/frontend/optimizer/graph_transform.h @@ -99,6 +99,8 @@ class GraphTupleParamTransform { mng->AddFuncGraph(new_fg); return new_fg; } + + private: std::unordered_map cache_; }; } // namespace opt diff --git a/mindspore/ccsrc/pybind_api/random_normal/random_cpu_kernel.h b/mindspore/ccsrc/pybind_api/random_normal/random_cpu_kernel.h index fb55b941c93..42c7be7eab3 100644 --- a/mindspore/ccsrc/pybind_api/random_normal/random_cpu_kernel.h +++ b/mindspore/ccsrc/pybind_api/random_normal/random_cpu_kernel.h @@ -29,8 +29,6 @@ class NormalDistribution; template class NormalDistribution { public: - std::array result; - bool UInt32ToFloat32(uint32_t input, float *output) { const uint32_t temp_value = input & 0x7fffffu; const uint32_t exp = static_cast(127); @@ -55,11 +53,14 @@ class NormalDistribution { const float threshold = 1.0e-7f; temp[0] = temp[0] < threshold ? threshold : temp[0]; temp[1] = temp[1] < threshold ? threshold : temp[1]; - result[i] = sqrt(-2.0 * log(temp[0])) * sin(2 * PI * temp[1]); - result[i + 1] = sqrt(-2.0 * log(temp[0])) * cos(2 * PI * temp[1]); + result_[i] = sqrt(-2.0 * log(temp[0])) * sin(2 * PI * temp[1]); + result_[i + 1] = sqrt(-2.0 * log(temp[0])) * cos(2 * PI * temp[1]); } - return result; + return result_; } + + private: + std::array result_; }; template diff --git a/mindspore/core/abstract/dshape.h b/mindspore/core/abstract/dshape.h index 04424937bd5..071c3cd1a16 100644 --- a/mindspore/core/abstract/dshape.h +++ b/mindspore/core/abstract/dshape.h @@ -77,13 +77,15 @@ class Shape : public BaseShape { bool operator==(const BaseShape &other) const override; BaseShapePtr Clone() const override { return std::make_shared(shape_, min_shape_, max_shape_); } void Broaden() override; - ShapeVector &shape() { return shape_; } - ShapeVector &min_shape() { return min_shape_; } - ShapeVector &max_shape() { return max_shape_; } + void set_shape(const ShapeVector &shape) { shape_ = shape; } + const ShapeVector &shape() { return shape_; } + const ShapeVector &min_shape() { return min_shape_; } + const ShapeVector &max_shape() { return max_shape_; } bool IsDynamic() const override { return std::any_of(shape_.begin(), shape_.end(), [](int64_t s) { return s < 0; }); } + private: ShapeVector shape_; // use SHP_ANY to implement the any shape in python ShapeVector min_shape_; // record minimum length for each dynamic dimension ShapeVector max_shape_; // record maximum length for each dynamic dimension diff --git a/mindspore/core/utils/info.cc b/mindspore/core/utils/info.cc index 2cd0e03f567..ace9a09a911 100644 --- a/mindspore/core/utils/info.cc +++ b/mindspore/core/utils/info.cc @@ -88,9 +88,9 @@ void TraceContext::ProcessAttributeFromContext() { // if there is trace context, get info from previous context if (!TraceManager::trace_context_stack_.empty()) { TraceContextPtr top = TraceManager::trace_context_stack_.top(); - trace_info_ = top->trace_info_; - location_ = top->location_; - func_name_ = top->func_name_; + trace_info_ = top->trace_info(); + location_ = top->location(); + func_name_ = top->func_name(); } } diff --git a/mindspore/core/utils/info.h b/mindspore/core/utils/info.h index 64a43c0cdcd..a40df6baae3 100644 --- a/mindspore/core/utils/info.h +++ b/mindspore/core/utils/info.h @@ -97,14 +97,6 @@ class TraceGuard { }; class TraceContext { - public: - LocationPtr location_; - TraceInfoPtr trace_info_; - std::string func_name_; - - protected: - void ProcessAttributeFromContext(); - public: ~TraceContext() = default; explicit TraceContext(const LocationPtr &loc) { @@ -125,6 +117,14 @@ class TraceContext { TraceInfoPtr trace_info() const { return trace_info_; } void set_func_name(const std::string &func_name) { func_name_ = func_name; } std::string func_name() { return func_name_; } + + protected: + void ProcessAttributeFromContext(); + + private: + LocationPtr location_; + TraceInfoPtr trace_info_; + std::string func_name_; }; class DebugInfo : public Base { @@ -200,6 +200,8 @@ class NodeDebugInfo : public DebugInfo { std::shared_ptr get_node() const { return node_.lock(); } void set_py_func_belonged(const std::string &name) { py_func_belonged_ = name; } std::string get_python_func_belonged() override { return py_func_belonged_; } + + private: AnfNodeWeakPtr node_; std::string py_func_belonged_; }; @@ -232,6 +234,8 @@ class GraphDebugInfo : public DebugInfo { std::string get_full_name() { return full_name_; } void set_deco_location(const LocationPtr &deco_list_loc); std::string get_python_func_belonged() override { return py_func_name_; } + + private: FuncGraphWeakPtr func_graph_; LocationPtr deco_loc_; std::string py_func_name_; diff --git a/mindspore/core/utils/trace_info.h b/mindspore/core/utils/trace_info.h index cead985992c..e9b29c7b478 100644 --- a/mindspore/core/utils/trace_info.h +++ b/mindspore/core/utils/trace_info.h @@ -258,6 +258,8 @@ class TraceSpecialize : public TraceInfo { std::string full_name() const override { return full_name_ + counter_ + "_"; } ~TraceSpecialize() override = default; TraceInfoPtr clone() override { return std::make_shared(*shared_from_base()); } + + private: std::string counter_; };