Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::IPositionalPairedOp Struct Referenceabstractexport

Capability interface for position-dependent paired operations. More...

Public Member Functions

virtual void decode (const ITensor &inputA, const ITensor &inputB, ITensor &outputA, ITensor &outputB, dim_t position)=0
 Process a single token at an explicit sequence position.
virtual void prefill (const ITensor &inputA, const ITensor &inputB, ITensor &outputA, ITensor &outputB, dim_t position_offset)=0
 Process a chunk of tokens starting at a given position.

Detailed Description

Capability interface for position-dependent paired operations.

Implemented by operations that accept two input/output tensor pairs and whose mathematical output changes based on absolute token position – e.g. RoPE, which rotates both Q and K embeddings by position-dependent angles.

Parameter order follows the PairedOperation convention: all inputs first, then all outputs, followed by the position argument.

Operations that are position-agnostic do not implement this interface – they use forward() for all modes.

Member Function Documentation

◆ decode()

virtual void Mila::Dnn::Compute::IPositionalPairedOp::decode ( const ITensor & inputA,
const ITensor & inputB,
ITensor & outputA,
ITensor & outputB,
dim_t position )
pure virtual

Process a single token at an explicit sequence position.

Parameters
inputASingle-token first input [B, 1, ...].
inputBSingle-token second input [B, 1, ...].
outputASingle-token first output [B, 1, ...].
outputBSingle-token second output [B, 1, ...].
positionZero-based absolute sequence position.

◆ prefill()

virtual void Mila::Dnn::Compute::IPositionalPairedOp::prefill ( const ITensor & inputA,
const ITensor & inputB,
ITensor & outputA,
ITensor & outputB,
dim_t position_offset )
pure virtual

Process a chunk of tokens starting at a given position.

Parameters
inputAFirst input tensor (e.g. Q) for this chunk.
inputBSecond input tensor (e.g. K) for this chunk.
outputAFirst output tensor for this chunk.
outputBSecond output tensor for this chunk.
position_offsetAbsolute position of the first token in this chunk.

The documentation for this struct was generated from the following file: