@@ -357,8 +357,8 @@ struct ggml_backend_webgpu_buffer_context {
357357
358358// Process a WGSL shader string, replacing tokens of the form {{KEY}} with
359359// the corresponding values provided in `repls`.
360- static std::string ggml_webgpu_process_shader_repls (const char * src,
361- const std::vector <std::pair<std:: string, std::string> > & repls) {
360+ static std::string ggml_webgpu_process_shader_repls (const char * src,
361+ const std::map <std::string, std::string> & repls) {
362362 if (!src) {
363363 return std::string ();
364364 }
@@ -1759,16 +1759,16 @@ static void ggml_webgpu_init_mul_mat_pipeline(webgpu_context & webgpu_ctx) {
17591759 wgsl_mul_mat_iq4_xs_f32, " mul_mat_iq4_xs_f32" );
17601760
17611761 if (webgpu_ctx->supports_subgroup_matrix ) {
1762- std::vector <std::pair<std:: string, std::string> > sg_matrix_repls;
1763- sg_matrix_repls. emplace_back ( " WEBGPU_MAX_SUBGROUP_SIZE" , std::to_string (webgpu_ctx->subgroup_size ) );
1764- sg_matrix_repls. emplace_back ( " WEBGPU_TILE_K" , std::to_string (WEBGPU_MUL_MAT_TILE_K) );
1765- sg_matrix_repls. emplace_back ( " WEBGPU_SUBGROUP_M" , std::to_string (WEBGPU_MUL_MAT_SUBGROUP_M) );
1766- sg_matrix_repls. emplace_back ( " WEBGPU_SUBGROUP_N" , std::to_string (WEBGPU_MUL_MAT_SUBGROUP_N) );
1767- sg_matrix_repls. emplace_back ( " WEBGPU_SUBGROUP_MATRIX_M" , std::to_string (WEBGPU_MUL_MAT_SUBGROUP_MATRIX_M) );
1768- sg_matrix_repls. emplace_back ( " WEBGPU_SUBGROUP_MATRIX_N" , std::to_string (WEBGPU_MUL_MAT_SUBGROUP_MATRIX_N) );
1769- sg_matrix_repls. emplace_back ( " WEBGPU_SG_MAT_M_SIZE" , std::to_string (webgpu_ctx->subgroup_matrix_config .M ) );
1770- sg_matrix_repls. emplace_back ( " WEBGPU_SG_MAT_N_SIZE" , std::to_string (webgpu_ctx->subgroup_matrix_config .N ) );
1771- sg_matrix_repls. emplace_back ( " WEBGPU_SG_MAT_K_SIZE" , std::to_string (webgpu_ctx->subgroup_matrix_config .K ) );
1762+ std::map <std::string, std::string> sg_matrix_repls;
1763+ sg_matrix_repls[ " WEBGPU_MAX_SUBGROUP_SIZE" ] = std::to_string (webgpu_ctx->subgroup_size );
1764+ sg_matrix_repls[ " WEBGPU_TILE_K" ] = std::to_string (WEBGPU_MUL_MAT_TILE_K);
1765+ sg_matrix_repls[ " WEBGPU_SUBGROUP_M" ] = std::to_string (WEBGPU_MUL_MAT_SUBGROUP_M);
1766+ sg_matrix_repls[ " WEBGPU_SUBGROUP_N" ] = std::to_string (WEBGPU_MUL_MAT_SUBGROUP_N);
1767+ sg_matrix_repls[ " WEBGPU_SUBGROUP_MATRIX_M" ] = std::to_string (WEBGPU_MUL_MAT_SUBGROUP_MATRIX_M);
1768+ sg_matrix_repls[ " WEBGPU_SUBGROUP_MATRIX_N" ] = std::to_string (WEBGPU_MUL_MAT_SUBGROUP_MATRIX_N);
1769+ sg_matrix_repls[ " WEBGPU_SG_MAT_M_SIZE" ] = std::to_string (webgpu_ctx->subgroup_matrix_config .M );
1770+ sg_matrix_repls[ " WEBGPU_SG_MAT_N_SIZE" ] = std::to_string (webgpu_ctx->subgroup_matrix_config .N );
1771+ sg_matrix_repls[ " WEBGPU_SG_MAT_K_SIZE" ] = std::to_string (webgpu_ctx->subgroup_matrix_config .K );
17721772
17731773 std::string proc_mul_mat_subgroup_matrix_f32_f32 =
17741774 ggml_webgpu_process_shader_repls (wgsl_mul_mat_subgroup_matrix_f32_f32, sg_matrix_repls);
@@ -1816,9 +1816,9 @@ static void ggml_webgpu_init_mul_mat_pipeline(webgpu_context & webgpu_ctx) {
18161816 mul_mat_reg_tile_constants[2 ].key = " WORKGROUP_SIZE_N" ;
18171817 mul_mat_reg_tile_constants[2 ].value = WEBGPU_MUL_MAT_WG_SIZE_N;
18181818
1819- std::vector <std::pair<std:: string, std::string> > reg_repls;
1820- reg_repls. emplace_back ( " WEBGPU_TILE_M" , std::to_string (WEBGPU_MUL_MAT_TILE_M) );
1821- reg_repls. emplace_back ( " WEBGPU_TILE_N" , std::to_string (WEBGPU_MUL_MAT_TILE_N) );
1819+ std::map <std::string, std::string> reg_repls;
1820+ reg_repls[ " WEBGPU_TILE_M" ] = std::to_string (WEBGPU_MUL_MAT_TILE_M);
1821+ reg_repls[ " WEBGPU_TILE_N" ] = std::to_string (WEBGPU_MUL_MAT_TILE_N);
18221822
18231823 // Process each reg-tile shader with tile replacements.
18241824 // Keep the processed strings in-scope so .c_str() remains valid.
0 commit comments