| 270 | int dilation, |
| 271 | assets::TensorStorageType storage_type, |
| 272 | bool use_bias) { |
| 273 | const auto g = source.require_f32(prefix + ".weight_g", {in_channels, 1, 1}); |
| 274 | const auto v = source.require_f32(prefix + ".weight_v", {in_channels, out_channels, kernel}); |
| 275 | const auto graph_storage_type = |
| 276 | compatible_conv_transpose_storage_type(source, prefix + ".weight_v", storage_type); |
| 277 | WeightNormConvTranspose1dWeights out = {}; |
| 278 | out.stride = stride; |
| 279 | out.padding = padding; |
| 280 | out.dilation = dilation; |
| 281 | auto fused_weight = apply_weight_norm(g, v, in_channels, out_channels * kernel); |
| 282 | auto col_weight = conv_transpose_col_weight(fused_weight, in_channels, out_channels, kernel); |
| 283 | out.conv.weight = store.make_from_f32( |
| 284 | core::TensorShape::from_dims({in_channels, out_channels, kernel}), |
| 285 | graph_storage_type, |
| 286 | std::move(fused_weight)); |
| 287 | out.col_weight = store.make_from_f32( |
| 288 | core::TensorShape::from_dims({out_channels * kernel, in_channels}), |
| 289 | graph_storage_type, |
| 290 | std::move(col_weight)); |
| 291 | if (use_bias) { |
| 292 | out.conv.bias = store.load_f32_tensor(source, prefix + ".bias", {out_channels}); |
| 293 | } |
| 294 | return out; |
| 295 | } |
| 296 | |
| 297 | ResidualUnitWeights load_residual_unit( |
| 298 | core::BackendWeightStore & store, |
| 299 | const assets::TensorSource & source, |
| 300 | const std::string & prefix, |
| 301 | int64_t channels, |
| 302 | assets::TensorStorageType storage_type) { |
| 303 | ResidualUnitWeights out = {}; |
| 304 | out.snake1 = load_snake_exact(store, source, prefix + ".snake1", channels); |
| 305 | out.conv1 = load_weight_norm_conv1d(store, source, prefix + ".conv1", channels, channels, 7, 1, 3, 1, storage_type, true); |
| 306 | out.snake2 = load_snake_exact(store, source, prefix + ".snake2", channels); |
| 307 | out.conv2 = load_weight_norm_conv1d(store, source, prefix + ".conv2", channels, channels, 1, 1, 0, 1, storage_type, true); |
| 308 | return out; |
| 309 | } |
no test coverage detected