| 114 | for (int64_t i = 0; i < inner; ++i) { |
| 115 | out[base + static_cast<size_t>(i)] = weight_v[base + static_cast<size_t>(i)] * scale; |
| 116 | } |
| 117 | } |
| 118 | return out; |
| 119 | } |
| 120 | |
| 121 | modules::Conv1dWeights load_weight_norm_conv1d( |
| 122 | core::BackendWeightStore & store, |
| 123 | const assets::TensorSource & source, |
| 124 | const std::string & prefix, |
| 125 | assets::TensorStorageType storage_type, |
| 126 | int64_t out_channels, |
| 127 | int64_t in_channels, |
| 128 | int64_t kernel, |
| 129 | bool use_bias) { |
| 130 | auto conv_storage_type = assets::resolve_tensor_storage_type(source, prefix + ".weight_v", storage_type); |
| 131 | const ggml_type conv_ggml_type = assets::ggml_type_for_tensor_storage(conv_storage_type); |
| 132 | if (ggml_is_quantized(conv_ggml_type) && kernel % ggml_blck_size(conv_ggml_type) != 0) { |
| 133 | conv_storage_type = assets::TensorStorageType::F32; |
| 134 | } |
| 135 | const auto weight_v = source.require_f32(prefix + ".weight_v", {out_channels, in_channels, kernel}); |
| 136 | const auto weight_g = squeeze_weight_g(source.require_f32(prefix + ".weight_g", {out_channels, 1, 1}), out_channels, prefix); |
| 137 | modules::Conv1dWeights weights; |
| 138 | weights.weight = store.make_from_f32( |
| 139 | core::TensorShape::from_dims({out_channels, in_channels, kernel}), |
| 140 | conv_storage_type, |
| 141 | fold_weight_norm_dim0(weight_v, weight_g, out_channels, in_channels, kernel, prefix)); |
| 142 | if (use_bias) { |
| 143 | weights.bias = store.load_f32_tensor(source, prefix + ".bias", {out_channels}); |
| 144 | } |
no test coverage detected