Caffe2 - C++ API
A deep learning, cross platform ML framework
apmeter_op.h
1 #ifndef CAFFE2_MAP_OP_H_
2 #define CAFFE2_MAP_OP_H_
3 
4 #include "caffe2/core/context.h"
5 #include "caffe2/core/operator.h"
6 
7 namespace caffe2 {
8 
9 template <typename T, class Context>
10 class APMeterOp final : public Operator<Context> {
11  public:
12  USE_OPERATOR_CONTEXT_FUNCTIONS;
13 
14  APMeterOp(const OperatorDef& operator_def, Workspace* ws)
15  : Operator<Context>(operator_def, ws),
16  buffer_size_(
17  OperatorBase::GetSingleArgument<int32_t>("buffer_size", 1000)),
18  buffer_used_(0) {}
19 
20  bool RunOnDevice() override;
21 
22  protected:
23  using BufferDataType = std::pair<float, int>;
24  // Buffer the predictions for each class
25  std::vector<std::vector<BufferDataType>> buffers_;
26  // Capacity of the buffer
27  int buffer_size_;
28  // Used buffer
29  int buffer_used_;
30 
31  INPUT_TAGS(PREDICTION, LABEL);
32 
33  protected:
34  // Buffer predictions for N sample and D classes
35  void
36  BufferPredictions(const float* Xdata, const int* labelData, int N, int D);
37 };
38 
39 } // namespace caffe2
40 
41 #endif // CAFFE2_MAP_OP_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:47
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...