[C-API] How to check the output of model is empty or not ?
Created by: chengduoZH
When doing detection task, the output of model may be empty. In this situation, how to check the output of model is empty or not? One solution is that:
paddle_error paddle_check_args_empty(paddle_arguments inArgs, int* notEmpty) {
auto in = paddle::capi::cast<paddle::capi::CArguments>(inArgs);
if (in == nullptr || notEmpty == nullptr) return kPD_NULLPTR;
// first checking
paddle_matrix result = paddle_matrix_create_none();
paddle_error res_err = paddle_arguments_get_value(in, 0, result);
if (res_err == kPD_OUT_OF_RANGE || res_err == kPD_NULLPTR) {
*notEmpty = 0;
CHECK(paddle_matrix_destroy(result));
return kPD_NO_ERROR;
}
// second checking
int height = 0, width = 0;
CHECK(paddle_matrix_get_shape(result, &height, &width));
CHECK(paddle_matrix_destroy(result));
*notEmpty = height;
return kPD_NO_ERROR;
}