File: variable_length_sequence_padding.cc

package info (click to toggle)
pytorch 1.13.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 139,252 kB
  • sloc: cpp: 1,100,274; python: 706,454; ansic: 83,052; asm: 7,618; java: 3,273; sh: 2,841; javascript: 612; makefile: 323; xml: 269; ruby: 185; yacc: 144; objc: 68; lex: 44
file content (27 lines) | stat: -rw-r--r-- 710 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "variable_length_sequence_padding.h"

namespace caffe2 {
REGISTER_CPU_OPERATOR(
    VariableLengthSequencePadding,
    VariableLengthSequencePaddingOp<float, CPUContext>);
OPERATOR_SCHEMA(VariableLengthSequencePadding)
    .NumInputs(2)
    .NumOutputs(1)
    .AllowInplace({{0, 0}})
    .SetDoc(R"DOC(
Super special-case operator. Used to pad a tensor to mimic pytorch's
pad_packed_sequence.

Given an input tensor INPUT of size NxBxM and an input tensor LENS
of size B, where

N = maximum sequence length
B = batch size
M = hidden size

set each element of INPUT to zero if it is past the end of the
corresponding sequence (i.e. if LENS[j] > i for an index (i,j,k)).

)DOC");

} // namespace caffe2