MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_map_custom2_impl

Function ggml_map_custom2_impl

ggml.c:6182–6213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6180};
6181
6182static 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 *) &params, 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
6215struct ggml_tensor * ggml_map_custom2(
6216 struct ggml_context * ctx,

Callers 2

ggml_map_custom2Function · 0.70
ggml_map_custom2_inplaceFunction · 0.70

Calls 3

ggml_view_tensorFunction · 0.70
ggml_dup_tensorFunction · 0.70
ggml_set_op_paramsFunction · 0.70

Tested by

no test coverage detected