@@ -201,13 +201,19 @@ def __call__(self, x: jax.Array) -> jax.Array:
201201 n , h , w , c = in_shape
202202 target_h = int (h * self .scale_factor [0 ])
203203 target_w = int (w * self .scale_factor [1 ])
204- if self .method == "nearest" and self .scale_factor [0 ] == int (self .scale_factor [0 ]) and self .scale_factor [1 ] == int (self .scale_factor [1 ]):
204+ if (
205+ self .method == "nearest"
206+ and self .scale_factor [0 ] == int (self .scale_factor [0 ])
207+ and self .scale_factor [1 ] == int (self .scale_factor [1 ])
208+ ):
205209 scale_h = int (self .scale_factor [0 ])
206210 scale_w = int (self .scale_factor [1 ])
207211 out = jnp .repeat (jnp .repeat (x , scale_h , axis = 1 ), scale_w , axis = 2 )
208212 else :
209213 if self .method == "nearest" :
210- max_logging .log (f"Warning: WanUpsample2D nearest method requested but scale_factor { self .scale_factor } is not integer. Falling back to jax.image.resize." )
214+ max_logging .log (
215+ f"Warning: WanUpsample2D nearest method requested but scale_factor { self .scale_factor } is not integer. Falling back to jax.image.resize."
216+ )
211217 out = jax .image .resize (x .astype (jnp .float32 ), (n , target_h , target_w , c ), method = self .method )
212218 out = out .astype (input_dtype )
213219 return out
@@ -1234,7 +1240,10 @@ def scan_fn(carry, chunk):
12341240 if spatial_sharding is not None :
12351241 out_chunk = jax .lax .with_sharding_constraint (out_chunk , spatial_sharding )
12361242 next_feat_map = jax .tree_util .tree_map (
1237- lambda x : jax .lax .with_sharding_constraint (x , spatial_sharding ) if spatial_sharding is not None and hasattr (x , "shape" ) and x .ndim == len (spatial_sharding .spec ) else x , next_feat_map
1243+ lambda x : jax .lax .with_sharding_constraint (x , spatial_sharding )
1244+ if spatial_sharding is not None and hasattr (x , "shape" ) and x .ndim == len (spatial_sharding .spec )
1245+ else x ,
1246+ next_feat_map ,
12381247 )
12391248 return next_feat_map , out_chunk
12401249
@@ -1333,7 +1342,9 @@ def scan_fn(carry, chunk_in):
13331342 if spatial_sharding is not None :
13341343 out_chunk = jax .lax .with_sharding_constraint (out_chunk , spatial_sharding )
13351344 next_feat_map = jax .tree_util .tree_map (
1336- lambda x : jax .lax .with_sharding_constraint (x , spatial_sharding ) if spatial_sharding is not None and hasattr (x , "shape" ) and x .ndim == len (spatial_sharding .spec ) else x ,
1345+ lambda x : jax .lax .with_sharding_constraint (x , spatial_sharding )
1346+ if spatial_sharding is not None and hasattr (x , "shape" ) and x .ndim == len (spatial_sharding .spec )
1347+ else x ,
13371348 next_feat_map ,
13381349 )
13391350 return next_feat_map , out_chunk
0 commit comments