only use ggml_allocr_alloc when tensor has NULL data and is no view

This commit is contained in:
xaedes 2023-08-14 20:56:56 +02:00
parent faf3e21eaf
commit 098654c277
No known key found for this signature in database
GPG key ID: 30030EDD817EA2B1

View file

@ -986,12 +986,16 @@ struct ggml_tensor * llama_build_train_graphs(
// gradient tensors (will be set to zero by ggml_graph_reset) // gradient tensors (will be set to zero by ggml_graph_reset)
for (int i = 0; i < gf->n_nodes; ++i) { for (int i = 0; i < gf->n_nodes; ++i) {
if (!gf->grads[i]) continue; if (!gf->grads[i]) continue;
if (gf->grads[i]->data == NULL && !ggml_is_view(gf->grads[i])) {
ggml_allocr_alloc(alloc, gf->grads[i]); ggml_allocr_alloc(alloc, gf->grads[i]);
}
ggml_build_forward_expand(gb, ggml_scale_inplace(ctx, gf->grads[i], one)); ggml_build_forward_expand(gb, ggml_scale_inplace(ctx, gf->grads[i], one));
} }
for (int i = 0; i < checkpoints.size(); ++i) { for (int i = 0; i < checkpoints.size(); ++i) {
if (checkpoints[i]->data == NULL && !ggml_is_view(checkpoints[i])) {
ggml_allocr_alloc(alloc, checkpoints[i]); ggml_allocr_alloc(alloc, checkpoints[i]);
} }
}
int n_leafs_after = gb->n_leafs; int n_leafs_after = gb->n_leafs;
int n_nodes_after = gb->n_nodes; int n_nodes_after = gb->n_nodes;