MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / FlaxDownsample2D

Class FlaxDownsample2D

diffusers/src/diffusers/models/vae_flax.py:95–122  ·  view source on GitHub ↗

Flax implementation of 2D Downsample layer Args: in_channels (`int`): Input channels dtype (:obj:`jnp.dtype`, *optional*, defaults to jnp.float32): Parameters `dtype`

Source from the content-addressed store, hash-verified

93
94
95class FlaxDownsample2D(nn.Module):
96 """
97 Flax implementation of 2D Downsample layer
98
99 Args:
100 in_channels (`int`):
101 Input channels
102 dtype (:obj:`jnp.dtype`, *optional*, defaults to jnp.float32):
103 Parameters `dtype`
104 """
105
106 in_channels: int
107 dtype: jnp.dtype = jnp.float32
108
109 def setup(self):
110 self.conv = nn.Conv(
111 self.in_channels,
112 kernel_size=(3, 3),
113 strides=(2, 2),
114 padding="VALID",
115 dtype=self.dtype,
116 )
117
118 def __call__(self, hidden_states):
119 pad = ((0, 0), (0, 1), (0, 1), (0, 0)) # pad height and width dim
120 hidden_states = jnp.pad(hidden_states, pad_width=pad)
121 hidden_states = self.conv(hidden_states)
122 return hidden_states
123
124
125class FlaxResnetBlock2D(nn.Module):

Callers 3

setupMethod · 0.70
setupMethod · 0.50
setupMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected