| 168 | ) |
| 169 | |
| 170 | def assert_runtime_integrity( |
| 171 | self, x: torch.Tensor, cond: torch.Tensor, mod: torch.Tensor |
| 172 | ): |
| 173 | assert x is not None, f"Input tensor must be specified" |
| 174 | if self.block_type == "basic": |
| 175 | assert ( |
| 176 | cond is None and mod is None |
| 177 | ), f"Condition and modulation are not supported for BasicBlock" |
| 178 | elif "cond" in self.block_type: |
| 179 | assert ( |
| 180 | cond is not None and mod is None |
| 181 | ), f"Condition must be specified and modulation is not supported for ConditionBlock" |
| 182 | elif self.block_type == "mod": |
| 183 | raise NotImplementedError( |
| 184 | f"modulation without condition is not implemented" |
| 185 | ) |
| 186 | else: |
| 187 | assert ( |
| 188 | cond is not None and mod is not None |
| 189 | ), f"Condition and modulation must be specified for ConditionModulationBlock" |
| 190 | |
| 191 | def forward_layer( |
| 192 | self, layer: nn.Module, x: torch.Tensor, cond: torch.Tensor, mod: torch.Tensor |