@@ -348,24 +348,40 @@ def __init__(
348348 for i_block in range (num_res_blocks ):
349349 out_ch = nf * ch_mult [i_level ]
350350# modules.append(ResnetBlock(in_ch=in_ch, out_ch=out_ch))
351- modules .append (ResnetNew (
352- in_channels = in_ch ,
353- out_channels = out_ch ,
354- temb_channels = 4 * nf ,
355- output_scale_factor = np .sqrt (2.0 ),
356- non_linearity = "silu" ,
357- groups = min (in_ch // 4 , 32 ),
358- groups_out = min (out_ch // 4 , 32 ),
359- overwrite_for_score_vde = True ,
360- ))
351+ modules .append (
352+ ResnetNew (
353+ in_channels = in_ch ,
354+ out_channels = out_ch ,
355+ temb_channels = 4 * nf ,
356+ output_scale_factor = np .sqrt (2.0 ),
357+ non_linearity = "silu" ,
358+ groups = min (in_ch // 4 , 32 ),
359+ groups_out = min (out_ch // 4 , 32 ),
360+ overwrite_for_score_vde = True ,
361+ )
362+ )
361363 in_ch = out_ch
362364
363365 if all_resolutions [i_level ] in attn_resolutions :
364366 modules .append (AttnBlock (channels = in_ch ))
365367 hs_c .append (in_ch )
366368
367369 if i_level != self .num_resolutions - 1 :
368- modules .append (ResnetBlock (down = True , in_ch = in_ch ))
370+ # modules.append(ResnetBlock(down=True, in_ch=in_ch))
371+ modules .append (
372+ ResnetNew (
373+ in_channels = in_ch ,
374+ temb_channels = 4 * nf ,
375+ output_scale_factor = np .sqrt (2.0 ),
376+ non_linearity = "silu" ,
377+ groups = min (in_ch // 4 , 32 ),
378+ groups_out = min (out_ch // 4 , 32 ),
379+ overwrite_for_score_vde = True ,
380+ down = True ,
381+ kernel = "fir" , # TODO(Patrick) - it seems like both fir and non-fir kernels are fine
382+ use_nin_shortcut = True ,
383+ )
384+ )
369385
370386 if progressive_input == "input_skip" :
371387 modules .append (combiner (dim1 = input_pyramid_ch , dim2 = in_ch ))
@@ -379,16 +395,50 @@ def __init__(
379395 hs_c .append (in_ch )
380396
381397 in_ch = hs_c [- 1 ]
382- modules .append (ResnetBlock (in_ch = in_ch ))
398+ # modules.append(ResnetBlock(in_ch=in_ch))
399+ modules .append (
400+ ResnetNew (
401+ in_channels = in_ch ,
402+ temb_channels = 4 * nf ,
403+ output_scale_factor = np .sqrt (2.0 ),
404+ non_linearity = "silu" ,
405+ groups = min (in_ch // 4 , 32 ),
406+ groups_out = min (out_ch // 4 , 32 ),
407+ overwrite_for_score_vde = True ,
408+ )
409+ )
383410 modules .append (AttnBlock (channels = in_ch ))
384- modules .append (ResnetBlock (in_ch = in_ch ))
411+ # modules.append(ResnetBlock(in_ch=in_ch))
412+ modules .append (
413+ ResnetNew (
414+ in_channels = in_ch ,
415+ temb_channels = 4 * nf ,
416+ output_scale_factor = np .sqrt (2.0 ),
417+ non_linearity = "silu" ,
418+ groups = min (in_ch // 4 , 32 ),
419+ groups_out = min (out_ch // 4 , 32 ),
420+ overwrite_for_score_vde = True ,
421+ )
422+ )
385423
386424 pyramid_ch = 0
387425 # Upsampling block
388426 for i_level in reversed (range (self .num_resolutions )):
389427 for i_block in range (num_res_blocks + 1 ):
390428 out_ch = nf * ch_mult [i_level ]
391- modules .append (ResnetBlock (in_ch = in_ch + hs_c .pop (), out_ch = out_ch ))
429+ # modules.append(ResnetBlock(in_ch=in_ch + hs_c.pop(), out_ch=out_ch))
430+ modules .append (
431+ ResnetNew (
432+ in_channels = in_ch + hs_c .pop (),
433+ out_channels = out_ch ,
434+ temb_channels = 4 * nf ,
435+ output_scale_factor = np .sqrt (2.0 ),
436+ non_linearity = "silu" ,
437+ groups = min (in_ch // 4 , 32 ),
438+ groups_out = min (out_ch // 4 , 32 ),
439+ overwrite_for_score_vde = True ,
440+ )
441+ )
392442 in_ch = out_ch
393443
394444 if all_resolutions [i_level ] in attn_resolutions :
@@ -420,7 +470,21 @@ def __init__(
420470 raise ValueError (f"{ progressive } is not a valid name" )
421471
422472 if i_level != 0 :
423- modules .append (ResnetBlock (in_ch = in_ch , up = True ))
473+ # modules.append(ResnetBlock(in_ch=in_ch, up=True))
474+ modules .append (
475+ ResnetNew (
476+ in_channels = in_ch ,
477+ temb_channels = 4 * nf ,
478+ output_scale_factor = np .sqrt (2.0 ),
479+ non_linearity = "silu" ,
480+ groups = min (in_ch // 4 , 32 ),
481+ groups_out = min (out_ch // 4 , 32 ),
482+ overwrite_for_score_vde = True ,
483+ up = True ,
484+ kernel = "fir" ,
485+ use_nin_shortcut = True ,
486+ )
487+ )
424488
425489 assert not hs_c
426490
0 commit comments