MCPcopy Create free account
hub / github.com/AlayaLab/Hive / forward

Method forward

models/flowsep/diffusers/models/vae.py:108–149  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

106 self.gradient_checkpointing = False
107
108 def forward(self, x):
109 sample = x
110 sample = self.conv_in(sample)
111
112 if self.training and self.gradient_checkpointing:
113
114 def create_custom_forward(module):
115 def custom_forward(*inputs):
116 return module(*inputs)
117
118 return custom_forward
119
120 # down
121 if is_torch_version(">=", "1.11.0"):
122 for down_block in self.down_blocks:
123 sample = torch.utils.checkpoint.checkpoint(
124 create_custom_forward(down_block), sample, use_reentrant=False
125 )
126 # middle
127 sample = torch.utils.checkpoint.checkpoint(
128 create_custom_forward(self.mid_block), sample, use_reentrant=False
129 )
130 else:
131 for down_block in self.down_blocks:
132 sample = torch.utils.checkpoint.checkpoint(create_custom_forward(down_block), sample)
133 # middle
134 sample = torch.utils.checkpoint.checkpoint(create_custom_forward(self.mid_block), sample)
135
136 else:
137 # down
138 for down_block in self.down_blocks:
139 sample = down_block(sample)
140
141 # middle
142 sample = self.mid_block(sample)
143
144 # post-process
145 sample = self.conv_norm_out(sample)
146 sample = self.conv_act(sample)
147 sample = self.conv_out(sample)
148
149 return sample
150
151
152class Decoder(nn.Module):

Callers

nothing calls this directly

Calls 1

is_torch_versionFunction · 0.85

Tested by

no test coverage detected