Skip to content

Commit

Permalink
ggml-opt: remove workarounds for dynamic tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesGaessler committed Nov 18, 2024
1 parent 3ad0dd2 commit cb26686
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/ggml-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ ggml_opt_context_t ggml_opt_init(struct ggml_opt_params params) {
result->buf_static = ggml_backend_alloc_ctx_tensors(result->ctx_static, ggml_backend_sched_get_backend(result->backend_sched, 0));
result->buf_static_cpu = nullptr;

ggml_opt_alloc_graph(result, result->gf);

return result;
}

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

ggml_opt_alloc_graph(result, result->gb_grad);
ggml_graph_reset(result->gb_grad);

return result;
Expand Down Expand Up @@ -466,7 +463,6 @@ ggml_opt_context_t ggml_opt_init(struct ggml_opt_params params) {

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

ggml_opt_alloc_graph(result, result->gb_opt);
ggml_graph_reset(result->gb_opt);

return result;
Expand Down
8 changes: 2 additions & 6 deletions src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -5839,12 +5839,8 @@ void ggml_graph_reset(struct ggml_cgraph * cgraph) {

if (node->op == GGML_OP_OPT_STEP_ADAMW) {
// clear momenta
if (node->src[2]->data) {
ggml_set_zero(node->src[2]);
}
if (node->src[3]->data) {
ggml_set_zero(node->src[3]);
}
ggml_set_zero(node->src[2]);
ggml_set_zero(node->src[3]);
}

// initial gradients of loss should be 1, 0 otherwise
Expand Down

0 comments on commit cb26686

Please sign in to comment.