Created by: chenwhql
PR types
Others
PR changes
Others
Describe
为了让大家更高效的修改余量不合规报错,增加grep_invalid_enforce.sh
脚本,便于轻松地找到相应目录或文件中尚存的不合规报错,使用简介及示例如下:
This script is used to grep invalid PADDLE checks by directory or file in the paddle/fluid/,
the result show all invalid PADDLE checks in specified directory or file.
Usage:
- bash grep_invalid_enforce.sh [target directory or file] (run in tools directory)
- The default check path is paddle/fluid/operators
Result Examples:
1. grep invalid PADDLE checks in directory
- Command: /work/paddle/tools {develop} bash grep_invalid_enforce.sh ../paddle/fluid/imperative
- Results:
- paddle/fluid/imperative/gradient_accumulator.cc
PADDLE_ENFORCE_EQ(dst_tensor->numel() == numel, true,
"dst_numel %d vs. src_numel %d", dst_tensor->numel(),
numel);
- paddle/fluid/imperative/nccl_context.cc
PADDLE_ENFORCE_EQ(addr.size(), 2UL,
"The endpoint should contain host and port: %s", ep);
PADDLE_THROW("create server fd failed");
PADDLE_THROW("set socket opt failed");
PADDLE_THROW("binding failed on ep: %s", ep);
PADDLE_THROW("listen on server fd failed");
PADDLE_THROW("accept the new socket fd failed");
PADDLE_THROW("reading the ncclUniqueId from socket failed");
PADDLE_ENFORCE_EQ(addr.size(), 2UL,
"The endpoint should contain host and port: %s", ep);
PADDLE_THROW("create socket failed");
PADDLE_THROW("invalied address: %s", ep);
- paddle/fluid/imperative/jit/program_desc_tracer.cc
PADDLE_ENFORCE_NOT_NULL(new_var);
PADDLE_ENFORCE_EQ(inner_var.IsInitialized(), true);
PADDLE_THROW("Not support variable type %s",
framework::ToTypeName(inner_var.Type()));
2. grep invalid PADDLE checks in file
- Command: /work/paddle/tools {develop} bash grep_invalid_enforce.sh ../paddle/fluid/pybind/reader_py.cc
- Results:
- paddle/fluid/pybind/reader_py.cc
PADDLE_THROW(
"Place cannot be CUDAPlace when use_double_buffer is False");
PADDLE_ENFORCE_NOT_NULL(exceptions_[i]);
PADDLE_ENFORCE_EQ(status, Status::kException);
PADDLE_ENFORCE_EQ(status, Status::kSuccess);