Caffe2 - C++ API
A deep learning, cross platform ML framework
sparse_matrix_reshape_op.cc
1 
17 #include "caffe2/experiments/operators/sparse_matrix_reshape_op.h"
18 
19 namespace caffe2 {
20 namespace {
21 
22 REGISTER_CPU_OPERATOR(SparseMatrixReshape, SparseMatrixReshapeOp<CPUContext>);
23 
24 OPERATOR_SCHEMA(SparseMatrixReshape)
25  .NumInputs(2)
26  .NumOutputs(2)
27  .DisallowInputFillers() // TODO: enable the filler
28  .AllowInplace({{0, 0}, {1, 1}})
29  .SetDoc(R"DOC(
30 Compute the indices of the reshaped sparse matrix.
31 
32 It takes two 1D tensors as input: the column indices (in int64) and
33 the row indices (in int), which correspond to `INDICES` and `SEGMENT_IDS`
34 in `SparseSortedSegment` family.
35 It outputs the corresponding reshaped column and row indices.
36 
37 Two arguments are required:
38 an argument `old_shape` specifies the original shape of the matrix,
39 and `new_shape` specifies the new shape.
40 One of the dimension in `old_shape` and `new_shape` can be -1.
41 The valid combinations are listed below, where p, q, r, s are
42 strictly positive integers.
43 
44 old_shape=(p, q)
45 new_shape=(r, s)
46 
47 old_shape=(p, q)
48 new_shape=(-1, s)
49 
50 old_shape=(p, q)
51 new_shape=(r, -1)
52 
53 old_shape=(-1, q)
54 new_shape=(-1, s)
55 
56 Note that only the first dimension in `old_shape` can be -1. In that case
57 the second dimension in `new_shape` must NOT be -1.
58 )DOC")
59  .Arg("old_shape", "Old shape.")
60  .Arg("new_shape", "New shape.")
61  .Input(0, "old_col", "Original column indices.")
62  .Input(1, "old_row", "Original row indices.")
63  .Output(0, "new_col", "New column indices.")
64  .Output(1, "new_row", "New row indices.");
65 
66 SHOULD_NOT_DO_GRADIENT(SparseMatrixReshape);
67 
68 } // namespace
69 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13