README

mizchi/webnn/model does not have a README file

#
AttentionMask

pub struct AttentionMask {
shape_ :
Shape

values_ : Array[Float]
}

Materializable additive attention-mask data.

The shape is [1, tokens, tokens] so it broadcasts across attention heads. Allowed score positions contain zero and masked positions contain the caller-provided negative value.

#
AttentionMask::additive

#
AttentionMask::batched_causal_padding

fn AttentionMask::batched_causal_padding(valid_batches : Array[Array[Bool]], masked_value : Float) -> AttentionMask raise
TensorError

#
AttentionMask::batched_padding

fn AttentionMask::batched_padding(valid_batches : Array[Array[Bool]], masked_value : Float) -> AttentionMask raise
TensorError

#
AttentionMask::causal

fn AttentionMask::causal(tokens : Int, masked_value : Float) -> AttentionMask raise
TensorError

#
AttentionMask::causal_padding

fn AttentionMask::causal_padding(valid_tokens : Array[Bool], masked_value : Float) -> AttentionMask raise
TensorError

#
AttentionMask::padding

fn AttentionMask::padding(valid_tokens : Array[Bool], masked_value : Float) -> AttentionMask raise
TensorError

#
AttentionMask::shape

#
AttentionMask::values

fn AttentionMask::values(self : AttentionMask) -> Array[Float]

#
BertEncoderBlock

pub(all) struct BertEncoderBlock[T] {
attention : SelfAttention[T]
attention_output_normalization : LayerNorm[T]
feed_forward : FeedForward[T]
output_normalization : LayerNorm[T]
}

A BERT encoder layer using the original post-normalization order.

Dropout is intentionally absent because this model represents inference. SelfAttention and FeedForward remain reusable pure sublayers; this block owns the residual and LayerNorm boundaries required by BERT checkpoints.

#
BertEncoderBlock::forward

fn[T :
TensorOps
] BertEncoderBlock::forward(self : BertEncoderBlock[T], input : T) -> T raise

#
BertEncoderConfig

pub struct BertEncoderConfig {
encoder_ : TransformerEncoderConfig
layers_ : Int
}

Shape and numerical configuration for an inference-only BERT encoder.

#
BertEncoderConfig::encoder

#
BertEncoderConfig::heads

fn BertEncoderConfig::heads(self : BertEncoderConfig) -> Int

#
BertEncoderConfig::intermediate_size

fn BertEncoderConfig::intermediate_size(self : BertEncoderConfig) -> Int

#
BertEncoderConfig::layers

fn BertEncoderConfig::layers(self : BertEncoderConfig) -> Int

#
BertEncoderConfig::new

fn BertEncoderConfig::new(layers : Int, width : Int, heads : Int, intermediate_size : Int, input_rank : Int, epsilon : Float) -> BertEncoderConfig raise
TensorError

#
BertEncoderConfig::width

fn BertEncoderConfig::width(self : BertEncoderConfig) -> Int

#
BertEncoderParameters

pub struct BertEncoderParameters {
layers_ : Array[TransformerEncoderParameters]
}

Owned per-layer parameters for a BERT encoder stack.

#
BertEncoderParameters::layers

#
BertEncoderStack

pub struct BertEncoderStack[T] {
layers_ : Array[BertEncoderBlock[T]]
}

A non-empty sequence of post-normalization BERT encoder layers.

#
BertEncoderStack::forward

fn[T :
TensorOps
] BertEncoderStack::forward(self : BertEncoderStack[T], input : T) -> T raise

#
BertEncoderStack::layer_count

fn[T] BertEncoderStack::layer_count(self : BertEncoderStack[T]) -> Int

#
Conv2dLayer

pub(all) struct Conv2dLayer[T] {
weight : T
bias : T
options :
Conv2dOptions

}

#
Conv2dLayer::forward

fn[T :
TensorOps
] Conv2dLayer::forward(self : Conv2dLayer[T], input : T) -> T raise

#
FeedForward

pub(all) struct FeedForward[T] {
input_projection : Linear[T]
output_projection : Linear[T]
}

Position-wise Transformer feed-forward network without normalization or a residual connection. Those concerns belong to TransformerEncoderBlock.

#
FeedForward::forward

fn[T :
TensorOps
] FeedForward::forward(self : FeedForward[T], input : T) -> T raise

#
FeedForwardParameters

pub struct FeedForwardParameters {
width_ : Int
hidden_size_ : Int
input_weight_ : Array[Float]
input_bias_ : Array[Float]
output_weight_ : Array[Float]
output_bias_ : Array[Float]
}

#
FeedForwardParameters::input_bias

fn FeedForwardParameters::input_bias(self : FeedForwardParameters) -> Array[Float]

#
FeedForwardParameters::input_weight

fn FeedForwardParameters::input_weight(self : FeedForwardParameters) -> Array[Float]

#
FeedForwardParameters::matches

#
FeedForwardParameters::new

fn FeedForwardParameters::new(config : TransformerEncoderConfig, input_weight : Array[Float], input_bias : Array[Float], output_weight : Array[Float], output_bias : Array[Float]) -> FeedForwardParameters raise
TensorError

#
FeedForwardParameters::output_bias

fn FeedForwardParameters::output_bias(self : FeedForwardParameters) -> Array[Float]

#
FeedForwardParameters::output_weight

fn FeedForwardParameters::output_weight(self : FeedForwardParameters) -> Array[Float]

#
LayerNorm

pub(all) struct LayerNorm[T] {
scale : T
bias : T
axes : Array[Int]
epsilon : Float
}

Layer normalization with explicit axes and epsilon.

#
LayerNorm::forward

fn[T :
TensorOps
] LayerNorm::forward(self : LayerNorm[T], input : T) -> T raise

#
Linear

pub(all) struct Linear[T] {
weight : T
bias : T
}

#
Linear::forward

fn[T :
TensorOps
] Linear::forward(self : Linear[T], input : T) -> T raise

#
Mlp

pub(all) struct Mlp[T] {
hidden : Linear[T]
output : Linear[T]
}

#
Mlp::forward

fn[T :
TensorOps
] Mlp::forward(self : Mlp[T], input : T) -> T raise

#
MlpParams

pub(all) struct MlpParams {
weight1 : Array[Float]
bias1 : Array[Float]
weight2 : Array[Float]
bias2 : Array[Float]
}

#
SelfAttention

pub(all) struct SelfAttention[T] {
query : Linear[T]
key : Linear[T]
value : Linear[T]
output : Linear[T]
score_scale : T
additive_mask : T?
heads : Int
}

Fixed-shape self-attention shared by CPU and WebNN backends.

Input and output use [tokens, width] or [batch, tokens, width]. Internally, projections are reshaped by head; batched matmul computes every batch and head together. This layer returns only the projected attention; residual addition belongs to a Transformer block.

#
SelfAttention::forward

fn[T :
TensorOps
] SelfAttention::forward(self : SelfAttention[T], input : T) -> T raise

#
SelfAttentionConfig

pub struct SelfAttentionConfig {
width_ : Int
heads_ : Int
}

#
SelfAttentionConfig::head_size

fn SelfAttentionConfig::head_size(self : SelfAttentionConfig) -> Int

#
SelfAttentionConfig::heads

fn SelfAttentionConfig::heads(self : SelfAttentionConfig) -> Int

#
SelfAttentionConfig::new

#
SelfAttentionConfig::score_scale

fn SelfAttentionConfig::score_scale(self : SelfAttentionConfig) -> Float

#
SelfAttentionConfig::width

fn SelfAttentionConfig::width(self : SelfAttentionConfig) -> Int

#
SelfAttentionParameters

pub struct SelfAttentionParameters {
width_ : Int
heads_ : Int
query_weight_ : Array[Float]
query_bias_ : Array[Float]
key_weight_ : Array[Float]
key_bias_ : Array[Float]
value_weight_ : Array[Float]
value_bias_ : Array[Float]
output_weight_ : Array[Float]
output_bias_ : Array[Float]
}

#
SelfAttentionParameters::key_bias

#
SelfAttentionParameters::key_weight

fn SelfAttentionParameters::key_weight(self : SelfAttentionParameters) -> Array[Float]

#
SelfAttentionParameters::matches

#
SelfAttentionParameters::new

fn SelfAttentionParameters::new(config : SelfAttentionConfig, query_weight : Array[Float], query_bias : Array[Float], key_weight : Array[Float], key_bias : Array[Float], value_weight : Array[Float], value_bias : Array[Float], output_weight : Array[Float], output_bias : Array[Float]) -> SelfAttentionParameters raise
TensorError

#
SelfAttentionParameters::output_bias

fn SelfAttentionParameters::output_bias(self : SelfAttentionParameters) -> Array[Float]

#
SelfAttentionParameters::output_weight

fn SelfAttentionParameters::output_weight(self : SelfAttentionParameters) -> Array[Float]

#
SelfAttentionParameters::query_bias

fn SelfAttentionParameters::query_bias(self : SelfAttentionParameters) -> Array[Float]

#
SelfAttentionParameters::query_weight

fn SelfAttentionParameters::query_weight(self : SelfAttentionParameters) -> Array[Float]

#
SelfAttentionParameters::value_bias

fn SelfAttentionParameters::value_bias(self : SelfAttentionParameters) -> Array[Float]

#
SelfAttentionParameters::value_weight

fn SelfAttentionParameters::value_weight(self : SelfAttentionParameters) -> Array[Float]

#
TinyCnn

pub(all) struct TinyCnn[T] {
convolution : Conv2dLayer[T]
classifier : Linear[T]
}

#
TinyCnn::forward

fn[T :
TensorOps
] TinyCnn::forward(self : TinyCnn[T], input : T) -> T raise

#
TransformerBlock

pub(all) struct TransformerBlock[T] {
input_projection : Linear[T]
normalization_scale : T
normalization_bias : T
output_projection : Linear[T]
normalization_axes : Array[Int]
epsilon : Float
}

A fixed-shape Transformer-style feed-forward block.

The first projection changes the feature width, layer normalization and GELU operate in that hidden space, and the second projection restores the input width before the residual addition.

#
TransformerBlock::forward

fn[T :
TensorOps
] TransformerBlock::forward(self : TransformerBlock[T], input : T) -> T raise

#
TransformerEncoderBlock

pub(all) struct TransformerEncoderBlock[T] {
attention_normalization : LayerNorm[T]
attention : SelfAttention[T]
feed_forward_normalization : LayerNorm[T]
feed_forward : FeedForward[T]
}

A pre-normalization Transformer encoder block.

Both sublayers share the same backend type, so one model definition can be materialized for CPU or WebNN execution. SelfAttention and FeedForward do not own residual connections; this block defines both residual boundaries.

#
TransformerEncoderBlock::forward

#
TransformerEncoderConfig

pub struct TransformerEncoderConfig {
attention_ : SelfAttentionConfig
hidden_size_ : Int
input_rank_ : Int
epsilon_ : Float
}

#
TransformerEncoderConfig::attention

#
TransformerEncoderConfig::epsilon

#
TransformerEncoderConfig::heads

#
TransformerEncoderConfig::hidden_size

fn TransformerEncoderConfig::hidden_size(self : TransformerEncoderConfig) -> Int

#
TransformerEncoderConfig::input_rank

#
TransformerEncoderConfig::new

fn TransformerEncoderConfig::new(width : Int, heads : Int, hidden_size : Int, input_rank : Int, epsilon : Float) -> TransformerEncoderConfig raise
TensorError

#
TransformerEncoderConfig::normalization_axis

fn TransformerEncoderConfig::normalization_axis(self : TransformerEncoderConfig) -> Int

#
TransformerEncoderConfig::width

#
TransformerEncoderParameters

pub struct TransformerEncoderParameters {
width_ : Int
heads_ : Int
hidden_size_ : Int
attention_normalization_scale_ : Array[Float]
attention_normalization_bias_ : Array[Float]
attention_ : SelfAttentionParameters
feed_forward_normalization_scale_ : Array[Float]
feed_forward_normalization_bias_ : Array[Float]
feed_forward_ : FeedForwardParameters
}

#
TransformerEncoderParameters::attention

#
TransformerEncoderParameters::attention_normalization_bias

fn TransformerEncoderParameters::attention_normalization_bias(self : TransformerEncoderParameters) -> Array[Float]

#
TransformerEncoderParameters::attention_normalization_scale

fn TransformerEncoderParameters::attention_normalization_scale(self : TransformerEncoderParameters) -> Array[Float]

#
TransformerEncoderParameters::feed_forward

#
TransformerEncoderParameters::feed_forward_normalization_bias

fn TransformerEncoderParameters::feed_forward_normalization_bias(self : TransformerEncoderParameters) -> Array[Float]

#
TransformerEncoderParameters::feed_forward_normalization_scale

fn TransformerEncoderParameters::feed_forward_normalization_scale(self : TransformerEncoderParameters) -> Array[Float]

#
TransformerEncoderParameters::matches

#
TransformerEncoderParameters::new

fn TransformerEncoderParameters::new(config : TransformerEncoderConfig, attention_normalization_scale : Array[Float], attention_normalization_bias : Array[Float], attention : SelfAttentionParameters, feed_forward_normalization_scale : Array[Float], feed_forward_normalization_bias : Array[Float], feed_forward : FeedForwardParameters) -> TransformerEncoderParameters raise
TensorError

#
TransformerEncoderStack

pub struct TransformerEncoderStack[T] {
layers_ : Array[TransformerEncoderBlock[T]]
}

A non-empty sequence of pre-normalization Transformer encoder blocks.

#
TransformerEncoderStack::forward

#
TransformerEncoderStack::layer_count

fn[T] TransformerEncoderStack::layer_count(self : TransformerEncoderStack[T]) -> Int

#
TransformerEncoderStackConfig

pub struct TransformerEncoderStackConfig {
encoder_ : TransformerEncoderConfig
layers_ : Int
}

#
TransformerEncoderStackConfig::encoder

#
TransformerEncoderStackConfig::layers

#
TransformerEncoderStackConfig::new

fn TransformerEncoderStackConfig::new(layers : Int, width : Int, heads : Int, hidden_size : Int, input_rank : Int, epsilon : Float) -> TransformerEncoderStackConfig raise
TensorError

#
TransformerEncoderStackParameters

pub struct TransformerEncoderStackParameters {
layers_ : Array[TransformerEncoderParameters]
}

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io