DiffusionResBlock<T>
Models & Types · AiDotNet.Diffusion.NoisePredictors
Implements a residual block per the DDPM (Ho et al. 2020) and Stable Diffusion (Rombach et al. 2022) U-Net architecture with time embedding conditioning.
Inheritance: LayerBase<T> → DiffusionResBlock<T>
Implements: IShapeContract
How It Works
The forward pass implements the following computation:
where skip_conv is a 1x1 convolution if inChannels != outChannels, otherwise identity.
Performance: all intermediate tensors use TensorAllocator for pooled allocation.
GroupNorm uses 32 groups (SD standard) with channels that aren’t divisible by 32 falling back
to the largest divisor.
Constructors
| Constructor | Summary |
|---|---|
DiffusionResBlock(int inChannels, int outChannels, int spatialSize, int timeEmbedDim, int numGroups, double epsilon) |
Creates a new diffusion residual block per the DDPM/Stable Diffusion paper. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<LayerPort> InputPorts { get; } |
|
bool SupportsTraining { get; } |
|
int InputChannels { get; } |
Gets the input channel count. |
int OutputChannels { get; } |
Gets the output channel count. |
int TimeEmbeddingDimension { get; } |
Gets the timestep-embedding width. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<ILayer<T>> GetSubLayers() |
|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
Tensor<T> Forward(Tensor<T> input, Tensor<T> timeEmbed) |
Forward pass with time embedding conditioning per the DDPM paper. |
void ResetState() |
|
void SetTrainingMode(bool isTraining) |
Propagates eval/training mode to the block’s nested sublayers. |
void UpdateParameters(T learningRate) |