LayerInputDomain

Structs · AiDotNet.NeuralNetworks.Layers

Describes what a layer will ACCEPT in its input tensor, so callers can generate or validate conforming data without inspecting the layer’s type.

Inheritance: ValueType → LayerInputDomain

How It Works

This contract complements a layer’s shape contract. EmbeddingLayer is an index lookup by construction, while continuous feature projection is represented explicitly by a projection layer. Callers therefore do not need to inspect values or guess a mode from tensor shape.

Data flows from the declared contract: a caller asks the layer what it accepts and produces values that conform. No value inspection changes layer behavior, and output rank remains a function of the declared layer and input shape.

Without this, the only way to feed a token model was to hand-write a per-model override that knew the vocabulary size – which is the hand-maintained surface the parameter automation exists to delete. A layer already knows its own domain; asking it is free.

Properties

Property Summary
LayerInputDomain AdditiveMask { get; } An additive attention mask: zero keeps an element and a negative value masks it.
LayerInputDomain BooleanMask { get; } A Boolean mask represented by the numeric tensor type.
LayerInputDomain Continuous { get; } Any real value.
LayerInputDomain Unspecified { get; } Preserves the primary input domain.
LayerInputDomainKind Kind { get; } Whether the input holds continuous values or integer indices.
bool IsIndices { get; } True when this domain constrains values to integer indices.
bool IsPreserved { get; } Whether the domain represents an identity relationship to another port.
bool IsResolved { get; } Whether the domain can be validated and synthesized without further binding.
int MaxExclusive { get; } One past the largest legal index (the vocabulary size).
int MinInclusive { get; } Smallest legal index.
string Detail { get; } Source port for a preserve relationship, explanation for a deferred domain, or stable key for a custom domain.

Methods

Method Summary
LayerInputDomain Custom(string providerKey) Creates a custom domain identified by a stable provider key.
LayerInputDomain Deferred(string reason) Creates a non-executable domain with an actionable explanation.
LayerInputDomain Indices(int minInclusive, int maxExclusive) Integer indices in the half-open interval [minInclusive, maxExclusive).
LayerInputDomain Indices(int vocabularySize) Integer indices in [0, vocabularySize).
LayerInputDomain Preserve(string sourcePort) Preserves the value domain of sourcePort.
LayerInputDomainCompatibility CompatibilityWith(LayerInputDomain producer) Proves whether this consumer accepts values produced under producer.
bool Accepts(LayerInputDomain producer) Whether this consumer is already proven to accept producer.
string ToString()