MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ggml_webgpu_encode

Function ggml_webgpu_encode

external/ggml/src/ggml-webgpu/ggml-webgpu.cpp:2926–3040  ·  view source on GitHub ↗

Returns the encoded command, or std::nullopt if the operation is a no-op

Source from the content-addressed store, hash-verified

2924
2925// Returns the encoded command, or std::nullopt if the operation is a no-op
2926static std::optional<webgpu_encoded_op> ggml_webgpu_encode(webgpu_context ctx,
2927 ggml_cgraph * cgraph,
2928 int node_idx,
2929 int & num_encoded_ops) {
2930 ggml_tensor ** nodes = cgraph->nodes;
2931 ggml_tensor * node = nodes[node_idx];
2932
2933 if (ggml_is_empty(node)) {
2934 return std::nullopt;
2935 }
2936 if ((node->flags & GGML_TENSOR_FLAG_COMPUTE) == 0) {
2937 return std::nullopt;
2938 }
2939 WEBGPU_LOG_DEBUG("ggml_webgpu_encode(" << node << ", " << ggml_op_name(node->op) << ")");
2940
2941 ggml_tensor * src0 = node->src[0];
2942 ggml_tensor * src1 = node->src[1];
2943 ggml_tensor * src2 = node->src[2];
2944
2945 switch (node->op) {
2946 // no-ops
2947 case GGML_OP_NONE:
2948 case GGML_OP_VIEW:
2949 case GGML_OP_PERMUTE:
2950 case GGML_OP_TRANSPOSE:
2951 case GGML_OP_RESHAPE:
2952 return std::nullopt;
2953 case GGML_OP_CPY:
2954 case GGML_OP_CONT:
2955 return ggml_webgpu_cpy(ctx, src0, node);
2956 case GGML_OP_SET:
2957 return ggml_webgpu_set(ctx, src0, src1, node);
2958 case GGML_OP_SET_ROWS:
2959 return ggml_webgpu_set_rows(ctx, src0, src1, node);
2960 case GGML_OP_GET_ROWS:
2961 return ggml_webgpu_get_rows(ctx, src0, src1, node);
2962 case GGML_OP_MUL_MAT:
2963 return ggml_webgpu_mul_mat(ctx, src0, src1, node);
2964 case GGML_OP_MUL_MAT_ID:
2965 return ggml_webgpu_mul_mat_id(ctx, src0, src1, src2, node);
2966 case GGML_OP_FLASH_ATTN_EXT:
2967 return ggml_webgpu_flash_attn(ctx, src0, src1, src2, node->src[3], node->src[4], node);
2968 case GGML_OP_ADD:
2969 case GGML_OP_SUB:
2970 case GGML_OP_MUL:
2971 case GGML_OP_DIV:
2972 return ggml_webgpu_binary_op(ctx, src0, src1, node);
2973 case GGML_OP_ADD_ID:
2974 return ggml_webgpu_add_id(ctx, src0, src1, src2, node);
2975 case GGML_OP_CONCAT:
2976 return ggml_webgpu_concat(ctx, src0, src1, node);
2977 case GGML_OP_REPEAT:
2978 return ggml_webgpu_repeat(ctx, src0, node);
2979 case GGML_OP_RMS_NORM:
2980 if (ggml_webgpu_can_fuse_rms_norm_mul(cgraph, node_idx)) {
2981 num_encoded_ops = 2;
2982 ggml_tensor * mul_node = nodes[node_idx + 1];
2983 return ggml_webgpu_rms_norm_mul(ctx, src0, node, mul_node->src[0], mul_node->src[1], mul_node);

Callers 1

Calls 15

ggml_is_emptyFunction · 0.85
ggml_op_nameFunction · 0.85
ggml_webgpu_cpyFunction · 0.85
ggml_webgpu_setFunction · 0.85
ggml_webgpu_set_rowsFunction · 0.85
ggml_webgpu_get_rowsFunction · 0.85
ggml_webgpu_mul_matFunction · 0.85
ggml_webgpu_mul_mat_idFunction · 0.85
ggml_webgpu_flash_attnFunction · 0.85
ggml_webgpu_binary_opFunction · 0.85
ggml_webgpu_add_idFunction · 0.85
ggml_webgpu_concatFunction · 0.85

Tested by

no test coverage detected