Skip to content

Commit

Permalink
move ir_verify from namespace optim to ir_utils (PaddlePaddle#57532)
Browse files Browse the repository at this point in the history
  • Loading branch information
Courtesy-Xs authored and iosmers committed Sep 21, 2023
1 parent 9211816 commit 0ca707c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion paddle/cinn/backends/codegen_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using cinn::common::float16;
const char *kCKeywordRestrict = "__restrict__";

void CodeGenC::Compile(const ir::Module &module, const Outputs &outputs) {
ir::IrVerify(Expr(module));
ir::ir_utils::IrVerify(Expr(module));

if (!outputs.c_header_name.empty()) {
auto source = Compile(module, OutputKind::CHeader);
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/codegen_cuda_dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ std::string CodeGenCUDA_Dev::Compile(const ir::Module &module, bool for_nvrtc) {

void CodeGenCUDA_Dev::Compile(const ir::Module &module,
const Outputs &outputs) {
ir::IrVerify(Expr(module));
ir::ir_utils::IrVerify(Expr(module));

CodeGenC::inline_builtin_codes_ = false;
if (!outputs.c_header_name.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/llvm/codegen_llvm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ llvm::Value *CodeGenLLVM::Visit(const ir::Call *op) {
llvm::Value *CodeGenLLVM::Visit(const ir::_Module_ *op) {
{
Expr body_to_verify(&Reference(op));
ir::IrVerify(body_to_verify);
ir::ir_utils::IrVerify(body_to_verify);
}

for (auto &fn : op->functions) {
Expand Down
10 changes: 6 additions & 4 deletions paddle/cinn/ir/test/ir_verify_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

#include "paddle/cinn/ir/op/ir_operators.h"

namespace cinn::ir {

namespace cinn {
namespace ir {
namespace ir_utils {
TEST(IrVerify, basic) {
Expr a(1);
Expr b(1);
IrVerify(a + b);
}

} // namespace cinn::ir
} // namespace ir_utils
} // namespace ir
} // namespace cinn
12 changes: 8 additions & 4 deletions paddle/cinn/ir/utils/ir_verify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
#include "paddle/cinn/ir/utils/ir_mutator.h"
#include "paddle/cinn/ir/utils/ir_printer.h"

namespace cinn::ir {
namespace cinn {
namespace ir {
namespace ir_utils {
namespace {

struct IrVerifyVisitor : public ir::IRMutator<> {
using ir::IRMutator<>::Visit;
Expand All @@ -30,10 +33,11 @@ struct IrVerifyVisitor : public ir::IRMutator<> {
NODETY_FORALL(__)
#undef __
};

} // namespace
void IrVerify(Expr e) {
IrVerifyVisitor visitor;
visitor.Visit(&e, &e);
}

} // namespace cinn::ir
} // namespace ir_utils
} // namespace ir
} // namespace cinn
9 changes: 6 additions & 3 deletions paddle/cinn/ir/utils/ir_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
#pragma once
#include "paddle/cinn/ir/ir.h"

namespace cinn::ir {
namespace cinn {
namespace ir {
namespace ir_utils {

void IrVerify(Expr e);

} // namespace cinn::ir
} // namespace ir_utils
} // namespace ir
} // namespace cinn

0 comments on commit 0ca707c

Please sign in to comment.