Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Error Message No. 31、40、41、126 BUAA】modify error messages #66707

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 102 additions & 24 deletions paddle/cinn/backends/llvm/llvm_intrin_rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,34 @@ namespace codegen {

template <int id, int arg_nums, bool add_float_suffix = true>
inline void MakeFloatIntrinOp(lang::Args args, lang::RetValue *rv) {
PADDLE_ENFORCE_GE(args.size(),
1U,
::common::errors::InvalidArgument(
"The number of args should be greater than 1."));
PADDLE_ENFORCE_GE(
args.size(),
1U,
phi::errors::InvalidArgument(
"The number of arguments should be at least 1. Received: %d",
args.size()));

Expr arg = args[0];
ir::Call *node = arg->as<ir::Call>();
CHECK(node);

PADDLE_ENFORCE_NOT_NULL(node,
phi::errors::InvalidArgument(
"The argument must be a valid call expression."));

PADDLE_ENFORCE_GE(
node->read_args.size(),
arg_nums,
::common::errors::InvalidArgument(
"The number of read args should be greater than arg_nums."));
phi::errors::InvalidArgument(
"The number of read arguments should be at least %d. Received: %d",
arg_nums,
node->read_args.size()));

if (add_float_suffix) {
CHECK(node->type().is_float());
PADDLE_ENFORCE_EQ(node->type().is_float(),
true,
phi::errors::InvalidArgument(
"The node type should be float. Received: %s",
node->type().to_string().c_str()));
*rv = ir::intrinsics::BuiltinIntrin::Make(
node->name + "f", node->read_args, id, arg_nums, node->type());
} else {
Expand Down Expand Up @@ -98,8 +112,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument(
"The argument must be a valid call expression."));
PADDLE_ENFORCE_EQ(
!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty."));

Expr arg = node->read_args[0];
*rv = !(lang::IsInf(arg)) && !(lang::IsNan(arg));
});
Expand All @@ -112,8 +134,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument("The argument must be a valid call "
"expression. Received null."));
PADDLE_ENFORCE_EQ(!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty. "
"The provided read_args are empty."));

Expr arg = node->read_args[0];
Type type = arg->type();
if (type.is_int() || type.is_uint()) {
Expand All @@ -132,8 +162,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument("The argument must be a valid call "
"expression. Received null."));
PADDLE_ENFORCE_EQ(!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty. "
"Received empty read_args."));

Expr arg = node->read_args[0];
*rv = make_const(arg->type(), 1) / lang::Sqrt(arg);
});
Expand All @@ -146,8 +184,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument("The argument must be a valid call "
"expression. Received null."));
PADDLE_ENFORCE_EQ(!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty. "
"Received empty read_args."));

Expr arg = node->read_args[0];
Expr ln10 = make_const(arg->type(), 2.302585093);
*rv = lang::Exp(arg * ln10);
Expand All @@ -161,8 +207,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument("The argument must be a valid call "
"expression. Received null."));
PADDLE_ENFORCE_EQ(!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty. "
"Received empty read_args."));

Expr arg = node->read_args[0];
*rv = lang::Sin(arg) / lang::Cos(arg);
});
Expand All @@ -175,8 +229,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument("The argument must be a valid call "
"expression. Received null."));
PADDLE_ENFORCE_EQ(!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty. "
"Received empty read_args."));

Expr arg = node->read_args[0];
Expr zero = make_const(arg->type(), 0);
Expr one = make_const(arg->type(), 1);
Expand All @@ -199,8 +261,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument("The argument must be a valid call "
"expression. Received null."));
PADDLE_ENFORCE_EQ(!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty. "
"Received empty read_args."));

Expr arg = node->read_args[0];
*rv = (lang::Exp(arg) + lang::Exp(arg * make_const(arg->type(), -1))) /
make_const(arg->type(), 2);
Expand All @@ -214,8 +284,16 @@ void RegisterCpuIntrinRule() {
"The number of args should be greater than 1."));
Expr arg0 = args[0];
ir::Call *node = arg0->as<ir::Call>();
CHECK(node);
CHECK(!node->read_args.empty());
PADDLE_ENFORCE_NOT_NULL(
node,
phi::errors::InvalidArgument("The argument must be a valid call "
"expression. Received null."));
PADDLE_ENFORCE_EQ(!node->read_args.empty(),
true,
phi::errors::InvalidArgument(
"The read_args of the node should not be empty. "
"Received empty read_args."));

Expr arg = node->read_args[0];
*rv = (lang::Exp(arg) - lang::Exp(arg * make_const(arg->type(), -1))) /
make_const(arg->type(), 2);
Expand Down
Loading