3 #include "caffe2/core/context.h" 4 #include "caffe2/core/operator.h" 5 #include "caffe2/utils/math.h" 10 template <
typename T,
typename Context>
11 void VariableLengthSequencePadding(
16 const int32_t* seqLengths,
19 for (
int j = 0; j < B; j++) {
20 for (
int i = seqLengths[j]; i < N; i++) {
21 EigenVectorArrayMap<T>(X + B * M * i + M * j, M).setConstant(padValue);
28 template <
typename T,
typename Context>
32 const OperatorDef& operator_def,
35 USE_OPERATOR_CONTEXT_FUNCTIONS;
37 bool RunOnDevice()
override {
38 const auto N = Input(INPUT).dim(0);
39 const auto B = Input(INPUT).dim(1);
40 const auto M = Input(INPUT).dim(2);
42 auto X = Output(OUTPUT)->template mutable_data<T>();
44 auto seqLengths = Input(SEQ_LENGTHS).template data<int32_t>();
46 detail::VariableLengthSequencePadding<T, Context>(
47 N, B, M, X, seqLengths, 0, &context_);
52 INPUT_TAGS(INPUT, SEQ_LENGTHS);
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...