nx_vae_decode_stage.nx
buildroot/runtime/nx_vae_decode_stage.nx
about
nx_vae_decode_stage.nx -- one stage of a VAE decoder.
L4 composer. Closes the latent -> pixel path: VAE decoder = N
stacked stages of (ResBlock + optional 2x upsample), ending with
final GroupNorm + SiLU + 3x3 conv to RGB. This primitive
is one such stage; caller composes the full decoder.
===== Canonical SD VAE decoder topology =========================
Input: latent [N, 4, H, W] (typical: 64x64 for 512x512 image)
stage_in: conv2d 4 -> 512 ch
stage_mid: ResBlock 512 -> 512 (no upsample)
stage_up_0: ResBlock 512 -> 512, upsample 2x
stage_up_1: ResBlock 512 -> 512, upsample 2x
stage_up_2: ResBlock 512 -> 256, upsample 2x
stage_up_3: ResBlock 256 -> 128, no upsample
stage_out: GroupNorm + SiLU + conv2d 128 -> 3
Output: image [N, 3, 8H, 8W]
v1 substrate ships THIS PRIMITIVE for one (ResBlock + optional
upsample) stage. The CHANNEL CHANGE (e.g. 512 -> 256) is queued
for v2 (needs 1x1 skip conv in the ResBlock). v1 covers the
same-channel-count stages which are the majority.
Bits-up composition (pure):
nx_unet_block_forward (L4 ResBlock, shipped 6ede5571)
nx_upsample_2x (L3 upsample, shipped dbd26d43)
NxTensor (L1)
nx_loop (control)
genealogy_id: kingma_2014_vae + rombach_2022_stable_diffusion_autoencoder
lineage_id: substrate_vae_decode_stage_v1
dependencies 6 imports · 0 importers
imports: nx_syscalls.nxnx_tier.nxnx_loop.nxnx_tensor.nxnx_unet_block.nxnx_upsample.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 51 | const NX_VDS_OK: nx_int = 0 |
| 52 | const NX_VDS_ERR_BAD_DIMS: nx_int = 1 |
| 53 | const NX_VDS_ERR_SHAPE_MISMATCH: nx_int = 2 |
| 54 | const NX_VDS_ERR_INTERNAL: nx_int = 3 |
| 55 | const NX_VDS_N_VERDICTS: nx_int = 4 |
functions
| 57 | func nx_vds_verdict_is_valid(v: nx_int) -> nx_int called by 1: main |
| 84 | func nx_vae_decode_stage_forward( |
| 131 | func main() -> i64 |