Skip to content

Commit cb26686

Browse files
ggml-opt: remove workarounds for dynamic tensors
1 parent 3ad0dd2 commit cb26686

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/ggml-opt.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ ggml_opt_context_t ggml_opt_init(struct ggml_opt_params params) {
419419
result->buf_static = ggml_backend_alloc_ctx_tensors(result->ctx_static, ggml_backend_sched_get_backend(result->backend_sched, 0));
420420
result->buf_static_cpu = nullptr;
421421

422-
ggml_opt_alloc_graph(result, result->gf);
423-
424422
return result;
425423
}
426424

@@ -434,7 +432,6 @@ ggml_opt_context_t ggml_opt_init(struct ggml_opt_params params) {
434432
result->buf_static = ggml_backend_alloc_ctx_tensors(result->ctx_static, ggml_backend_sched_get_backend(result->backend_sched, 0));
435433
result->buf_static_cpu = nullptr;
436434

437-
ggml_opt_alloc_graph(result, result->gb_grad);
438435
ggml_graph_reset(result->gb_grad);
439436

440437
return result;
@@ -466,7 +463,6 @@ ggml_opt_context_t ggml_opt_init(struct ggml_opt_params params) {
466463

467464
result->buf_static_cpu = ggml_backend_alloc_ctx_tensors_from_buft(result->ctx_static_cpu, ggml_backend_cpu_buffer_type());
468465

469-
ggml_opt_alloc_graph(result, result->gb_opt);
470466
ggml_graph_reset(result->gb_opt);
471467

472468
return result;

src/ggml.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5839,12 +5839,8 @@ void ggml_graph_reset(struct ggml_cgraph * cgraph) {
58395839

58405840
if (node->op == GGML_OP_OPT_STEP_ADAMW) {
58415841
// clear momenta
5842-
if (node->src[2]->data) {
5843-
ggml_set_zero(node->src[2]);
5844-
}
5845-
if (node->src[3]->data) {
5846-
ggml_set_zero(node->src[3]);
5847-
}
5842+
ggml_set_zero(node->src[2]);
5843+
ggml_set_zero(node->src[3]);
58485844
}
58495845

58505846
// initial gradients of loss should be 1, 0 otherwise

0 commit comments

Comments
 (0)