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  template <class... Args>
15  explicit APMeterOp(Args&&... args)
16  : Operator<Context>(std::forward<Args>(args)...),
17  buffer_size_(
18  this->template GetSingleArgument<int32_t>("buffer_size", 1000)),
19  buffer_used_(0) {}
20 
21  bool RunOnDevice() override;
22 
23  protected:
24  using BufferDataType = std::pair<float, int>;
25  // Buffer the predictions for each class
26  std::vector<std::vector<BufferDataType>> buffers_;
27  // Capacity of the buffer
28  int buffer_size_;
29  // Used buffer
30  int buffer_used_;
31 
32  INPUT_TAGS(PREDICTION, LABEL);
33 
34  protected:
35  // Buffer predictions for N sample and D classes
36  void
37  BufferPredictions(const float* Xdata, const int* labelData, int N, int D);
38 };
39 
40 } // namespace caffe2
41 
42 #endif // CAFFE2_MAP_OP_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13
Definition: static.cpp:70