@@ -1533,16 +1533,17 @@ int main(int argc, char ** argv) {
1533
1533
1534
1534
int n_past = 0 ;
1535
1535
1536
- ggml_cgraph gf = {};
1536
+ struct ggml_cgraph * gf = NULL ;
1537
+ gf = ggml_new_graph_custom (ctx0, LLAMA_TRAIN_MAX_NODES, true );
1537
1538
1538
1539
get_example_targets_batch (ctx0, 64 *ex+0 , tokens_input, targets);
1539
1540
1540
- struct ggml_tensor * logits = forward_batch (&model, &kv_self, ctx0, & gf, tokens_input, n_tokens, n_past, n_batch);
1541
+ struct ggml_tensor * logits = forward_batch (&model, &kv_self, ctx0, gf, tokens_input, n_tokens, n_past, n_batch);
1541
1542
// struct ggml_tensor * e = cross_entropy_loss(ctx0, targets, logits);
1542
1543
struct ggml_tensor * e = square_error_loss (ctx0, targets, logits);
1543
1544
1544
- ggml_build_forward_expand (& gf, e);
1545
- ggml_graph_compute_helper (work_buffer, & gf, /* n_threads*/ 1 );
1545
+ ggml_build_forward_expand (gf, e);
1546
+ ggml_graph_compute_helper (work_buffer, gf, /* n_threads*/ 1 );
1546
1547
1547
1548
float error_before_opt = ggml_get_f32_1d (e, 0 );
1548
1549
@@ -1552,8 +1553,8 @@ int main(int argc, char ** argv) {
1552
1553
opt_params_lbfgs.lbfgs .n_iter = 16 ;
1553
1554
ggml_opt (ctx0, opt_params_lbfgs, e);
1554
1555
//
1555
- ggml_build_forward_expand (& gf, e);
1556
- ggml_graph_compute_helper (work_buffer, & gf, /* n_threads*/ 1 );
1556
+ ggml_build_forward_expand (gf, e);
1557
+ ggml_graph_compute_helper (work_buffer, gf, /* n_threads*/ 1 );
1557
1558
1558
1559
float error_after_opt = ggml_get_f32_1d (e, 0 );
1559
1560
@@ -1600,13 +1601,14 @@ int main(int argc, char ** argv) {
1600
1601
};
1601
1602
struct ggml_context * ctx0 = ggml_init (params);
1602
1603
1603
- ggml_cgraph gf = {};
1604
+ struct ggml_cgraph * gf = NULL ;
1605
+ gf = ggml_new_graph_custom (ctx0, LLAMA_TRAIN_MAX_NODES, true );
1604
1606
1605
1607
int n_past = 0 ;
1606
- struct ggml_tensor * logits = forward (&model, &kv_self, ctx0, & gf, tokens_input, sample_ctx, n_past);
1608
+ struct ggml_tensor * logits = forward (&model, &kv_self, ctx0, gf, tokens_input, sample_ctx, n_past);
1607
1609
1608
- ggml_build_forward_expand (& gf, logits);
1609
- ggml_graph_compute_helper (work_buffer, & gf, /* n_threads*/ 1 );
1610
+ ggml_build_forward_expand (gf, logits);
1611
+ ggml_graph_compute_helper (work_buffer, gf, /* n_threads*/ 1 );
1610
1612
1611
1613
struct ggml_tensor * best_samples = ggml_new_tensor_1d (ctx0, GGML_TYPE_I32, sample_ctx);
1612
1614
struct ggml_tensor * probs = ggml_new_tensor_2d (ctx0, GGML_TYPE_F32, n_vocab, sample_ctx);
0 commit comments