@@ -51,7 +51,9 @@ using lang::Compute;
5151void GetRealAxes (int ndim,
5252 const std::vector<int >& axes,
5353 std::vector<int >* real_axes) {
54- CHECK (real_axes);
54+ PADDLE_ENFORCE_NOT_NULL (real_axes,
55+ phi::errors::InvalidArgument (
56+ " The 'real_axes' pointer must not be null." ));
5557 if (axes.empty ()) {
5658 for (int i = 0 ; i < ndim; ++i) {
5759 real_axes->push_back (i);
@@ -120,7 +122,9 @@ void GetOutputShape(const std::vector<int>& real_axes,
120122 std::vector<Expr>* output_shape,
121123 const Tensor& tensor,
122124 bool keep_dims) {
123- CHECK (output_shape);
125+ PADDLE_ENFORCE_NOT_NULL (output_shape,
126+ phi::errors::InvalidArgument (
127+ " The 'output_shape' pointer must not be null." ));
124128 auto ndim = tensor->shape .size ();
125129 if (keep_dims) {
126130 for (size_t i = 0 ; i < ndim; ++i) {
@@ -141,7 +145,10 @@ void GetOutputShape(const std::vector<int>& real_axes,
141145 output_shape->push_back (cinn::common::make_one ());
142146 }
143147
144- CHECK (!tensor->shape .empty ());
148+ PADDLE_ENFORCE_EQ (
149+ !tensor->shape .empty (),
150+ true ,
151+ phi::errors::InvalidArgument (" The 'tensor' shape must not be empty." ));
145152 if (tensor->shape [0 ]->type () == Int (64 )) {
146153 for (auto & shape_item : *output_shape) {
147154 shape_item->convert_int32_to_int64 ();
@@ -868,8 +875,10 @@ std::vector<ir::Tensor> TwoStepBlockReduceInternal(
868875 ReduceFunc reduce_func,
869876 BlockReduceFunc block_reduce_func,
870877 ir::Expr initial) {
871- CHECK (!WithoutLastDimInReduce (A->shape , axes))
872- << " Can't find last axis in reduce!" ;
878+ PADDLE_ENFORCE_EQ (
879+ !WithoutLastDimInReduce (A->shape , axes),
880+ true ,
881+ phi::errors::InvalidArgument (" Can't find last axis in reduce!" ));
873882 // If the number of current device SM is smaller than the number of SM
874883 // required by Warp Reduce, the performance of Warp Reduce is better.
875884 // Otherwise, use Block Reduce.
0 commit comments