| 6180 | }; |
| 6181 | |
| 6182 | static struct ggml_tensor * ggml_map_custom2_impl( |
| 6183 | struct ggml_context * ctx, |
| 6184 | struct ggml_tensor * a, |
| 6185 | struct ggml_tensor * b, |
| 6186 | const ggml_custom2_op_t fun, |
| 6187 | int n_tasks, |
| 6188 | void * userdata, |
| 6189 | bool inplace) { |
| 6190 | GGML_ASSERT(n_tasks == GGML_N_TASKS_MAX || n_tasks > 0); |
| 6191 | |
| 6192 | bool is_node = false; |
| 6193 | |
| 6194 | if (!inplace && (a->grad || b->grad)) { |
| 6195 | is_node = true; |
| 6196 | } |
| 6197 | |
| 6198 | struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a); |
| 6199 | |
| 6200 | struct ggml_map_custom2_op_params params = { |
| 6201 | /*.fun =*/ fun, |
| 6202 | /*.n_tasks =*/ n_tasks, |
| 6203 | /*.userdata =*/ userdata |
| 6204 | }; |
| 6205 | ggml_set_op_params(result, (const void *) ¶ms, sizeof(params)); |
| 6206 | |
| 6207 | result->op = GGML_OP_MAP_CUSTOM2; |
| 6208 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 6209 | result->src[0] = a; |
| 6210 | result->src[1] = b; |
| 6211 | |
| 6212 | return result; |
| 6213 | } |
| 6214 | |
| 6215 | struct ggml_tensor * ggml_map_custom2( |
| 6216 | struct ggml_context * ctx, |
no test coverage detected