Caffe2 - C++ API
A deep learning, cross platform ML framework
lengths_reducer_fused_8bit_rowwise_ops.cc
1 
17 #include "caffe2/operators/lengths_reducer_fused_8bit_rowwise_ops.h"
18 #include "caffe2/core/registry.h"
19 
20 namespace caffe2 {
21 
22 REGISTER_CPU_OPERATOR(
23  SparseLengthsSumFused8BitRowwise,
24  SparseLengthsFused8BitRowwiseOp<CPUContext>);
25 OPERATOR_SCHEMA(SparseLengthsSumFused8BitRowwise)
26  .NumInputs(3)
27  .NumOutputs(1)
28  .SetDoc(R"DOC(
29 Performs the same operation as SparseLengthsSum, but operating on
30 8-bit rowwise quantized matrices with fused storage (where each row
31 stores the scale, bias and then quantized values).
32 )DOC")
33  .Input(
34  0,
35  "DATA",
36  "uint8 tensor obtained with "
37  "operator FloatToFused8BitRowwiseQuantized")
38  .Input(
39  1,
40  "INDICES",
41  "Integer vector containing indices of the first "
42  "dimension of DATA for the slices that are being aggregated")
43  .Input(
44  2,
45  "LENGTHS",
46  "Vector with the same sum of elements as the first dimension of DATA")
47  .Output(0, "output", "output");
48 NO_GRADIENT(SparseLengthsSumFused8BitRowwise);
49 
50 REGISTER_CPU_OPERATOR(
51  SparseLengthsWeightedSumFused8BitRowwise,
52  SparseLengthsFused8BitRowwiseOp<CPUContext, /*with_weights=*/true>);
53 OPERATOR_SCHEMA(SparseLengthsWeightedSumFused8BitRowwise)
54  .NumInputs(4)
55  .NumOutputs(1)
56  .SetDoc(R"DOC(
57 Performs the same operation as SparseLengthsWeightedSum,
58 but operating on 8-bit rowwise quantized matrices with fused storage
59 (where each row stores the scale, bias and then quantized values).
60 )DOC")
61  .Input(
62  0,
63  "DATA",
64  "uint8 tensor obtained with "
65  "operator FloatToFused8BitRowwiseQuantized")
66  .Input(
67  1,
68  "INDICES",
69  "Integer vector containing indices of the first "
70  "dimension of DATA for the slices that are being aggregated")
71  .Input(
72  2,
73  "LENGTHS",
74  "Vector with the same sum of elements as the first dimension of DATA")
75  .Input(
76  3,
77  "WEIGHTS",
78  "Vector of weights to scale rows of DATA with before reduction")
79  .Output(0, "output", "output");
80 
81 NO_GRADIENT(SparseLengthsWeightedSumFused8BitRowwise);
82 
83 REGISTER_CPU_OPERATOR(
84  SparseLengthsMeanFused8BitRowwise,
85  SparseLengthsFused8BitRowwiseOp<
86  CPUContext,
87  /*with_weights=*/false,
88  /*is_mean=*/true>);
89 OPERATOR_SCHEMA(SparseLengthsMeanFused8BitRowwise)
90  .NumInputs(3)
91  .NumOutputs(1)
92  .SetDoc(R"DOC(
93 Performs the same operation as SparseLengthsMean, but
94 operating on 8-bit rowwise quantized matrices with fused storage
95 (where each row stores the scale, bias and then quantized values).
96 )DOC")
97  .Input(
98  0,
99  "DATA",
100  "uint8 tensor obtained with "
101  "operator FloatToFused8BitRowwiseQuantized")
102  .Input(
103  1,
104  "INDICES",
105  "Integer vector containing indices of the first "
106  "dimension of DATA for the slices that are being aggregated")
107  .Input(
108  2,
109  "LENGTHS",
110  "Vector with the same sum of elements as the first dimension of DATA")
111  .Output(0, "output", "output");
112 NO_GRADIENT(SparseLengthsMeanFused8BitRowwise);
113 } // namespace caffe2
Copyright (c) 2016-present, Facebook, Inc.