Caffe2 - C++ API
A deep learning, cross platform ML framework
apmeter_op.h
1 
17 #ifndef CAFFE2_MAP_OP_H_
18 #define CAFFE2_MAP_OP_H_
19 
20 #include "caffe2/core/context.h"
21 #include "caffe2/core/operator.h"
22 
23 namespace caffe2 {
24 
25 template <typename T, class Context>
26 class APMeterOp final : public Operator<Context> {
27  public:
28  USE_OPERATOR_CONTEXT_FUNCTIONS;
29 
30  APMeterOp(const OperatorDef& operator_def, Workspace* ws)
31  : Operator<Context>(operator_def, ws),
32  buffer_size_(
33  OperatorBase::GetSingleArgument<int32_t>("buffer_size", 1000)),
34  buffer_used_(0) {}
35 
36  bool RunOnDevice() override;
37 
38  protected:
39  using BufferDataType = std::pair<float, int>;
40  // Buffer the predictions for each class
41  std::vector<std::vector<BufferDataType>> buffers_;
42  // Capacity of the buffer
43  int buffer_size_;
44  // Used buffer
45  int buffer_used_;
46 
47  INPUT_TAGS(PREDICTION, LABEL);
48 
49  protected:
50  // Buffer predictions for N sample and D classes
51  void
52  BufferPredictions(const float* Xdata, const int* labelData, int N, int D);
53 };
54 
55 } // namespace caffe2
56 
57 #endif // CAFFE2_MAP_OP_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:63
Copyright (c) 2016-present, Facebook, Inc.