(x, scale: int = 2)
| 8 | |
| 9 | # from https://github.com/ml-explore/mlx-examples/blob/main/stable_diffusion/stable_diffusion/unet.py |
| 10 | def upsample_nearest(x, scale: int = 2): |
| 11 | B, H, W, C = x.shape |
| 12 | x = mx.broadcast_to(x[:, :, None, :, None, :], (B, H, scale, W, scale, C)) |
| 13 | x = x.reshape(B, H * scale, W * scale, C) |
| 14 | return x |
| 15 | |
| 16 | |
| 17 | class UpsamplingConv2d(nn.Module): |