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

First rough draft of recoverable errors feature. #1325

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
There were still struct fields and defines conditionally enabled.
Change return from ggml_last_error_msg to be const.

Cast returning error msg buffer to avoid a compiler warning.
  • Loading branch information
KerfuffleV2 committed May 7, 2023
commit 30b2b3d65569a71794c6a542d1ea09d1dcc5e653
6 changes: 2 additions & 4 deletions ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -4245,10 +4245,8 @@ struct ggml_context {

struct ggml_scratch scratch;
struct ggml_scratch scratch_save;
#ifdef GGML_RECOVERABLE_ERRORS
enum ggml_errcode last_error_code;
char last_error_msg[GGML_ERROR_BUFFER_LEN];
#endif
};

struct ggml_context_container {
Expand Down Expand Up @@ -4638,8 +4636,8 @@ enum ggml_errcode ggml_last_error_code(struct ggml_context * ctx) {
return ctx->last_error_code;
}

char * ggml_last_error_msg(struct ggml_context * ctx) {
return ctx->last_error_code == GGML_ERRCODE_SUCCESS ? "Success" : &ctx->last_error_msg;
const char * ggml_last_error_msg(struct ggml_context * ctx) {
return ctx->last_error_code == GGML_ERRCODE_SUCCESS ? "Success" : (const char *)&ctx->last_error_msg;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions ggml.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
} while (0)

#define GGML_RECOVERABLE_ERRORS
#define GGML_ERROR_BUFFER_LEN 256
#ifndef GGML_RECOVERABLE_ERRORS
#define GGML_RECOVERABLE_ASSERT(_ctx, _code, x, ...) \
do { \
Expand All @@ -217,7 +218,6 @@
} while (0)

#else
#define GGML_ERROR_BUFFER_LEN 256
#define GGML_RECOVERABLE_ASSERT(ctx, errcode, x, ...) \
do { \
if ((ctx)->last_error_code != GGML_ERRCODE_SUCCESS) { \
Expand Down Expand Up @@ -468,7 +468,7 @@ extern "C" {
// struct ggml_context * ctx);
GGML_API enum ggml_errcode ggml_last_error_code(
struct ggml_context * ctx);
GGML_API char * ggml_last_error_msg(
GGML_API const char * ggml_last_error_msg(
struct ggml_context * ctx);

GGML_API struct ggml_tensor * ggml_new_tensor(
Expand Down