@@ -310,17 +310,20 @@ class Generator: Module {
310310
311311 func callAsFunction( _ x: MLXArray , f0: MLXArray , g: MLXArray ? = nil ) -> MLXArray {
312312 var out = conv_pre ( x)
313+ print ( " DEBUG: Generator.conv_pre out: [ \( out. min ( ) . item ( Float . self) ) ... \( out. max ( ) . item ( Float . self) ) ] " )
313314
314315 // Add speaker conditioning if available
315316 if let g = g, let condLayer = cond {
316317 out = out + condLayer( g)
318+ print ( " DEBUG: Generator.cond added: [ \( out. min ( ) . item ( Float . self) ) ... \( out. max ( ) . item ( Float . self) ) ] " )
317319 }
318320
319321
320322 // NSF Source Signal: [B, L*U, 1] (High Resolution)
321323 // upp = prod(upsampleRates) = 400
322324 let upp = 400
323325 let har_source = m_source ( f0, upsampling_factor: upp)
326+ print ( " DEBUG: Generator.har_source: [ \( har_source. min ( ) . item ( Float . self) ) ... \( har_source. max ( ) . item ( Float . self) ) ] " )
324327 // har_source is now [B, AudioLen, 1]
325328
326329 var resIdx = 0
@@ -332,16 +335,12 @@ class Generator: Module {
332335 // Add NSF Noise
333336 // noise_conv reduces har_source resolution to match current 'out'
334337 let noise_conv = noise_convs [ i]
335- // We need to transpose har_source to [B, 1, T] ?? No. MLX is [N, L, C].
336- // har_source is [N, T, 1]. noise_conv(1->C) -> [N, T_down, C].
337- // Should match 'out' shape.
338338 let n = noise_conv ( har_source)
339339
340- // Crop if necessary (Python does: if x.shape[1] != n.shape[1])
340+ // Crop if necessary
341341 if out. shape [ 1 ] != n. shape [ 1 ] {
342342 let minLen = min ( out. shape [ 1 ] , n. shape [ 1 ] )
343343 out = out [ 0 ... , 0 ..< minLen, 0 ... ]
344- // n = n[0..., 0..<minLen, 0...] // n is let constant, but we add it.
345344 out = out + n[ 0 ... , 0 ..< minLen, 0 ... ]
346345 } else {
347346 out = out + n
@@ -358,11 +357,15 @@ class Generator: Module {
358357 }
359358 // Average
360359 out = xs! / 3.0
360+ print ( " DEBUG: Generator.ups[ \( i) ] (after resblocks) out: [ \( out. min ( ) . item ( Float . self) ) ... \( out. max ( ) . item ( Float . self) ) ] " )
361361 }
362362
363363 out = leakyRelu ( out)
364364 out = conv_post ( out)
365+ print ( " DEBUG: Generator.conv_post out: [ \( out. min ( ) . item ( Float . self) ) ... \( out. max ( ) . item ( Float . self) ) ] " )
366+
365367 out = tanh ( out)
368+ print ( " DEBUG: Generator.final (tanh): [ \( out. min ( ) . item ( Float . self) ) ... \( out. max ( ) . item ( Float . self) ) ] " )
366369 return out
367370 }
368371}
0 commit comments