diff --git a/paddle/cinn/backends/llvm/llvm_intrin_rule.h b/paddle/cinn/backends/llvm/llvm_intrin_rule.h index 307018cc3c142..dbe851743fa4b 100644 --- a/paddle/cinn/backends/llvm/llvm_intrin_rule.h +++ b/paddle/cinn/backends/llvm/llvm_intrin_rule.h @@ -32,20 +32,34 @@ namespace codegen { template 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(); - 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 { @@ -98,8 +112,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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)); }); @@ -112,8 +134,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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()) { @@ -132,8 +162,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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); }); @@ -146,8 +184,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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); @@ -161,8 +207,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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); }); @@ -175,8 +229,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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); @@ -199,8 +261,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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); @@ -214,8 +284,16 @@ void RegisterCpuIntrinRule() { "The number of args should be greater than 1.")); Expr arg0 = args[0]; ir::Call *node = arg0->as(); - 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); diff --git a/paddle/cinn/hlir/pe/map_expr_to_ir.cc b/paddle/cinn/hlir/pe/map_expr_to_ir.cc index d2ee60533329d..7c42c2b23afce 100644 --- a/paddle/cinn/hlir/pe/map_expr_to_ir.cc +++ b/paddle/cinn/hlir/pe/map_expr_to_ir.cc @@ -77,7 +77,12 @@ class MapExprToIrTranslator { ir::Expr GetStoreExprForOp(const ::pir::Operation* op) const { const auto& iter = node2lowered_funcs_->find(const_cast<::pir::Operation*>(op)); - CHECK(iter != node2lowered_funcs_->end()); + PADDLE_ENFORCE_NE(iter, + node2lowered_funcs_->end(), + phi::errors::InvalidArgument( + "Iterator reached the end, which indicates the node " + "was not found in node2lowered_funcs_.")); + const auto& lowered_funcs = iter->second; PADDLE_ENFORCE_EQ( lowered_funcs.size(), @@ -85,10 +90,19 @@ class MapExprToIrTranslator { ::common::errors::InvalidArgument("Only support one LoweredFunc now!")); std::optional ret{std::nullopt}; VisitEachStoreExpr(lowered_funcs.at(0), [&](const ir::Expr& expr) { - CHECK(!ret.has_value()); + PADDLE_ENFORCE_EQ( + ret.has_value(), + false, + phi::errors::InvalidArgument( + "ret already has a value. Expected it to be uninitialized.")); ret = expr; }); - CHECK(ret.has_value()); + PADDLE_ENFORCE_EQ( + ret.has_value(), + true, + phi::errors::InvalidArgument( + "ret does not have a value after VisitEachStoreExpr execution.")); + return ret.value(); } @@ -96,7 +110,11 @@ class MapExprToIrTranslator { const tReduceInit& op) const { const auto& iter = node2lowered_funcs_->find(const_cast<::pir::Operation*>(op.value())); - CHECK(iter != node2lowered_funcs_->end()); + PADDLE_ENFORCE_NE(iter, + node2lowered_funcs_->end(), + phi::errors::NotFound( + "The node was not found in node2lowered_funcs_.")); + const auto& lowered_funcs = iter->second; PADDLE_ENFORCE_EQ( lowered_funcs.size(), @@ -117,7 +135,11 @@ class MapExprToIrTranslator { const tReduceAcc& op) const { const auto& iter = node2lowered_funcs_->find(const_cast<::pir::Operation*>(op.value())); - CHECK(iter != node2lowered_funcs_->end()); + PADDLE_ENFORCE_NE(iter, + node2lowered_funcs_->end(), + phi::errors::NotFound( + "The node was not found in node2lowered_funcs_.")); + const auto& lowered_funcs = iter->second; PADDLE_ENFORCE_EQ( lowered_funcs.size(), @@ -306,7 +328,12 @@ class MapExprToIrTranslator { store_rvalue->operands.size(), 0, ::common::errors::InvalidArgument("Only support one operand!")); - CHECK(!op_expr_children->empty()); + PADDLE_ENFORCE_EQ( + op_expr_children->empty(), + false, + phi::errors::InvalidArgument("The op_expr_children list is empty. " + "Expected it to contain elements.")); + PADDLE_ENFORCE_EQ( (store_rvalue.As()->read_args.size()), (op_expr_children->size()), @@ -400,9 +427,13 @@ class MapExprToIrTranslator { static std::unordered_map MakeStoreRvalueExpr4Op(MakeGetterMakeStoreRvalueExpr4Op()); const auto& iter = MakeStoreRvalueExpr4Op.find(op_name); - CHECK(iter != MakeStoreRvalueExpr4Op.end()) - << "Operation " << op_name - << " not supported yet! store_expr: " << store_expr; + PADDLE_ENFORCE_NE(iter, + MakeStoreRvalueExpr4Op.end(), + phi::errors::Unimplemented( + "Operation %s is not supported yet! store_expr: %s", + op_name, + store_expr)); + return iter->second; } @@ -416,7 +447,13 @@ class MapExprToIrTranslator { return GetStoreExpr(op_expr).value().As()->value; } std::optional store_expr = GetStoreExpr(op_expr); - CHECK(store_expr.has_value()); + PADDLE_ENFORCE_EQ(store_expr.has_value(), + true, + phi::errors::InvalidArgument( + "Expected store_expr to have a value, but it is " + "currently uninitialized or empty. Ensure that the " + "store_expr is correctly set before this check.")); + ir::Expr store_rvalue = store_expr.value().As()->value; if (store_rvalue.As()) { return MakeLoadExpr(store_rvalue, op_expr_children, IterExprs4Tensor); @@ -437,7 +474,13 @@ class MapExprToIrTranslator { const IterExprs4TensorT& IterExprs4Tensor) const { const auto& [_, op_expr_children] = op_expr.tuple(); std::optional store_expr = GetStoreExpr(op_expr); - CHECK(store_expr.has_value()); + PADDLE_ENFORCE_EQ(store_expr.has_value(), + true, + phi::errors::InvalidArgument( + "Expected store_expr to have a value, but it is " + "currently uninitialized or empty. Ensure that the " + "store_expr is correctly set before this check.")); + ir::Expr store_rvalue = store_expr.value().As()->value; VLOG(1) << "tReduceInit store_rvalue:\n" << store_rvalue; @@ -459,7 +502,13 @@ class MapExprToIrTranslator { const IterExprs4TensorT& IterExprs4Tensor) const { const auto& [_, op_expr_children] = op_expr.tuple(); std::optional store_expr = GetStoreExpr(op_expr); - CHECK(store_expr.has_value()); + PADDLE_ENFORCE_EQ(store_expr.has_value(), + true, + phi::errors::InvalidArgument( + "Expected store_expr to have a value, but it is " + "currently uninitialized or empty. Ensure that the " + "store_expr is correctly set before this check.")); + ir::Expr store_rvalue = store_expr.value().As()->value; VLOG(1) << "tReduceAcc store_rvalue:\n" << store_rvalue; @@ -471,7 +520,14 @@ class MapExprToIrTranslator { op_expr_children->size(), 1, ::common::errors::InvalidArgument("Mismatched children size")); - CHECK(opt_output_tensor.has_value()); + PADDLE_ENFORCE_EQ( + opt_output_tensor.has_value(), + true, + phi::errors::InvalidArgument( + "Expected opt_output_tensor to have a value, but it is currently " + "uninitialized or empty. Ensure that the opt_output_tensor is " + "correctly set before this check.")); + store_rvalue->operands.at(0).As()->indices = IterExprs4Tensor(opt_output_tensor.value()); { @@ -568,7 +624,14 @@ class MapExprToIrTranslator { ir::Var var{std::string("m_expr_i_") + std::to_string(UniqueId::New().unique_id())}; ir::Expr expr = TranslateTensorIterator(value); - CHECK(value2var_expr.emplace(value, std::make_pair(var, expr)).second); + PADDLE_ENFORCE_EQ( + value2var_expr.emplace(value, std::make_pair(var, expr)).second, + true, + phi::errors::InvalidArgument( + "Failed to insert the value-var-expr pair into value2var_expr. " + "This indicates that the value already exists in the map. " + "Ensure that each value is unique before inserting.")); + } else { // Do nothing } @@ -582,7 +645,14 @@ class MapExprToIrTranslator { ret.reserve(iterator_values->size()); for (const auto& iterator_value : *iterator_values) { const auto& it = value2var_expr.find(iterator_value); - CHECK(it != value2var_expr.end()); + PADDLE_ENFORCE_NE( + it, + value2var_expr.end(), + phi::errors::NotFound( + "The iterator reached the end of value2var_expr, indicating " + "that the value was not found in the map. Ensure that the " + "value exists in the map before attempting to access it.")); + ret.emplace_back(it->second.first); } return ret; @@ -613,7 +683,13 @@ class MapExprToIrTranslator { ir::Expr Translate(const OpExprStmt& op_expr_stmt) const { const auto& [output_tensor, op_expr] = op_expr_stmt.tuple(); std::optional store_expr = GetStoreExpr(op_expr); - CHECK(store_expr.has_value()); + PADDLE_ENFORCE_EQ(store_expr.has_value(), + true, + phi::errors::InvalidArgument( + "Expected store_expr to have a value, but it is " + "currently uninitialized or empty. Ensure that the " + "store_expr is correctly set before this check.")); + std::optional opt_output_tensor = output_tensor; std::vector> binding_var2value{}; @@ -622,7 +698,12 @@ class MapExprToIrTranslator { const auto& opt_rvalue = TranslateOpExpr(op_expr, opt_output_tensor, IterExprs4Tensor); - CHECK(opt_rvalue.has_value()); + PADDLE_ENFORCE_EQ(opt_rvalue.has_value(), + true, + phi::errors::InvalidArgument( + "Expected opt_rvalue to have a value, but it is " + "currently uninitialized or empty. Ensure that " + "opt_rvalue is correctly set before this check.")); const auto& output_expr = ir::Store::Make(store_expr.value().As()->tensor, diff --git a/paddle/cinn/ir/buffer.cc b/paddle/cinn/ir/buffer.cc index 15719c2751d12..176ab07783213 100644 --- a/paddle/cinn/ir/buffer.cc +++ b/paddle/cinn/ir/buffer.cc @@ -26,17 +26,32 @@ namespace cinn { namespace ir { std::string TensorGetBufferName(const _Tensor_ *tensor) { - CHECK(!tensor->name.empty()); - CHECK(!utils::StartsWith(tensor->name, "_")) - << "the name with prefix _ is not allowed for tensor. Current tensor's " - "name is: " - << tensor->name; + PADDLE_ENFORCE_EQ( + !tensor->name.empty(), + true, + phi::errors::InvalidArgument( + "Tensor name is empty. Ensure that the tensor has a valid name.")); + PADDLE_ENFORCE_EQ( + utils::StartsWith(tensor->name, "_"), + false, + phi::errors::InvalidArgument("The name with prefix '_' is not allowed " + "for tensor. Current tensor's name is: %s", + tensor->name)); return "_" + tensor->name; } + std::string BufferGetTensorName(const _Buffer_ *buffer) { - CHECK(!buffer->name.empty()); - CHECK(utils::StartsWith(buffer->name, "_")) - << "buffer's name should start with _"; + PADDLE_ENFORCE_EQ( + !buffer->name.empty(), + true, + phi::errors::InvalidArgument( + "Buffer name is empty. Ensure that the buffer has a valid name.")); + PADDLE_ENFORCE_EQ( + utils::StartsWith(buffer->name, "_"), + true, + phi::errors::InvalidArgument( + "Buffer's name should start with '_'. Current buffer's name is: %s", + buffer->name)); return buffer->name.substr(1); } @@ -53,9 +68,22 @@ Buffer _Buffer_::Make(Var data, int data_alignment, int offset_factor, Target target) { - CHECK(dtype.valid()); - CHECK(!dtype.is_unk()); - CHECK(!dtype.is_void()); + PADDLE_ENFORCE_EQ(dtype.valid(), + true, + phi::errors::InvalidArgument( + "The data type (dtype) is invalid. Ensure that dtype " + "is properly initialized and valid.")); + PADDLE_ENFORCE_EQ(dtype.is_unk(), + false, + phi::errors::InvalidArgument( + "The data type (dtype) is unknown. Ensure that dtype " + "is properly initialized and known.")); + PADDLE_ENFORCE_EQ(dtype.is_void(), + false, + phi::errors::InvalidArgument( + "The data type (dtype) is void. Ensure that dtype is " + "properly initialized and not void.")); + auto *node = cinn::common::make_shared<_Buffer_>(); node->shape = shape; node->strides = strides; @@ -89,8 +117,13 @@ void _Buffer_::BindTo(const Tensor &tensor) { BindTo(tensor.As<_Tensor_>()); } void _Buffer_::BindTo(const _Tensor_ *tensor) { if (name.empty()) name = TensorGetBufferName(tensor); if (type().is_unk()) set_type(tensor->type()); - CHECK(!tensor->shape.empty()) - << "Tensor should have shape to bind to a Buffer"; + PADDLE_ENFORCE_EQ( + !tensor->shape.empty(), + true, + phi::errors::InvalidArgument( + "Tensor should have a shape to bind to a Buffer. Ensure that the " + "tensor's shape is properly initialized and not empty.")); + shape = tensor->shape; binded_tensors_names_.insert(tensor->name); } @@ -107,7 +140,12 @@ Var _Buffer_::buffer_addr() const { int64_t _Buffer_::numel() const { int64_t res = 1; for (auto &i : shape) { - CHECK(i.is_constant()); + PADDLE_ENFORCE_EQ(i.is_constant(), + true, + phi::errors::InvalidArgument( + "The value of 'i' is not constant. Ensure that 'i' " + "is a constant value before proceeding.")); + if (i->type() == Int(64)) { res *= i.as_int64(); } else { @@ -126,9 +164,21 @@ ir::Expr _Buffer_::SymbolicNumel() const { } void _Buffer_::Verify() const { - CHECK(!shape.empty()); - CHECK(!name.empty()); - CHECK(dtype.valid()); + PADDLE_ENFORCE_EQ( + !shape.empty(), + true, + phi::errors::InvalidArgument( + "Buffer shape is empty. Ensure that the buffer has a valid shape.")); + PADDLE_ENFORCE_EQ( + !name.empty(), + true, + phi::errors::InvalidArgument( + "Buffer name is empty. Ensure that the buffer has a valid name.")); + PADDLE_ENFORCE_EQ(dtype.valid(), + true, + phi::errors::InvalidArgument( + "Buffer data type (dtype) is invalid. Ensure that " + "dtype is properly initialized and valid.")); } Expr Buffer::DestroyExpr() const { @@ -146,7 +196,10 @@ Expr _BufferRange_::Make(const Expr &buffer, const std::vector &ranges) { } void _BufferRange_::Verify() const { auto *buffer_ptr = buffer.As<_Buffer_>(); - CHECK(buffer_ptr); + PADDLE_ENFORCE_NOT_NULL( + buffer_ptr, + phi::errors::InvalidArgument("buffer_ptr is null. Ensure that buffer_ptr " + "is properly initialized and not null.")); } Expr _BufferRange_::Copy() const { auto node = make_shared<_BufferRange_>(); @@ -159,8 +212,15 @@ Expr _BufferRange_::Copy() const { bool BufferRange::operator==(const BufferRange &x) const { auto this_buffer = operator->()->buffer.As<_Buffer_>(); auto other_buffer = x->buffer.As<_Buffer_>(); - CHECK(this_buffer); - CHECK(other_buffer); + PADDLE_ENFORCE_NOT_NULL(this_buffer, + phi::errors::InvalidArgument( + "this_buffer is null. Ensure that this_buffer is " + "properly initialized and not null.")); + PADDLE_ENFORCE_NOT_NULL(other_buffer, + phi::errors::InvalidArgument( + "other_buffer is null. Ensure that other_buffer " + "is properly initialized and not null.")); + if (this_buffer != other_buffer) return false; if (x->ranges.size() != operator->()->ranges.size()) return false; for (int i = 0; i < x->ranges.size(); i++) { diff --git a/paddle/cinn/ir/ir_mutator.h b/paddle/cinn/ir/ir_mutator.h index e367ff31fc993..15d4016c23ad6 100644 --- a/paddle/cinn/ir/ir_mutator.h +++ b/paddle/cinn/ir/ir_mutator.h @@ -223,7 +223,12 @@ void IRMutator::Visit(const Reduce *expr, T op) { auto *node = op->template As(); if (node->init.defined()) IRVisitorRequireReImpl::Visit(&node->init, &node->init); - CHECK(node->body.defined()); + PADDLE_ENFORCE_EQ(node->body.defined(), + true, + phi::errors::InvalidArgument( + "The node's body is not defined. Ensure that the " + "node's body is properly initialized and defined.")); + IRVisitorRequireReImpl::Visit(&node->body, &node->body); } @@ -300,7 +305,11 @@ void IRMutator::Visit(const IntrinsicOp *expr, T op) { template void IRMutator::Visit(const _BufferRange_ *expr, T op) { auto *node = op->template As<_BufferRange_>(); - CHECK(node); + PADDLE_ENFORCE_NOT_NULL( + node, + phi::errors::InvalidArgument("Node is null. Ensure that the node is " + "properly initialized and not null.")); + IRVisitorRequireReImpl::Visit(&node->buffer, &node->buffer); for (auto &var : node->ranges) { if (var->lower_bound.defined()) { @@ -317,7 +326,11 @@ void IRMutator::Visit(const _BufferRange_ *expr, T op) { template void IRMutator::Visit(const ScheduleBlock *expr, T op) { auto *node = op->template As(); - CHECK(node); + PADDLE_ENFORCE_NOT_NULL( + node, + phi::errors::InvalidArgument("Node is null. Ensure that the node is " + "properly initialized and not null.")); + for (auto &var : node->iter_vars) { if (var->lower_bound.defined()) { IRVisitorRequireReImpl::Visit(&var->lower_bound, @@ -340,7 +353,11 @@ void IRMutator::Visit(const ScheduleBlock *expr, T op) { template void IRMutator::Visit(const ScheduleBlockRealize *expr, T op) { auto *node = op->template As(); - CHECK(node); + PADDLE_ENFORCE_NOT_NULL( + node, + phi::errors::InvalidArgument("Node is null. Ensure that the node is " + "properly initialized and not null.")); + for (auto &value : node->iter_values) { IRVisitorRequireReImpl::Visit(&value, &value); } @@ -351,7 +368,11 @@ void IRMutator::Visit(const ScheduleBlockRealize *expr, T op) { template void IRMutator::Visit(const _Dim_ *expr, T op) { auto *node = op->template As<_Dim_>(); - CHECK(node); + PADDLE_ENFORCE_NOT_NULL( + node, + phi::errors::InvalidArgument("Node is null. Ensure that the node is " + "properly initialized and not null.")); + // IRVisitorRequireReImpl::Visit(&node->sym_dim, &node->sym_dim); }