From a7fc02cb602f43ea0a3088ec8ab6de4089dc093f Mon Sep 17 00:00:00 2001 From: fary86 Date: Tue, 28 Jul 2020 10:30:27 +0800 Subject: [PATCH] Adjust source code format and check scripts, format source codes in directory 'mindspore/core' --- mindspore/core/base/base_ref_utils.h | 1 - mindspore/core/ir/anf.h | 4 +++- mindspore/core/ir/pattern_matcher.h | 4 +--- mindspore/core/ir/primitive.cc | 1 - mindspore/core/utils/flags.h | 2 +- scripts/check_clang_format.sh | 6 +++--- scripts/format_source_code.sh | 6 +++--- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/mindspore/core/base/base_ref_utils.h b/mindspore/core/base/base_ref_utils.h index c12f41fc2f5..7ec0628a7fe 100644 --- a/mindspore/core/base/base_ref_utils.h +++ b/mindspore/core/base/base_ref_utils.h @@ -21,7 +21,6 @@ #include "ir/tensor.h" #include "base/base_ref.h" - #ifndef MINDSPORE_CCSRC_UTILS_BASE_REF_UTILS_H #define MINDSPORE_CCSRC_UTILS_BASE_REF_UTILS_H namespace mindspore { diff --git a/mindspore/core/ir/anf.h b/mindspore/core/ir/anf.h index c3bf85fba5f..96acdf4248b 100644 --- a/mindspore/core/ir/anf.h +++ b/mindspore/core/ir/anf.h @@ -180,7 +180,9 @@ class AnfNode : public Base { bool HasUserData(const std::string &key) const { return user_data_.has(key); } template - bool HasUserData() const { return user_data_.has(T::key); } + bool HasUserData() const { + return user_data_.has(T::key); + } protected: // Hold a weak ref to Graph as Graph also hold ref to AnfNode. diff --git a/mindspore/core/ir/pattern_matcher.h b/mindspore/core/ir/pattern_matcher.h index ea1c4e09e7f..45d03f3dd32 100644 --- a/mindspore/core/ir/pattern_matcher.h +++ b/mindspore/core/ir/pattern_matcher.h @@ -40,9 +40,7 @@ namespace mindspore { template class PBase { public: - bool CheckFunc(const PredicateFuncType &func, const AnfNodePtr &node) { - return func(get_object().GetNode(node)); - } + bool CheckFunc(const PredicateFuncType &func, const AnfNodePtr &node) { return func(get_object().GetNode(node)); } const T &get_object() const { return *static_cast(this); } diff --git a/mindspore/core/ir/primitive.cc b/mindspore/core/ir/primitive.cc index 87cf287de0a..89e19ca96a5 100644 --- a/mindspore/core/ir/primitive.cc +++ b/mindspore/core/ir/primitive.cc @@ -19,7 +19,6 @@ #include #include "abstract/abstract_function.h" - namespace mindspore { abstract::AbstractBasePtr Primitive::ToAbstract() { diff --git a/mindspore/core/utils/flags.h b/mindspore/core/utils/flags.h index cc751aaa214..89268fbaed9 100644 --- a/mindspore/core/utils/flags.h +++ b/mindspore/core/utils/flags.h @@ -23,6 +23,6 @@ extern const char GRAPH_FLAG_HAS_EFFECT[]; extern const char GRAPH_FLAG_EFFECT_PATIAL_ORDER[]; extern const char GRAPH_FLAG_RANDOM_EFFECT[]; extern const char GRAPH_FLAG_SIDE_EFFECT[]; -} +} // namespace mindspore #endif // MINDSPORE_CORE_UTILS_FLAGS_H diff --git a/scripts/check_clang_format.sh b/scripts/check_clang_format.sh index 6ed4f7e5de2..8cd900dec93 100755 --- a/scripts/check_clang_format.sh +++ b/scripts/check_clang_format.sh @@ -86,12 +86,12 @@ cd "${SCRIPTS_PATH}/.." || exit 1 CHECK_LIST_FILE='__checked_files_list__' if [ "X${mode}" == "Xall" ]; then - find mindspore/ccsrc -type f -name "*" | grep "\.h$\|\.cc$" > "${CHECK_LIST_FILE}" || true + find mindspore/{ccsrc,core} -type f -name "*" | grep "\.h$\|\.cc$" > "${CHECK_LIST_FILE}" || true elif [ "X${mode}" == "Xchanged" ]; then # --diff-filter=ACMRTUXB will ignore deleted files in commit - git diff --diff-filter=ACMRTUXB --name-only | grep "mindspore/ccsrc" | grep "\.h$\|\.cc$" > "${CHECK_LIST_FILE}" || true + git diff --diff-filter=ACMRTUXB --name-only | grep "mindspore/ccsrc\|mindspore/core" | grep "\.h$\|\.cc$" > "${CHECK_LIST_FILE}" || true else # "X${mode}" == "Xlastcommit" - git diff --diff-filter=ACMRTUXB --name-only HEAD~ HEAD | grep "mindspore/ccsrc" | grep "\.h$\|\.cc$" > "${CHECK_LIST_FILE}" || true + git diff --diff-filter=ACMRTUXB --name-only HEAD~ HEAD | grep "mindspore/ccsrc\|mindspore/core" | grep "\.h$\|\.cc$" > "${CHECK_LIST_FILE}" || true fi CHECK_RESULT_FILE=__code_format_check_result__ diff --git a/scripts/format_source_code.sh b/scripts/format_source_code.sh index 39c5df7ce5a..d9ef0626c98 100755 --- a/scripts/format_source_code.sh +++ b/scripts/format_source_code.sh @@ -86,11 +86,11 @@ cd "${SCRIPTS_PATH}/.." || exit 1 FMT_FILE_LIST='__format_files_list__' if [[ "X${mode}" == "Xall" ]]; then - find mindspore/ccsrc -type f -name "*" | grep "\.h$\|\.cc$" > "${FMT_FILE_LIST}" || true + find mindspore/{ccsrc,core} -type f -name "*" | grep "\.h$\|\.cc$" > "${FMT_FILE_LIST}" || true elif [[ "X${mode}" == "Xchanged" ]]; then - git diff --name-only | grep "mindspore/ccsrc" | grep "\.h$\|\.cc$" > "${FMT_FILE_LIST}" || true + git diff --name-only | grep "mindspore/ccsrc\|mindspore/core" | grep "\.h$\|\.cc$" > "${FMT_FILE_LIST}" || true else # "X${mode}" == "Xlastcommit" - git diff --name-only HEAD~ HEAD | grep "mindspore/ccsrc" | grep "\.h$\|\.cc$" > "${FMT_FILE_LIST}" || true + git diff --name-only HEAD~ HEAD | grep "mindspore/ccsrc\|mindspore/core" | grep "\.h$\|\.cc$" > "${FMT_FILE_LIST}" || true fi while read line; do