oa::TransformerBlock

TransformerBlock class in the OA Ml public surface.

Inheritance

public Module

Public Methods

oa::AttentionMode oa::TransformerBlock::attentionMode()
oa::I32 oa::TransformerBlock::dFF()
oa::I32 oa::TransformerBlock::dModel()
void oa::TransformerBlock::enableAdaptiveConditioning(oa::I32 inConditionDim)
oa::Matrix oa::TransformerBlock::forward(const oa::Matrix & inX)
oa::Matrix oa::TransformerBlock::forwardConditioned(const oa::Matrix & inX, const oa::Matrix & inCondition, const oa::Matrix & inAdditiveMask = = {})
oa::Matrix oa::TransformerBlock::forwardMasked(const oa::Matrix & inX, const oa::Matrix & inAdditiveMask)
void oa::TransformerBlock::init(oa::I32 inDModel, oa::I32 inDFF, oa::I32 inSeqLen, oa::F32 inEps = 1e-5f)
void oa::TransformerBlock::init(oa::I32 inDModel, oa::I32 inDFF, oa::I32 inSeqLen, oa::I32 inNumHeads, oa::F32 inEps)
void oa::TransformerBlock::initMoe(oa::I32 inDModel, oa::I32 inExpertDFF, oa::I32 inSeqLen, oa::I32 inNumExperts, oa::I32 inExpertsPerToken, oa::F32 inEps = 1e-5f)
void oa::TransformerBlock::initMoe(oa::I32 inDModel, oa::I32 inExpertDFF, oa::I32 inSeqLen, oa::I32 inNumHeads, oa::I32 inNumExperts, oa::I32 inExpertsPerToken, oa::F32 inEps)
bool oa::TransformerBlock::isMoe()
Moe * oa::TransformerBlock::moe()
const Moe * oa::TransformerBlock::moe()
oa::I32 oa::TransformerBlock::numHeads()
oa::I32 oa::TransformerBlock::seqLen()
void oa::TransformerBlock::setAttentionMode(oa::AttentionMode inMode)
void oa::TransformerBlock::setSeqLen(oa::I32 inSeqLen)

Constructor & Destructor Documentation

oa::TransformerBlock::TransformerBlock()
No public source comment is attached to this declaration.
oa::TransformerBlock::TransformerBlock( oa::I32 inDModel, oa::I32 inDFF, oa::I32 inSeqLen, oa::F32 inEps = 1e-5f )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inDFF
oa::I32

inSeqLen
oa::I32

inEps
oa::F32

Default: 1e-5f

oa::TransformerBlock::TransformerBlock( oa::I32 inDModel, oa::I32 inDFF, oa::I32 inSeqLen, oa::I32 inNumHeads, oa::F32 inEps )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inDFF
oa::I32

inSeqLen
oa::I32

inNumHeads
oa::I32

inEps
oa::F32

oa::TransformerBlock::TransformerBlock( oa::I32 inDModel, oa::I32 inExpertDFF, oa::I32 inSeqLen, oa::I32 inNumExperts, oa::I32 inExpertsPerToken, oa::F32 inEps = 1e-5f )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inExpertDFF
oa::I32

inSeqLen
oa::I32

inNumExperts
oa::I32

inExpertsPerToken
oa::I32

inEps
oa::F32

Default: 1e-5f

oa::TransformerBlock::TransformerBlock( oa::I32 inDModel, oa::I32 inExpertDFF, oa::I32 inSeqLen, oa::I32 inNumHeads, oa::I32 inNumExperts, oa::I32 inExpertsPerToken, oa::F32 inEps )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inExpertDFF
oa::I32

inSeqLen
oa::I32

inNumHeads
oa::I32

inNumExperts
oa::I32

inExpertsPerToken
oa::I32

inEps
oa::F32

Public Method Documentation

oa::AttentionMode oa::TransformerBlock::attentionMode()
No public source comment is attached to this declaration.

Returns

oa::AttentionMode

The declared return value.

oa::I32 oa::TransformerBlock::dFF()
No public source comment is attached to this declaration.

Returns

oa::I32

The declared return value.

oa::I32 oa::TransformerBlock::dModel()
No public source comment is attached to this declaration.

Returns

oa::I32

The declared return value.

void oa::TransformerBlock::enableAdaptiveConditioning( oa::I32 inConditionDim )
Enables DiT-style AdaLN-Zero modulation. The ordinary language-model path remains unchanged until this is explicitly enabled by a conditioned model.

Parameters

inConditionDim
oa::I32

Returns

void

The declared return value.

oa::Matrix oa::TransformerBlock::forward( const oa::Matrix & inX )
forward: x [B*S, D] → [B*S, D]. inSeqLen separates sequences within the flattened batch. Causal visibility remains the language-model default; flow/denoising encoders explicitly select Bidirectional.

Parameters

inX
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::TransformerBlock::forwardConditioned( const oa::Matrix & inX, const oa::Matrix & inCondition, const oa::Matrix & inAdditiveMask = = {} )
No public source comment is attached to this declaration.

Parameters

inX
const oa::Matrix &

inCondition
const oa::Matrix &

inAdditiveMask
const oa::Matrix &

Default: = {}

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::TransformerBlock::forwardMasked( const oa::Matrix & inX, const oa::Matrix & inAdditiveMask )
Same block with an explicit additive attention mask [B*H*S,S]. The mask is shared by language padding and bidirectional denoising; Flash attention is intentionally bypassed because its current kernel is causal-only.

Parameters

inX
const oa::Matrix &

inAdditiveMask
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

void oa::TransformerBlock::init( oa::I32 inDModel, oa::I32 inDFF, oa::I32 inSeqLen, oa::F32 inEps = 1e-5f )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inDFF
oa::I32

inSeqLen
oa::I32

inEps
oa::F32

Default: 1e-5f

Returns

void

The declared return value.

void oa::TransformerBlock::init( oa::I32 inDModel, oa::I32 inDFF, oa::I32 inSeqLen, oa::I32 inNumHeads, oa::F32 inEps )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inDFF
oa::I32

inSeqLen
oa::I32

inNumHeads
oa::I32

inEps
oa::F32

Returns

void

The declared return value.

void oa::TransformerBlock::initMoe( oa::I32 inDModel, oa::I32 inExpertDFF, oa::I32 inSeqLen, oa::I32 inNumExperts, oa::I32 inExpertsPerToken, oa::F32 inEps = 1e-5f )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inExpertDFF
oa::I32

inSeqLen
oa::I32

inNumExperts
oa::I32

inExpertsPerToken
oa::I32

inEps
oa::F32

Default: 1e-5f

Returns

void

The declared return value.

void oa::TransformerBlock::initMoe( oa::I32 inDModel, oa::I32 inExpertDFF, oa::I32 inSeqLen, oa::I32 inNumHeads, oa::I32 inNumExperts, oa::I32 inExpertsPerToken, oa::F32 inEps )
No public source comment is attached to this declaration.

Parameters

inDModel
oa::I32

inExpertDFF
oa::I32

inSeqLen
oa::I32

inNumHeads
oa::I32

inNumExperts
oa::I32

inExpertsPerToken
oa::I32

inEps
oa::F32

Returns

void

The declared return value.

bool oa::TransformerBlock::isMoe()
No public source comment is attached to this declaration.

Returns

bool

The declared return value.

Moe * oa::TransformerBlock::moe()
No public source comment is attached to this declaration.

Returns

Moe *

The declared return value.

const Moe * oa::TransformerBlock::moe()
No public source comment is attached to this declaration.

Returns

const Moe *

The declared return value.

oa::I32 oa::TransformerBlock::numHeads()
No public source comment is attached to this declaration.

Returns

oa::I32

The declared return value.

oa::I32 oa::TransformerBlock::seqLen()
No public source comment is attached to this declaration.

Returns

oa::I32

The declared return value.

void oa::TransformerBlock::setAttentionMode( oa::AttentionMode inMode )
No public source comment is attached to this declaration.

Parameters

inMode
oa::AttentionMode

Returns

void

The declared return value.

void oa::TransformerBlock::setSeqLen( oa::I32 inSeqLen )
The weights are sequence-length independent. Updating the runtime length only changes the B/S view and its causal mask, which lets one block serve fixed-length training and growing-prefix autoregressive generation.

Parameters

inSeqLen
oa::I32

Returns

void

The declared return value.