diff --git a/paddle/fluid/framework/unused_var_check.cc b/paddle/fluid/framework/unused_var_check.cc index 7a81bc15b89bd080064398f5692c426d167427f3..eee100bc81c337942fe9e051f63155e8b07c1cb8 100644 --- a/paddle/fluid/framework/unused_var_check.cc +++ b/paddle/fluid/framework/unused_var_check.cc @@ -12,14 +12,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/unused_var_check.h" + #include #include #include #include #include + #include "paddle/fluid/framework/operator.h" -#include "paddle/fluid/framework/unused_var_check.h" #include "paddle/fluid/platform/enforce.h" DEFINE_bool(enable_unused_var_check, false, @@ -27,7 +29,7 @@ DEFINE_bool(enable_unused_var_check, false, "especially for grad operator. It should be in unittest."); // NOTE(zhiqiu): Currently, there are some operators which involves unused -// inputs and cannot be removed from the white_list below. +// inputs and cannot be removed from the allow_list below. // They can be mainly divided into four categories: // 0: the inputs of which are only used in if branch, or used in cuda kernel but // not in cpu kernel; @@ -35,7 +37,7 @@ DEFINE_bool(enable_unused_var_check, false, // 2: the inputs of which are used in fused operators. // The category number is presented in the comments after each operator. -const std::unordered_set op_has_unsed_vars_white_list = { +const std::unordered_set op_with_unsed_vars_allow_list = { "batch_norm", // 0 "batch_norm_grad", // 0 "sync_batch_norm", // 0 @@ -74,8 +76,8 @@ void LogVarUsageIfUnusedVarCheckEnabled(const std::string &name) { } void CheckUnusedVar(const OperatorBase &op, const Scope &scope) { - // skip op in white list and it should be fixed in the future. - if (op_has_unsed_vars_white_list.count(op.Type()) != 0) { + // skip op in allow list. + if (op_with_unsed_vars_allow_list.count(op.Type()) != 0) { return; } auto *used_set = GetThreadLocalUsedVarNameSet(); @@ -116,7 +118,7 @@ void CheckUnusedVar(const OperatorBase &op, const Scope &scope) { "from inputs of the operator; if yes, register " "NoNeedBufferVarsInference or add " "the operator to " - "white list in unused_var_check.cc. See more details at " + "allow list in unused_var_check.cc. See more details at " "[https://github.com/PaddlePaddle/Paddle/wiki/" "OP-Should-Not-Have-Unused-Input]"; PADDLE_ENFORCE_EQ(unsed_input_var_names.size(), 0, diff --git a/paddle/fluid/framework/unused_var_check.h b/paddle/fluid/framework/unused_var_check.h index b56498e0e7f7935e320e34c88e21daf90bf3e332..2f44a3bcde0bc2e6fe8b33247444166728d03ad4 100644 --- a/paddle/fluid/framework/unused_var_check.h +++ b/paddle/fluid/framework/unused_var_check.h @@ -19,11 +19,13 @@ limitations under the License. */ #include #include -#include "paddle/fluid/framework/operator.h" namespace paddle { namespace framework { +class OperatorBase; +class Scope; + std::unordered_set* GetThreadLocalUsedVarNameSet(); void LogVarUsageIfUnusedVarCheckEnabled(const std::string& name); diff --git a/tools/check_api_approvals.sh b/tools/check_api_approvals.sh index c047afad13178c414607151b058d64300b391b93..0ef20b746c0dfbbc43df34d40d716a19da2f8d87 100644 --- a/tools/check_api_approvals.sh +++ b/tools/check_api_approvals.sh @@ -111,7 +111,7 @@ for API_FILE in ${API_FILES[*]}; do echo_line="You must have one RD (gongweibao or seiriosPlus) approval for the paddle/fluid/operators/distributed/send_recv.proto.in, which manages the environment variables.\n" check_approval 1 10721757 5442383 elif [ "${API_FILE}" == "paddle/fluid/framework/unused_var_check.cc" ];then - echo_line="You must have one RD (zhiqiu (Recommend) , sneaxiy or luotao1) approval for the changes of paddle/fluid/framework/unused_var_check.cc, which manages the white list of operators that have unused input variables. Before change the white list, please read the specification [https://github.com/PaddlePaddle/Paddle/wiki/OP-Should-Not-Have-Unused-Input] and try to refine code first. \n" + echo_line="You must have one RD (zhiqiu (Recommend) , sneaxiy or luotao1) approval for the changes of paddle/fluid/framework/unused_var_check.cc, which manages the allow list of operators that have unused input variables. Before change the allow list, please read the specification [https://github.com/PaddlePaddle/Paddle/wiki/OP-Should-Not-Have-Unused-Input] and try to refine code first. \n" check_approval 1 6888866 32832641 6836917 elif [ "${API_FILE}" == "paddle/fluid/pybind/op_function_generator.cc" ];then echo_line="You must have one RD (zhiqiu (Recommend) , phlrain) approval for the changes of paddle/fluid/pybind/op_function_generator.cc, which manages the logic of automatic generating op functions for dygraph. \n"