From: Tanmay Sachan Date: Mon, 8 May 2023 15:06:36 +0000 (+0530) Subject: examples : make struct initialization more portable (#112) X-Git-Tag: upstream/0.0.1642~1491 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=4fdfcb923c6dbb3346bc524bb12b4e666024fc6c;p=pkg%2Fggml%2Fsources%2Fggml examples : make struct initialization more portable (#112) --- diff --git a/examples/gpt-2/main.cpp b/examples/gpt-2/main.cpp index f90ee67c..ad00d2d5 100644 --- a/examples/gpt-2/main.cpp +++ b/examples/gpt-2/main.cpp @@ -417,7 +417,8 @@ bool gpt2_eval( }; struct ggml_context * ctx0 = ggml_init(params); - struct ggml_cgraph gf = { .n_threads = n_threads }; + struct ggml_cgraph gf = {}; + gf.n_threads = n_threads; struct ggml_tensor * embd = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, N); memcpy(embd->data, embd_inp.data(), N*ggml_element_size(embd)); diff --git a/examples/gpt-j/main.cpp b/examples/gpt-j/main.cpp index 99ed4406..1f658200 100644 --- a/examples/gpt-j/main.cpp +++ b/examples/gpt-j/main.cpp @@ -416,7 +416,8 @@ bool gptj_eval( }; struct ggml_context * ctx0 = ggml_init(params); - struct ggml_cgraph gf = { .n_threads = n_threads }; + struct ggml_cgraph gf = {}; + gf.n_threads = n_threads; struct ggml_tensor * embd = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, N); memcpy(embd->data, embd_inp.data(), N*ggml_element_size(embd)); diff --git a/examples/mnist/main.cpp b/examples/mnist/main.cpp index e2ae0329..8036aaf0 100644 --- a/examples/mnist/main.cpp +++ b/examples/mnist/main.cpp @@ -174,7 +174,8 @@ int mnist_eval( }; struct ggml_context * ctx0 = ggml_init(params); - struct ggml_cgraph gf = { .n_threads = n_threads }; + struct ggml_cgraph gf = {}; + gf.n_threads = n_threads; struct ggml_tensor * input = ggml_new_tensor_1d(ctx0, GGML_TYPE_F32, hparams.n_input); memcpy(input->data, digit.data(), ggml_nbytes(input)); diff --git a/examples/stablelm/main.cpp b/examples/stablelm/main.cpp index 494b5e21..3462659d 100644 --- a/examples/stablelm/main.cpp +++ b/examples/stablelm/main.cpp @@ -417,7 +417,8 @@ bool stablelm_eval( }; struct ggml_context * ctx0 = ggml_init(params); - struct ggml_cgraph gf = { .n_threads = n_threads }; + struct ggml_cgraph gf = {}; + gf.n_threads = n_threads; struct ggml_tensor * embd = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, N); memcpy(embd->data, embd_inp.data(), N*ggml_element_size(embd));