| 6123 | }; |
| 6124 | |
| 6125 | static struct ggml_tensor * ggml_map_custom1_impl( |
| 6126 | struct ggml_context * ctx, |
| 6127 | struct ggml_tensor * a, |
| 6128 | const ggml_custom1_op_t fun, |
| 6129 | int n_tasks, |
| 6130 | void * userdata, |
| 6131 | bool inplace) { |
| 6132 | GGML_ASSERT(n_tasks == GGML_N_TASKS_MAX || n_tasks > 0); |
| 6133 | |
| 6134 | bool is_node = false; |
| 6135 | |
| 6136 | if (!inplace && a->grad) { |
| 6137 | is_node = true; |
| 6138 | } |
| 6139 | |
| 6140 | struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a); |
| 6141 | |
| 6142 | struct ggml_map_custom1_op_params params = { |
| 6143 | /*.fun =*/ fun, |
| 6144 | /*.n_tasks =*/ n_tasks, |
| 6145 | /*.userdata =*/ userdata |
| 6146 | }; |
| 6147 | ggml_set_op_params(result, (const void *) ¶ms, sizeof(params)); |
| 6148 | |
| 6149 | result->op = GGML_OP_MAP_CUSTOM1; |
| 6150 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 6151 | result->src[0] = a; |
| 6152 | |
| 6153 | return result; |
| 6154 | } |
| 6155 | |
| 6156 | struct ggml_tensor * ggml_map_custom1( |
| 6157 | struct ggml_context * ctx, |
no test coverage detected