Caffe2 - C++ API
A deep learning, cross platform ML framework
length_split_op.cc
1 #include "caffe2/operators/length_split_op.h"
2 
3 namespace caffe2 {
4 
5 REGISTER_CPU_OPERATOR(LengthsSplit, LengthsSplitOp<CPUContext>);
6 
7 OPERATOR_SCHEMA(LengthsSplit)
8  .NumInputs(1, 2)
9  .NumOutputs(1)
10  .ScalarType(TensorProto::INT32)
11  .SetDoc(R"DOC(
12 Given input vector LENGTHS, and input n_split, LengthsSplit returns
13 a single output vector. It "splits" each length into n_split values which add
14 up to the original length. It will attempt to do equal splits, and if not possible,
15 it orders larger values first. If the n_split is larger than the length, zero
16 padding will be applied.
17 
18 e.g. LENGTHS = [9 4 5]
19  n_split = 3
20  Y = [3 3 3 2 1 1 2 2 1]
21 
22 e.g. LENGTHS = [2, 1, 2]
23  n_split = 3
24  Y = [1 1 0 1 0 0 1 1 0]
25 )DOC")
26  .Arg("n_split", "Number of splits for each element in LENGTHS")
27  .Input(0, "LENGTHS", "Mx1 Input tensor denoting INT32 lengths")
28  .Input(
29  1,
30  "n_split",
31  "(Optional) Number of splits for each element in LENGTHS (overrides argument)")
32  .Output(0, "Y", "(M*n_split)x1 Output vector denoting split lengths");
33 
34 // TODO: Write gradient for this when needed
35 GRADIENT_NOT_IMPLEMENTED_YET(LengthsSplit);
36 
37 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13