Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C-API] How to check the output of model is empty or not ? #6207

Closed
chengduoZH opened this issue Dec 4, 2017 · 0 comments
Closed

[C-API] How to check the output of model is empty or not ? #6207

chengduoZH opened this issue Dec 4, 2017 · 0 comments

Comments

@chengduoZH
Copy link
Contributor

chengduoZH commented Dec 4, 2017

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants