diff --git a/build.sh b/build.sh index d54432e7091..42a066b1d68 100755 --- a/build.sh +++ b/build.sh @@ -14,6 +14,7 @@ # limitations under the License. # ============================================================================ +# MindSpore build script set -e BASEPATH=$(cd "$(dirname $0)"; pwd) export CUDA_PATH="" @@ -39,6 +40,7 @@ check_on_off() fi } +# check value of input is 'on' or 'off' or 'debug' update_submodule() { git submodule update --init graphengine @@ -54,6 +56,7 @@ update_submodule() fi } +# check value of input is 'on' or 'off' build_exit() { echo "$@" >&2 diff --git a/cmake/dependency_graphengine.cmake b/cmake/dependency_graphengine.cmake index af63a609db2..9286f6a2c8d 100644 --- a/cmake/dependency_graphengine.cmake +++ b/cmake/dependency_graphengine.cmake @@ -2,7 +2,7 @@ message(STATUS "Compiling GraphEngine") if(NOT(BUILD_LITE)) set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/graphengine) else() - set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../graphengine) + set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../graphengine) endif() message(STATUS "[ME] build_path: ${BUILD_PATH}") diff --git a/include/api/cell.h b/include/api/cell.h index e0813467666..a92c5262a02 100644 --- a/include/api/cell.h +++ b/include/api/cell.h @@ -21,7 +21,7 @@ #include #include "include/api/status.h" #include "include/api/types.h" -#include "include/api/graph.h" +#include "include/api/graph.h" // for MSTensor namespace mindspore { class InputAndOutput; @@ -29,7 +29,8 @@ class Context; using Input = InputAndOutput; using Output = InputAndOutput; -class MS_API CellBase { + +class MS_API CellBase { // for CellCreator public: CellBase() = default; virtual ~CellBase() = default; @@ -50,7 +51,7 @@ class MS_API GraphCell final : public Cell { public: class GraphImpl; - GraphCell() = default; + GraphCell() = default; // for CellCreator ~GraphCell() override = default; explicit GraphCell(const Graph &); @@ -58,7 +59,7 @@ class MS_API GraphCell final : public Cell { explicit GraphCell(const std::shared_ptr &); void SetContext(const std::shared_ptr &context); - const std::shared_ptr &GetGraph() const { return graph_; } + const std::shared_ptr &GetGraph() const { return graph_; } // for CellCreator Status Run(const std::vector &inputs, std::vector *outputs) override; std::vector GetInputs(); std::vector GetOutputs(); @@ -71,7 +72,8 @@ class MS_API GraphCell final : public Cell { std::shared_ptr executor_; }; -class MS_API InputAndOutput { +class MS_API InputAndOutput { // for CellCreator + public: InputAndOutput(); ~InputAndOutput() = default; diff --git a/include/c_api/model_c.h b/include/c_api/model_c.h index ddd31b52a86..3f5db9e7234 100644 --- a/include/c_api/model_c.h +++ b/include/c_api/model_c.h @@ -32,6 +32,7 @@ typedef struct MSTensorHandleArray { } MSTensorHandleArray; #define MS_MAX_SHAPE_NUM 32 + typedef struct MSShapeInfo { size_t shape_num; int64_t shape[MS_MAX_SHAPE_NUM]; diff --git a/include/c_api/status_c.h b/include/c_api/status_c.h index 62b19b99460..603bcf6a431 100644 --- a/include/c_api/status_c.h +++ b/include/c_api/status_c.h @@ -22,7 +22,7 @@ extern "C" { #endif -enum MSCompCode { +enum MSCompCode { // 4 bytes kMSCompCodeCore = 0x00000000u, kMSCompCodeMD = 0x10000000u, kMSCompCodeME = 0x20000000u, diff --git a/mindspore/ccsrc/backend/common/optimizer/common_backend_optimization.h b/mindspore/ccsrc/backend/common/optimizer/common_backend_optimization.h index 762fc6a2735..ddc3b5c8209 100644 --- a/mindspore/ccsrc/backend/common/optimizer/common_backend_optimization.h +++ b/mindspore/ccsrc/backend/common/optimizer/common_backend_optimization.h @@ -21,7 +21,7 @@ namespace mindspore { namespace opt { void BackendCommonOptimization(const std::shared_ptr &kernel_graph); void CommonFinalOptimization(const std::shared_ptr &kernel_graph); -void CommonUnifyMindIR(const std::shared_ptr &kernel_graph); +void CommonUnifyMindIR(const std::shared_ptr &kernel_graph); // for debug void AddDynamicShapeAttrPass(const std::shared_ptr &kernel_graph); void EliminateIllegalDataTypePass(const std::shared_ptr &kernel_graph); void DynamicShapeConvertPass(const std::shared_ptr &kernel_graph); diff --git a/mindspore/ccsrc/backend/common/session/ascend_session.h b/mindspore/ccsrc/backend/common/session/ascend_session.h index 9efb511b57a..cf8d00add07 100644 --- a/mindspore/ccsrc/backend/common/session/ascend_session.h +++ b/mindspore/ccsrc/backend/common/session/ascend_session.h @@ -47,7 +47,7 @@ class AscendSession : public SessionBasic { static void BatchBuildKernel(const std::vector> &build_tasks); - protected: + protected: // load graph to device related void UnifyMindIR(const KernelGraphPtr &graph) override; GraphId CompileGraphImpl(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) override; GraphId CompileGraphImpl(NotNull func_graph) override; diff --git a/mindspore/ccsrc/backend/common/session/cpu_session.h b/mindspore/ccsrc/backend/common/session/cpu_session.h index 7bc583b6ade..5274143e718 100644 --- a/mindspore/ccsrc/backend/common/session/cpu_session.h +++ b/mindspore/ccsrc/backend/common/session/cpu_session.h @@ -31,7 +31,7 @@ class CPUSession : public SessionBasic { ~CPUSession() override = default; void Init(uint32_t device_id) override; - protected: + protected: // load graph void UnifyMindIR(const KernelGraphPtr &graph) override { SessionBasic::UnifyMindIR(graph); } void CreateOutputTensors(const GraphId &graph_id, const std::vector &input_tensors, VectorRef *, std::map *tensor_to_node, diff --git a/mindspore/ccsrc/backend/common/session/session_basic.h b/mindspore/ccsrc/backend/common/session/session_basic.h index ab292a573ad..d173931a0d3 100644 --- a/mindspore/ccsrc/backend/common/session/session_basic.h +++ b/mindspore/ccsrc/backend/common/session/session_basic.h @@ -228,7 +228,7 @@ class BACKEND_EXPORT SessionBasic : public std::enable_shared_from_this &tensor_to_node, std::map *); virtual void UnifyMindIR(const KernelGraphPtr &graph); diff --git a/mindspore/ccsrc/pipeline/pynative/base.h b/mindspore/ccsrc/pipeline/pynative/base.h index fd774ae1e3f..90f33c105dd 100644 --- a/mindspore/ccsrc/pipeline/pynative/base.h +++ b/mindspore/ccsrc/pipeline/pynative/base.h @@ -37,7 +37,7 @@ namespace py = pybind11; enum RunOpArgsEnum { PY_PRIM = 0, PY_NAME, PY_INPUTS, PY_ARGS_NUM }; -struct OpExecInfo { +struct OpExecInfo { // for runop build bool is_nop_prim = false; bool is_dynamic_shape = false; bool is_mixed_precision_cast = false; diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/ascend_backend_optimization.cc b/mindspore/ccsrc/plugin/device/ascend/optimizer/ascend_backend_optimization.cc index d45e344de8e..f49199a200f 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/ascend_backend_optimization.cc +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/ascend_backend_optimization.cc @@ -169,6 +169,7 @@ namespace opt { namespace { constexpr char kDisablePrebuildEnv[] = "MS_DEV_DISABLE_PREBUILD"; +// The following passes are used to optimize the graph before fusion. void AddAscendIRFusionRulesPass(PassManager *ir_fusion_pm) { MS_EXCEPTION_IF_NULL(ir_fusion_pm); ir_fusion_pm->AddPass(std::make_shared()); @@ -360,6 +361,7 @@ void AscendBackendIRFusionOptimization(const std::shared_ptrgraph_id(); } +// The following passes are used to optimize the graph after fusion. void RunOpAscendBackendIRFusionOptimization(const std::shared_ptr &kernel_graph) { auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); diff --git a/mindspore/lite/tools/converter/import/mindspore_importer.cc b/mindspore/lite/tools/converter/import/mindspore_importer.cc index d411f48ffe3..d6a5af78996 100644 --- a/mindspore/lite/tools/converter/import/mindspore_importer.cc +++ b/mindspore/lite/tools/converter/import/mindspore_importer.cc @@ -42,7 +42,7 @@ constexpr size_t kDependInputNum = 3; constexpr size_t kDependFirstInputIdx = 1; constexpr size_t kTupleGetItemFirstInputIdx = 1; } // namespace -STATUS MindsporeImporter::Mindir2AnfAdjust(const FuncGraphPtr &func_graph, const converter::Flags &flag) { +STATUS MindsporeImporter::Mindir2AnfAdjust(const FuncGraphPtr &func_graph, const converter::Flags &flag) { // fmk: Ms MS_ASSERT(func_graph != nullptr); auto primitive_adjust_pass = std::make_shared(); MS_CHECK_TRUE_MSG(primitive_adjust_pass != nullptr, RET_NULL_PTR, "primitive_adjust_pass is nullptr."); diff --git a/mindspore/lite/tools/converter/micro/coder/generator/component/common_component.cc b/mindspore/lite/tools/converter/micro/coder/generator/component/common_component.cc index f34fbec310a..2326d626083 100644 --- a/mindspore/lite/tools/converter/micro/coder/generator/component/common_component.cc +++ b/mindspore/lite/tools/converter/micro/coder/generator/component/common_component.cc @@ -77,7 +77,7 @@ void CodeMSModelBuild(std::ofstream &ofs, const Configurator *config) { " return kMSStatusLiteNotSupport;\n" " }\n"; ofs << " int ret = RET_OK;\n"; - if (config->target() != kARM32M) { + if (config->target() != kARM32M) { // only support ARM32M ofs << " ret = Init((void*)model_data, data_size);\n"; } if (config->support_parallel()) { diff --git a/mindspore/python/mindspore/boost/__init__.py b/mindspore/python/mindspore/boost/__init__.py index 255c5d7dc10..e8c08b5a4c0 100644 --- a/mindspore/python/mindspore/boost/__init__.py +++ b/mindspore/python/mindspore/boost/__init__.py @@ -29,6 +29,7 @@ from .adasum import AdaSum from .dim_reduce import DimReduce + __all__ = ['AutoBoost', 'OptimizerProcess', 'ParameterProcess', 'BoostTrainOneStepCell', 'BoostTrainOneStepWithLossScaleCell', diff --git a/mindspore/python/mindspore/boost/base.py b/mindspore/python/mindspore/boost/base.py index 61c246e3c6e..448b69854d9 100644 --- a/mindspore/python/mindspore/boost/base.py +++ b/mindspore/python/mindspore/boost/base.py @@ -31,6 +31,7 @@ from mindspore.parallel._auto_parallel_context import auto_parallel_context from .less_batch_normalization import CommonHeadLastFN + __all__ = ["OptimizerProcess", "ParameterProcess"] diff --git a/mindspore/python/mindspore/boost/dim_reduce.py b/mindspore/python/mindspore/boost/dim_reduce.py index dbfd7d86fc8..8176cecf740 100644 --- a/mindspore/python/mindspore/boost/dim_reduce.py +++ b/mindspore/python/mindspore/boost/dim_reduce.py @@ -84,6 +84,7 @@ def _get_delta_weight_process(rho, dn, grad_res_momentum): return delta_weight + class DimReduce(Cell): r""" The dimension reduce training, is a novel algorithm for accelerating convergence of Deep Learning models. diff --git a/mindspore/python/mindspore/dataset/__init__.py b/mindspore/python/mindspore/dataset/__init__.py index 149cc999e10..781c8441dd1 100644 --- a/mindspore/python/mindspore/dataset/__init__.py +++ b/mindspore/python/mindspore/dataset/__init__.py @@ -40,6 +40,7 @@ Descriptions of common dataset terms are as follows: - Iterator, the base class of dataset iterator for enumerating elements. """ +# pylint: disable=unused-import from .core import config from .engine import * from .engine.cache_client import DatasetCache diff --git a/mindspore/python/mindspore/dataset/core/datatypes.py b/mindspore/python/mindspore/dataset/core/datatypes.py index 433f0c59644..5eb8da6b9e5 100644 --- a/mindspore/python/mindspore/dataset/core/datatypes.py +++ b/mindspore/python/mindspore/dataset/core/datatypes.py @@ -22,7 +22,7 @@ from mindspore._c_expression import typing import mindspore.common.dtype as mstype -def mstype_to_detype(type_): +def mstype_to_detype(type_): # pylint: disable=too-many-return-statements """ Get de data type corresponding to mindspore dtype. diff --git a/mindspore/python/mindspore/scipy/utils.py b/mindspore/python/mindspore/scipy/utils.py index c0b091700da..0561eac9590 100644 --- a/mindspore/python/mindspore/scipy/utils.py +++ b/mindspore/python/mindspore/scipy/utils.py @@ -26,7 +26,7 @@ grad = GradOperation(get_all=False, get_by_list=False, sens_param=False) _eps_net = ops.Eps() -def _convert_64_to_32(tensor): +def _convert_64_to_32(tensor): """Convert Tensor with float64/int64 types to float32/int32.""" if tensor.dtype == mstype.float64: return tensor.astype("float32") diff --git a/mindspore/python/mindspore/train/_utils.py b/mindspore/python/mindspore/train/_utils.py index 951ba053fea..0e3467c2d22 100644 --- a/mindspore/python/mindspore/train/_utils.py +++ b/mindspore/python/mindspore/train/_utils.py @@ -23,7 +23,7 @@ from mindspore.common.dtype import dtype_to_nptype, pytype_to_dtype from mindspore.common import dtype as mstype from mindspore import log as logger from mindspore.common.api import _cell_graph_executor -from mindspore.train.mind_ir_pb2 import ModelProto as mindir_model +from mindspore.train.mind_ir_pb2 import ModelProto as mindir_model from mindspore.train.checkpoint_pb2 import Checkpoint from mindspore.train.node_strategy_pb2 import ParallelStrategyMap as ckpt_strategy @@ -42,7 +42,7 @@ def _convert_type(types): Returns: list, list of element in dataset. """ - ms_types = [] + ms_types = [] for np_type in types: ms_type = pytype_to_dtype(np_type) ms_types.append(ms_type) diff --git a/setup.py b/setup.py index 63d69b005cf..1db4c933a19 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ import os import stat import platform +# pylint: disable=import-error from setuptools import setup, find_packages from setuptools.command.egg_info import egg_info from setuptools.command.build_py import build_py @@ -33,35 +34,35 @@ pwd = os.path.dirname(os.path.realpath(__file__)) pkg_dir = os.path.join(build_path, 'package') -def _read_file(filename): +def _read_file(filename): # pylint: disable=invalid-name with open(os.path.join(pwd, filename), encoding='UTF-8') as f: return f.read() -version = _read_file('version.txt').replace("\n", "") +version = _read_file('version.txt').replace("\n", "") # pylint: disable=invalid-name readme = _read_file('README.md') -def _write_version(file): +def _write_version(file): # pylint: disable=invalid-name file.write("__version__ = '{}'\n".format(version)) -def _write_config(file): +def _write_config(file): # pylint: disable=invalid-name file.write("__backend__ = '{}'\n".format(backend_policy)) -def _write_commit_file(file): +def _write_commit_file(file): # pylint: disable=invalid-name file.write("__commit_id__ = '{}'\n".format(commit_id)) -def _write_package_name(file): +def _write_package_name(file): # pylint: disable=invalid-name file.write("__package_name__ = '{}'\n".format(package_name)) def _write_device_target(file): file.write("__device_target__ = '{}'\n".format(device_target)) - +# def build_dependencies(): """generate python file""" version_file = os.path.join(pkg_dir, 'mindspore', 'version.py')