!29153 fix code check

Merge pull request !29153 from lianliguang/master
This commit is contained in:
i-robot 2022-01-17 12:30:34 +00:00 committed by Gitee
commit 446ac59181
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 32 additions and 32 deletions

View File

@ -24,6 +24,7 @@
"mindspore/mindspore/ccsrc/runtime/hccl_adapter/hccl_adapter.cc" "useStlAlgorithm"
"mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/cast_gpu_kernel.cc" "unknownMacro"
"mindspore/mindspore/ccsrc/runtime/device/ascend/ascend_memory_manager.cc" "nullPointerArithmeticRedundantCheck"
"mindspore/mindspore/ccsrc/pipeline/jit/static_analysis/auto_monad.cc" "containerOutOfBounds"
# MindData
"mindspore/mindspore/ccsrc/minddata/dataset/engine/dataset_iterator.cc" "useStlAlgorithm"

View File

@ -836,7 +836,7 @@ REGISTER_PRIMITIVE_FRONT_EVAL_IMPL(J, prim::kPrimJ, InferImplJ, nullptr);
REGISTER_PRIMITIVE_FRONT_EVAL_IMPL(Shard, prim::kPrimShard, InferImplShard, nullptr);
REGISTER_PRIMITIVE_FRONT_EVAL_IMPL(BroadcastGradientArgs, prim::kPrimBroadcastGradientArgs,
InferImplBroadcastGradientArgs, nullptr);
REGISTER_PRIMITIVE_FRONT_EVAL_IMPL(MakeSiice, prim::kPrimMakeSlice, InferImplMakeSlice, nullptr);
REGISTER_PRIMITIVE_FRONT_EVAL_IMPL(MakeSlice, prim::kPrimMakeSlice, InferImplMakeSlice, nullptr);
REGISTER_PRIMITIVE_FRONT_EVAL_IMPL(SliceGetItem, prim::kPrimSliceGetItem, InferImplSliceGetItem, nullptr);
} // namespace abstract
} // namespace mindspore

View File

@ -84,9 +84,9 @@ class Resource : public ResourceBase {
loop_size_ = size;
}
void set_is_load(bool flag) { is_load_ = flag; }
bool is_load() { return is_load_; }
bool vm_loop_flag() { return vm_loop_flag_; }
int64_t loop_size() { return loop_size_; }
bool is_load() const { return is_load_; }
bool vm_loop_flag() const { return vm_loop_flag_; }
int64_t loop_size() const { return loop_size_; }
void set_layout_map(const LayoutMap &layout_map) { layout_map_ = layout_map; }
const LayoutMap &get_layout_map() const { return layout_map_; }

View File

@ -295,7 +295,7 @@ class AsyncInferTask {
static AsyncInferTaskPtr MakeShared(const AsyncAbstractPtr &abstract, const std::string &thread = "") {
std::string thread_id = thread;
if (thread_id == "") {
thread_id = AnalysisSchedule::GetInstance().thread_id();
thread_id = AnalysisSchedule::thread_id();
}
MS_EXCEPTION_IF_NULL(abstract);
auto ret = std::make_shared<AsyncInferTask>(thread_id, abstract);
@ -388,10 +388,10 @@ class EvaluatorCacheMgr {
~EvaluatorCacheMgr() = default;
void Clear() { eval_result_cache_.clear(); }
const EvalResultCache &GetCache() { return eval_result_cache_; }
const EvalResultCache &GetCache() const { return eval_result_cache_; }
EvalResultPtr GetValue(const AbstractBasePtrList &key) { return eval_result_cache_.get(key); }
void SetValue(const AbstractBasePtrList &key, const EvalResultPtr &arg) { eval_result_cache_.set(key, arg); }
size_t GetSize() { return eval_result_cache_.size(); }
size_t GetSize() const { return eval_result_cache_.size(); }
private:
EvalResultCache eval_result_cache_;

View File

@ -616,7 +616,6 @@ class SideEffectFinder {
if (IsPrimitiveEquals(prim, prim::kPrimMakeTuple)) {
if (tuple_indexes->empty()) {
MS_LOG(EXCEPTION) << "Unexpected make_tuple: " << cnode->DebugString(2);
return {EffectInfo::kDetected, false, false, false};
}
// Pop out tuple index.
auto top_index = tuple_indexes->top();

View File

@ -73,7 +73,7 @@ class Evaluator : public Base {
return nullptr;
}
auto is_abstract = std::any_of(args_spec_list.begin(), args_spec_list.end(), [](auto &arg) {
auto is_abstract = std::any_of(args_spec_list.begin(), args_spec_list.end(), [](auto &arg) -> bool {
if (arg->BuildType()->type_id() == kObjectTypeUndeterminedType) {
return true;
}
@ -95,7 +95,7 @@ class Evaluator : public Base {
EvaluatorCacheMgrPtr evaluator_cache_mgr() const { return evaluator_cache_mgr_; }
EvaluatorAttrCachePtr attr_cache() const { return attr_cache_; }
std::recursive_timed_mutex &eval_lock() { return eval_lock_; }
const std::recursive_timed_mutex &eval_lock() { return eval_lock_; }
protected:
std::string identifier_;

View File

@ -89,7 +89,7 @@ class UniformPrimEvaluator final : public TrivialPrimEvaluator {
}
}
}
~UniformPrimEvaluator() override = default;
~UniformPrimEvaluator() override { impl_ = nullptr; };
MS_DECLARE_PARENT(UniformPrimEvaluator, TrivialPrimEvaluator);
EvalResultPtr EvalPrim(const AnalysisEnginePtr &engine, const AbstractBasePtrList &args) override;
@ -122,7 +122,7 @@ class DoSignatureEvaluator final : public Evaluator {
~DoSignatureEvaluator() override = default;
MS_DECLARE_PARENT(DoSignatureEvaluator, Evaluator);
EvalResultPtr Run(AnalysisEnginePtr engine, const ConfigPtrList &argrefs,
const AnfNodeConfigPtr &out_config = nullptr) override;
const AnfNodeConfigPtr &out_config) override;
EvalResultPtr Eval(AnalysisEnginePtr, const AbstractBasePtrList &, const AnfNodeConfigPtr &) override {
MS_LOG(EXCEPTION) << "Eval() should not be called, Run() method should be called";
@ -138,7 +138,7 @@ class UnpackGraphEvaluator final : public Evaluator {
~UnpackGraphEvaluator() override = default;
MS_DECLARE_PARENT(UnpackGraphEvaluator, Evaluator);
EvalResultPtr Run(AnalysisEnginePtr engine, const ConfigPtrList &argrefs,
const AnfNodeConfigPtr &out_config = nullptr) override;
const AnfNodeConfigPtr &out_config) override;
EvalResultPtr Eval(AnalysisEnginePtr, const AbstractBasePtrList &, const AnfNodeConfigPtr &) override {
MS_LOG(EXCEPTION) << "Eval() should not be called, Run() method should be called";
@ -155,7 +155,7 @@ class MixedPrecisionCastEvaluator final : public Evaluator {
~MixedPrecisionCastEvaluator() override = default;
MS_DECLARE_PARENT(MixedPrecisionCastEvaluator, Evaluator);
EvalResultPtr Run(AnalysisEnginePtr engine, const ConfigPtrList &argrefs,
const AnfNodeConfigPtr &out_config = nullptr) override;
const AnfNodeConfigPtr &out_config) override;
EvalResultPtr Eval(AnalysisEnginePtr, const AbstractBasePtrList &, const AnfNodeConfigPtr &) override {
MS_LOG(EXCEPTION) << "Eval() should not be called, Run() method should be called";

View File

@ -27,7 +27,6 @@
namespace mindspore {
namespace abstract {
class StackFrame;
using StackFramePtr = std::shared_ptr<StackFrame>;
using EvaluatorWeakPtr = std::weak_ptr<Evaluator>;
using BaseFuncGraphEvaluatorPtr = std::shared_ptr<BaseFuncGraphEvaluator>;
@ -65,7 +64,7 @@ class StackFrame final : public Base {
// Return back from branch func graph.
void Back(const AnalysisEnginePtr &engine, const StackFramePtr &last_stack_frame, const EvalResultPtr &eval_result);
bool Done() { return done_; }
bool Done() const { return done_; }
AnfNodePtr &CurrentNode() {
if (slot_index_ >= node_slots_.size()) {
@ -92,7 +91,7 @@ class StackFrame final : public Base {
AnalysisContextPtr current_context() const { return current_context_; }
AnalysisContextPtr parent_context() const { return parent_context_; }
const AbstractBasePtrList &args_abs_list() { return args_abs_list_; }
const AbstractBasePtrList &args_abs_list() const { return args_abs_list_; }
void set_args_abs_list(const AbstractBasePtrList &&args_abs_list) { args_abs_list_ = args_abs_list; }
std::string ToString() const override {

View File

@ -65,7 +65,7 @@ using AttrValueMapPtr = std::shared_ptr<AttrValueMap>;
// the class to save evaluated result: abstract value and modified attribute
class EvalResult : public Base {
public:
EvalResult(AbstractBasePtr abs, AttrValueMapPtr attr) : abstract_(abs), attribute_(attr) {}
EvalResult(const AbstractBasePtr &abs, const AttrValueMapPtr &attr) : abstract_(abs), attribute_(attr) {}
~EvalResult() override = default;
MS_DECLARE_PARENT(EvalResult, Base);
const AbstractBasePtr &abstract() { return abstract_; }
@ -292,7 +292,7 @@ class AnalysisEngine : public std::enable_shared_from_this<AnalysisEngine> {
forward_count_ = 0;
enable_recursive_eval_ = (common::GetEnv("MS_DEV_RECURSIVE_EVAL") == "1");
}
~AnalysisEngine() = default;
virtual ~AnalysisEngine() = default;
// func_graph: The func_graph to analyze.
// args_spec_list: The abstracted arguments for the func_graph. Must be a tuple of AbstractBase.

View File

@ -71,7 +71,7 @@ class PrimitivePy : public Primitive {
py::dict RunInfer(const py::tuple &args);
void RunCheck(const py::tuple &args);
py::object RunInferValue(const py::tuple &args);
bool HasPyObj() { return python_obj_.operator bool(); }
bool HasPyObj() const { return python_obj_.operator bool(); }
PrimitivePtr Clone() override;
PrimitivePyAdapterPtr adapter() const { return adapter_; }
void set_bprop_cls_name(const std::string &name) { bprop_cls_name_ = name; }
@ -102,7 +102,7 @@ class PrimitivePyAdapter {
void set_hook(const py::function &hook);
void set_instance_name(const std::string &s);
void set_attached_primitive(const PrimitivePyPtr &prim);
PrimitivePyPtr attached_primitive() { return attached_primitive_.lock(); }
PrimitivePyPtr attached_primitive() const { return attached_primitive_.lock(); }
std::string name() const { return name_; }
void set_name(const std::string &name) { name_ = name; }
const bool parse_info_ = true;

View File

@ -1135,7 +1135,7 @@ std::unique_ptr<GraphCompilerInfo> MindRTBackend::ConstructGraphCompilerInfo(con
parser->Parse(control_nodes_, graphs, device_contexts, root_graph, func_graph_to_kernel_graphs);
runtime::KernelMapPosition outputs_order;
size_t outputs_num = 0;
size_t outputs_num;
const auto &root_output =
AnfAlgo::VisitKernelWithReturnType(root_graph->output(), 0, false, {prim::kPrimTupleGetItem}).first;
size_t position = 0;

View File

@ -134,7 +134,7 @@ void FinalVM::Popsp() {
int64_t sp = retsp_.top();
MS_LOG(DEBUG) << "Current sp:" << sp_ << ", before sp:" << sp << ", " << sp_ - sp;
if (sp_ >= sp) {
Pop(sp_ - sp + 1);
Pop((sp_ - sp) + 1);
retsp_.pop();
} else {
MS_LOG(EXCEPTION) << "Stack point sp_:" << sp << " must be bigger than sp:" << sp_;

View File

@ -268,14 +268,12 @@ class MS_CORE_API PartialAbstractClosure final : public AbstractFuncAtom {
/// \brief Get the pre-provided arguments.
///
/// \return The pre-provided arguments.
const AbstractBasePtrList &args() { return args_spec_list_; }
ValuePtr RealBuildValue() const override { return fn_->BuildValue(); }
const AbstractBasePtrList &args() const { return args_spec_list_; }
/// \brief Get the CNode this PartialAbstractClosure evaluated from.
///
/// \return The CNode this PartialAbstractClosure evaluated from.
AnfNodePtr node() { return node_.lock(); }
AnfNodePtr node() const { return node_.lock(); }
/// \brief Set the CNode this PartialAbstractClosure evaluated from.
///
@ -292,6 +290,9 @@ class MS_CORE_API PartialAbstractClosure final : public AbstractFuncAtom {
std::string ToString() const override;
protected:
ValuePtr RealBuildValue() const override { return fn_->BuildValue(); }
private:
AbstractFuncAtomPtr fn_;
AbstractBasePtrList args_spec_list_;

View File

@ -147,7 +147,7 @@ class MS_CORE_API AbstractBase : public Base {
/// \brief Set the function, which prints the debug info.
///
/// \param[in] trace_node_provider The function.
static void set_trace_node_provider(TraceNodeProvider trace_node_provider) {
static void set_trace_node_provider(const TraceNodeProvider &trace_node_provider) {
trace_node_provider_ = trace_node_provider;
}

View File

@ -175,17 +175,17 @@ class MS_CORE_API Shape final : public BaseShape {
/// \brief Get shape dimensions.
///
/// \return Shape dimensions.
const ShapeVector &shape() { return shape_; }
const ShapeVector &shape() const { return shape_; }
/// \brief Get minimum shape dimensions.
///
/// \return Minimum shape dimensions.
const ShapeVector &min_shape() { return min_shape_; }
const ShapeVector &min_shape() const { return min_shape_; }
/// \brief Get maximum shape dimensions.
///
/// \return Maximum shape dimensions.
const ShapeVector &max_shape() { return max_shape_; }
const ShapeVector &max_shape() const { return max_shape_; }
bool IsDynamic() const override {
return std::any_of(shape_.begin(), shape_.end(), [](int64_t s) { return s < 0; });

View File

@ -60,7 +60,7 @@ abstract::ShapePtr AudioSpectrogramInferShape(const PrimitivePtr &primitive,
}
auto stride_size = GetValue<int64_t>(primitive->GetAttr(kStride));
if (stride_size < 1) {
MS_LOG(ERROR) << "stride must be positive, now is " << stride_size;
MS_LOG(EXCEPTION) << "stride must be positive, now is " << stride_size;
}
std::vector<int64_t> infer_shape;
infer_shape.push_back(input_shape[1]);