| 18231 | } |
| 18232 | |
| 18233 | static void ggml_opt_acc_grad(int np, struct ggml_tensor * const ps[], float * g, float scale) { |
| 18234 | int64_t i = 0; |
| 18235 | for (int p = 0; p < np; ++p) { |
| 18236 | const int64_t ne = ggml_nelements(ps[p]) ; |
| 18237 | // TODO: add function to get all elements at once |
| 18238 | for (int64_t j = 0; j < ne; ++j) { |
| 18239 | g[i++] += ggml_get_f32_1d(ps[p]->grad, j) * scale; |
| 18240 | } |
| 18241 | } |
| 18242 | } |
| 18243 | |
| 18244 | // |
| 18245 | // ADAM |
no test coverage detected