3 #include "caffe2/core/context.h" 4 #include "caffe2/core/operator.h" 5 #include "caffe2/utils/eigen_utils.h" 6 #include "caffe2/utils/math.h" 11 template <
typename T,
typename Context>
12 void VariableLengthSequencePadding(
17 const int32_t* seqLengths,
20 for (
int j = 0; j < B; j++) {
21 for (
int i = seqLengths[j]; i < N; i++) {
22 EigenVectorArrayMap<T>(X + B * M * i + M * j, M).setConstant(padValue);
29 template <
typename T,
typename Context>
32 template <
class... Args>
35 USE_OPERATOR_CONTEXT_FUNCTIONS;
37 bool RunOnDevice()
override {
38 const auto N = Input(INPUT).size(0);
39 const auto B = Input(INPUT).size(1);
40 const auto M = Input(INPUT).size(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);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...