Caffe2 - C++ API
A deep learning, cross platform ML framework
reverse_packed_segs_op.cc
1 #include "caffe2/operators/reverse_packed_segs_op.h"
2 
3 namespace caffe2 {
4 REGISTER_CPU_OPERATOR(ReversePackedSegs, ReversePackedSegsOp<CPUContext>);
5 
6 OPERATOR_SCHEMA(ReversePackedSegs)
7  .NumInputs(2)
8  .NumOutputs(1)
9  .SetDoc(R"DOC(
10 Reverse segments in a 3-D tensor (lengths, segments, embeddings,), leaving
11 paddings unchanged. This operator is used to reverse input of a recurrent neural
12 network to make it a BRNN.
13  )DOC")
14  .Input(0, "data", "a 3-D (lengths, segments, embeddings,) tensor.")
15  .Input(1, "lengths", "length of each segment.")
16  .Output(
17  0,
18  "reversed data",
19  "a (lengths, segments, embeddings,) tensor with each segment reversed"
20  "and paddings unchanged.");
21 
23  using GradientMakerBase::GradientMakerBase;
24  vector<OperatorDef> GetGradientDefs() override {
25  return SingleGradientDef(
26  "ReversePackedSegs",
27  "",
28  vector<string>{GO(0), I(1)},
29  vector<string>{GI(0)});
30  }
31 };
32 REGISTER_GRADIENT(ReversePackedSegs, GetReversePackedSegsGradient);
33 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13
static vector< OperatorDef > SingleGradientDef(const Args &...args)
a helper function to allow one to create one single operator def, which is usually the case for many ...