Build a single task queue for the encoder or decoder @param net: the VAE decoder or encoder network @param is_decoder: currently building decoder or encoder @return: the task queue
(net, is_decoder)
| 329 | |
| 330 | |
| 331 | def build_task_queue(net, is_decoder): |
| 332 | """ |
| 333 | Build a single task queue for the encoder or decoder |
| 334 | @param net: the VAE decoder or encoder network |
| 335 | @param is_decoder: currently building decoder or encoder |
| 336 | @return: the task queue |
| 337 | """ |
| 338 | task_queue = [] |
| 339 | task_queue.append(('conv_in', net.conv_in)) |
| 340 | |
| 341 | # construct the sampling part of the task queue |
| 342 | # because encoder and decoder share the same architecture, we extract the sampling part |
| 343 | build_sampling(task_queue, net, is_decoder) |
| 344 | if is_decoder and not sd_flag: |
| 345 | net.give_pre_end = False |
| 346 | net.tanh_out = False |
| 347 | |
| 348 | if not is_decoder or not net.give_pre_end: |
| 349 | if sd_flag: |
| 350 | task_queue.append(('pre_norm', net.norm_out)) |
| 351 | else: |
| 352 | task_queue.append(('pre_norm', net.conv_norm_out)) |
| 353 | task_queue.append(('silu', inplace_nonlinearity)) |
| 354 | task_queue.append(('conv_out', net.conv_out)) |
| 355 | if is_decoder and net.tanh_out: |
| 356 | task_queue.append(('tanh', torch.tanh)) |
| 357 | |
| 358 | return task_queue |
| 359 | |
| 360 | |
| 361 | def clone_task_queue(task_queue): |
no test coverage detected