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. 17】Replace part of CHECK_ in paddle/cinn/frontend/decomposer/* #62774

Merged
merged 3 commits into from
Mar 21, 2024
Merged
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
35 changes: 27 additions & 8 deletions paddle/cinn/frontend/decomposer/broadcast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "paddle/cinn/frontend/decomposer_registry.h"
#include "paddle/cinn/frontend/syntax.h"
#include "paddle/common/enforce.h"

namespace cinn {
namespace frontend {
Expand Down Expand Up @@ -51,10 +52,18 @@ void GetReduceDimsForY(const std::vector<int>& dy_shape,

void elementwise_add(const Instruction& instr,
const DecomposerContext& context) {
CHECK_EQ(instr->inputs.size(), 2UL)
<< " 2 input tensors for " << instr->op_type;
CHECK_EQ(instr->outputs.size(), 1UL)
<< "1 output tensor for " << instr->op_type;
PADDLE_ENFORCE_EQ(instr->inputs.size(),
2UL,
phi::errors::InvalidArgument(
"The size of inputs in elementwise_add is incorrect. "
"Expected size is 2, but receive %d. ",
instr->inputs.size()));
PADDLE_ENFORCE_EQ(instr->outputs.size(),
1UL,
phi::errors::InvalidArgument(
"The size of outputs in elementwise_add is incorrect. "
"Expected size is 1, but receive %d. ",
instr->outputs.size()));
auto x = instr->inputs[0];
auto y = instr->inputs[1];
auto output = instr->outputs[0];
Expand Down Expand Up @@ -120,10 +129,20 @@ void elementwise_add(const Instruction& instr,

void elementwise_add_grad(const Instruction& instr,
const DecomposerContext& context) {
CHECK_EQ(instr->inputs.size(), 3UL)
<< " 3 input tensors for " << instr->op_type;
CHECK_EQ(instr->outputs.size(), 2UL)
<< "2 output tensors for " << instr->op_type;
PADDLE_ENFORCE_EQ(
instr->inputs.size(),
3UL,
phi::errors::InvalidArgument(
"The size of inputs in elementwise_add_grad is incorrect. "
"Expected size is 3, but receive %d. ",
instr->inputs.size()));
PADDLE_ENFORCE_EQ(
instr->outputs.size(),
2UL,
phi::errors::InvalidArgument(
"The size of outputs in elementwise_add_grad is incorrect. "
"Expected size is 2, but receive %d. ",
instr->outputs.size()));
auto dout = instr->inputs[0];
auto dx = instr->outputs[0];
auto dy = instr->outputs[1];
Expand Down