Caffe2 - C++ API
A deep learning, cross platform ML framework
merge_id_lists_op.cc
1 
17 #include "caffe2/operators/merge_id_lists_op.h"
18 
19 namespace caffe2 {
20 namespace {
21 REGISTER_CPU_OPERATOR(MergeIdLists, MergeIdListsOp<CPUContext>);
22 
23 OPERATOR_SCHEMA(MergeIdLists)
24  .NumInputs([](int n) { return (n > 0 && n % 2 == 0); })
25  .NumOutputs(2)
26  .SetDoc(R"DOC(
27 MergeIdLists: Merge multiple ID_LISTs into a single ID_LIST.
28 
29 An ID_LIST is a list of IDs (may be ints, often longs) that represents a single
30 feature. As described in https://caffe2.ai/docs/sparse-operations.html, a batch
31 of ID_LIST examples is represented as a pair of lengths and values where the
32 `lengths` (int32) segment the `values` or ids (int32/int64) into examples.
33 
34 Given multiple inputs of the form lengths_0, values_0, lengths_1, values_1, ...
35 which correspond to lengths and values of ID_LISTs of different features, this
36 operator produces a merged ID_LIST that combines the ID_LIST features. The
37 final merged output is described by a lengths and values vector.
38 
39 WARNING: The merge makes no guarantee about the relative order of ID_LISTs
40 within a batch. This can be an issue if ID_LIST are order sensitive.
41 )DOC")
42  .Input(0, "lengths_0", "Lengths of the ID_LISTs batch for first feature")
43  .Input(1, "values_0", "Values of the ID_LISTs batch for first feature")
44  .Output(0, "merged_lengths", "Lengths of the merged ID_LISTs batch")
45  .Output(1, "merged_values", "Values of the merged ID_LISTs batch");
46 NO_GRADIENT(MergeIdLists);
47 }
48 }
Copyright (c) 2016-present, Facebook, Inc.