Skip to content

Commit

Permalink
【Error Message BUAA No. 29】paddle/cinn/poly/schedule.cc (PaddlePaddle…
Browse files Browse the repository at this point in the history
…#66739)

* change CHECK tp PADDLE_ENFORCE_xx paddle/cinn/poly/schedule.cc

* change PADDLE_ENFORCE_xx to PADDLE_ENFORCE_NOT_NULL
  • Loading branch information
tlxd authored and Lans1ot committed Aug 5, 2024
1 parent 2e781fd commit 81f5a55
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions paddle/cinn/poly/schedule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ TimeSchedule::TimeSchedule(const std::string &id,
id_ = id;
domain_dims = dims;
for (auto &dim : domain_dims) {
CHECK(!dim.empty());
PADDLE_ENFORCE_EQ(!dim.empty(),
true,
phi::errors::InvalidArgument(
"The dim should not be empty! Please check."));
time_dims_.emplace_back(dim, 0);
}
}
Expand All @@ -109,7 +112,10 @@ void TimeSchedule::OrderAfter(const TimeSchedule &other, int level) {
0,
::common::errors::InvalidArgument(
"level should be greater than or equal to 0, but got %d", level));
CHECK(!time_dims_.empty());
PADDLE_ENFORCE_EQ(!time_dims_.empty(),
true,
phi::errors::InvalidArgument(
"The time dims should not be empty! Please check."));

root_time_ = std::max(root_time_, other.root_time_);

Expand All @@ -132,7 +138,10 @@ isl::map TimeSchedule::to_isl(isl::ctx ctx) const {
}

const std::string &TimeSchedule::id() const {
CHECK(!id_.empty());
PADDLE_ENFORCE_EQ(!id_.empty(),
true,
phi::errors::InvalidArgument(
"The id should not be empty! Please check."));
return id_;
}

Expand All @@ -159,7 +168,8 @@ std::unique_ptr<Schedule> CreateSchedule(
const std::vector<Stage *> &stages,
ScheduleKind schedule_kind,
const std::vector<std::pair<std::string, std::string>> &extra_links) {
CHECK(!stages.empty());
PADDLE_ENFORCE_EQ(
!stages.empty(), true, "The stages should not be empty! Please check.");
for (auto &stage : stages) {
VLOG(4) << "stage: " << stage->domain();
}
Expand All @@ -184,7 +194,9 @@ std::map<std::string, isl::map> CollectScheduleMapFromGroup(

std::vector<Stage *> stages;
for (auto &node : group.nodes) {
CHECK(node->stage);
PADDLE_ENFORCE_NOT_NULL(
node->stage,
phi::errors::NotFound("The stage is not exist in node! Please check."));
stages.push_back(node->stage);
}

Expand All @@ -195,7 +207,10 @@ std::map<std::string, isl::map> CollectScheduleMapFromGroup(
}

void SchedulerBase::AddStage(const Stage &x) {
CHECK(!registration_finalized_) << "element registration has been finalized.";
PADDLE_ENFORCE_EQ(
!registration_finalized_,
true,
phi::errors::InvalidArgument("element registration has been finalized."));
space_size_ =
std::max(space_size_, isl_map_dim(x.transform().get(), isl_dim_out));
VLOG(3) << "space_size: " << space_size_;
Expand Down Expand Up @@ -243,9 +258,11 @@ void SchedulerBase::FinishStageAdd() {
}
}

CHECK(!schedule_graph_.nodes().empty())
<< "No node is registered to the graph, use RegisterElement to collect "
"some elements";
PADDLE_ENFORCE_EQ(!schedule_graph_.nodes().empty(),
true,
phi::errors::InvalidArgument(
"No node is registered to the graph, use "
"RegisterElement to collect some elements."));
registration_finalized_ = true;

for (auto &item : schedule_graph_.nodes()) {
Expand Down Expand Up @@ -279,8 +296,14 @@ SchedulerBase &SchedulerBase::After(const Stage &a, const Stage &b, int level) {
schedule_graph_.RetrieveNode(a.id())->safe_as<ScheduleGraphNode>();
auto *b_node =
schedule_graph_.RetrieveNode(b.id())->safe_as<ScheduleGraphNode>();
CHECK(a_node) << "no node called " << a.id() << " registered in the graph";
CHECK(b_node) << "no node called " << b.id() << " registered in the graph";
PADDLE_ENFORCE_NOT_NULL(
a_node,
phi::errors::NotFound("no node called %s registered in the graph",
a.id()));
PADDLE_ENFORCE_NOT_NULL(
b_node,
phi::errors::NotFound("no node called %s registered in the graph",
b.id()));

auto _a_edge_b_edge_ = a_node->LinkTo<ScheduleGraphEdge>(b_node); // NOLINT
auto &a_edge = std::get<0>(_a_edge_b_edge_);
Expand Down

0 comments on commit 81f5a55

Please sign in to comment.