| 4192 | // ggml_out_prod |
| 4193 | |
| 4194 | struct ggml_tensor * ggml_out_prod( |
| 4195 | struct ggml_context * ctx, |
| 4196 | struct ggml_tensor * a, |
| 4197 | struct ggml_tensor * b) { |
| 4198 | GGML_ASSERT(ggml_can_out_prod(a, b)); |
| 4199 | GGML_ASSERT(!ggml_is_transposed(a)); |
| 4200 | |
| 4201 | bool is_node = false; |
| 4202 | |
| 4203 | if (a->grad || b->grad) { |
| 4204 | is_node = true; |
| 4205 | } |
| 4206 | |
| 4207 | // a is broadcastable to b for ne[2] and ne[3] -> use b->ne[2] and b->ne[3] |
| 4208 | const int64_t ne[4] = { a->ne[0], b->ne[0], b->ne[2], b->ne[3] }; |
| 4209 | struct ggml_tensor * result = ggml_new_tensor(ctx, GGML_TYPE_F32, MAX(a->n_dims, b->n_dims), ne); |
| 4210 | |
| 4211 | result->op = GGML_OP_OUT_PROD; |
| 4212 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 4213 | result->src[0] = a; |
| 4214 | result->src[1] = b; |
| 4215 | |
| 4216 | return result; |
| 4217 | } |
| 4218 | |
| 4219 | // ggml_scale |
| 4220 |
no test coverage detected