code wiki / (root) / nx_vae_decode_stage.nx

nx_vae_decode_stage.nx

buildroot/runtime/nx_vae_decode_stage.nx

8293 B212 linesdepth 9pulls 19 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_loop.nx nx_tensor.nx nx_unet_block.nx nx_upsample.nx nx_vae_decode_stage.nx

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

main sys_mmap nx_t_alloc nx_dt_is_valid nx_dt_element_bytes sys_mmap ↻ nx_t_compute_strides_rowma nx_vae_decode_stage_forwar nx_unet_block_forward nx_groupnorm_forward nx_t_is_contiguous nx_isqrt_q10 nx_isqrt nx_silu_forward nx_t_is_contiguous ↻ nx_silu_q10 nx_sigmoid_q10 nx_exp_q10_neg nx_conv2d_forward nx_t_is_contiguous ↻ nx_upsample_2x nx_t_is_contiguous ↻ _up_nearest _up_bilinear nx_vds_verdict_is_valid

structs

none

consts

51const NX_VDS_OK: nx_int = 0
52const NX_VDS_ERR_BAD_DIMS: nx_int = 1
53const NX_VDS_ERR_SHAPE_MISMATCH: nx_int = 2
54const NX_VDS_ERR_INTERNAL: nx_int = 3
55const NX_VDS_N_VERDICTS: nx_int = 4

functions

57func nx_vds_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
84func nx_vae_decode_stage_forward(
131func main() -> i64