8000 mnist: fix segmentation fault (ggml/1227) · robbiemu/llama.cpp@6c35981 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c35981

Browse files
JohannesGaesslerggerganov
authored andcommitted
mnist: fix segmentation fault (ggml/1227)
1 parent 8b5e19a commit 6c35981

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

ggml/include/ggml-opt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ extern "C" {
128128
// set gradients to zero, initilize loss, and optionally reset the optimizer
129129
GGML_API void ggml_opt_reset(ggml_opt_context_t opt_ctx, bool optimizer);
130130

131+
GGML_API bool ggml_opt_static_graphs(ggml_opt_context_t opt_ctx); // whether the graphs are allocated_statically
132+
131133
// get underlying tensors that store data
132134
// if not using static graphs these pointers become invalid with the next call to ggml_opt_alloc
133135
GGML_API struct ggml_tensor * ggml_opt_inputs( ggml_opt_context_t opt_ctx); // forward graph input tensor

ggml/src/ggml-opt.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,10 @@ void ggml_opt_reset(ggml_opt_context_t opt_ctx, bool optimizer) {
576576
}
577577
}
578578

579+
bool ggml_opt_static_graphs(ggml_opt_context_t opt_ctx) {
580+
return opt_ctx->static_graphs;
581+
}
582+
579583
struct ggml_tensor * ggml_opt_inputs(ggml_opt_context_t opt_ctx) {
580584
return opt_ctx->inputs;
581585
}
@@ -842,6 +846,7 @@ void ggml_opt_epoch(
842846
int64_t idata_split,
843847
ggml_opt_epoch_callback callback_train,
844848
ggml_opt_epoch_callback callback_eval) {
849+
GGML_ASSERT(ggml_opt_static_graphs(opt_ctx) && "ggml_opt_epoch requires static graphs");
845850
struct ggml_tensor * inputs = ggml_opt_inputs(opt_ctx);
846851
struct ggml_tensor * labels = ggml_opt_labels(opt_ctx);
847852
struct ggml_tensor * data = ggml_opt_dataset_data(dataset);

0 commit comments

Comments
 (0)
0