RotaryEmbedding¶
Computes the Rotary Position Embedding (RoPE) of the input tensor.
Attributes¶
interleaved The boolean that specifies whether the input tensor is in interleaved format, i.e., whether the 2-d vectors rotated are taken from adjacent 2 elements in the hidden dimension.
rotaryEmbeddingDim The hidden dimension that participates in RoPE. A special value of 0 means the full hidden dimension participates in RoPE.
Inputs¶
input: tensor of type T
cosCache: tensor of type T, cosine values for use in computing the rotary embedding.
sinCache: tensor of type T, sine values for use in computing the rotary embedding.
positionIds optional: tensor of type M, position IDs for indexing into cosCache and sinCache.
Outputs¶
output: tensor of type T
Data Types¶
T: float32, float16, bfloat16
M: int64
Shape Information¶
input and output are tensors with the same shape of \([b, d, s, h]\)
cosCache and sinCache are tensors with the same shape of \([b, s, h/2]\).
If positionIds is provided, the shape of cosCache and sinCache is \([maxPositionId+1, h/2]\).
If rotaryEmbeddingDim is not 0, the last dimension of cosCache and sinCache should be \(rotaryEmbeddingDim/2\) instead of \(h/2\).
positionIds, if provided, is a tensor with the shape of \([b, s]\).
DLA Support¶
Not supported.
Examples¶
C++ API¶
For more information about the C++ IRotaryEmbeddingLayer operator, refer to the C++ IRotaryEmbeddingLayer documentation.
Python API¶
For more information about the Python IRotaryEmbeddingLayer operator, refer to the Python IRotaryEmbeddingLayer documentation.