1 #include "caffe2/operators/sinusoid_position_encoding_op.h" 5 SinusoidPositionEncoding,
6 SinusoidPositionEncodingOp<CPUContext>);
8 OPERATOR_SCHEMA(SinusoidPositionEncoding)
12 Calculates a sinusoid position encoding tensor as described 13 in https://arxiv.org/abs/1706.03762. Takes a 2-D tensor 14 (of size M x K) of positions as input, the embedding size 15 as an argument, and outputs a position encoding tensor of 16 size (M x K x embedding_size). Here M is typically the max 17 sequence length and K is typically the batch size. 18 The input tensor must satisfy input[m, 0] == input[m, k] for all k. 20 Encoded as amplitude * SIN(pos/alpha^(i/embedding_size)) if i is even, 21 else amplitude * COS(pos/alpha^(i/embedding_size)). Here, pos is the position, 22 alpha and amplitude are tuning parameters, i is the current dimension for 23 the embedding, and embedding_size is the number of total dimensions in 28 "Desired embedding size/number of dimensions -- defaults to 100")
29 .Arg(
"alpha",
"Sinusoid tuning parameter -- defaults to 10000")
30 .Arg(
"amplitude",
"Amplitude of Sin/Cos output")
31 .Input(0,
"positions",
"2-D tensor of positions to be encoded")
32 .Output(0,
"output",
"3-D tensor representing the positional encoding");
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...