Caffe2 - C++ API
A deep learning, cross platform ML framework
find_duplicate_elements_op.cc
1 #include "caffe2/operators/find_duplicate_elements_op.h"
2 
3 namespace caffe2 {
4 namespace {
5 REGISTER_CPU_OPERATOR(
6  FindDuplicateElements,
7  FindDuplicateElementsOp<CPUContext>);
8 
9 OPERATOR_SCHEMA(FindDuplicateElements)
10  .NumInputs(1)
11  .NumOutputs(1)
12  .SetDoc(R"DOC(
13 The *FindDuplicateElements* op takes a single 1-D tensor *data* as input and returns a single 1-D output tensor *indices*. The output tensor contains the indices of the duplicate elements of the input, excluding the first occurrences. If all elements of *data* are unique, *indices* will be empty.
14 
15 Github Links:
16 
17 - https://github.com/caffe2/caffe2/blob/master/caffe2/operators/find_duplicate_elements_op.h
18 - https://github.com/caffe2/caffe2/blob/master/caffe2/operators/find_duplicate_elements_op.cc
19 
20 
21 <details>
22 
23 <summary> <b>Example</b> </summary>
24 
25 **Code**
26 
27 ```
28 
29 workspace.ResetWorkspace()
30 
31 op = core.CreateOperator(
32  "FindDuplicateElements",
33  ["data"],
34  ["indices"],
35 )
36 
37 workspace.FeedBlob("data", np.array([8,2,1,1,7,8,1]).astype(np.float32))
38 print("data:\n", workspace.FetchBlob("data"))
39 
40 workspace.RunOperatorOnce(op)
41 print("indices: \n", workspace.FetchBlob("indices"))
42 
43 ```
44 
45 **Result**
46 
47 ```
48 
49 data:
50  [8. 2. 1. 1. 7. 8. 1.]
51 indices:
52  [3 5 6]
53 
54 ```
55 
56 </details>
57 
58 
59  )DOC")
60  .Input(0, "data", "a 1-D tensor.")
61  .Output(
62  0,
63  "indices",
64  "Indices of duplicate elements in data, excluding first occurrences.");
65 
66 SHOULD_NOT_DO_GRADIENT(FindDuplicateElements);
67 } // namespace
68 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13