Caffe2 - C++ API
A deep learning, cross platform ML framework
mod_op.h
1 #ifndef CAFFE_OPERATORS_MOD_OP_H_
2 #define CAFFE_OPERATORS_MOD_OP_H_
3 
4 #include "caffe2/core/context.h"
5 #include "caffe2/core/logging.h"
6 #include "caffe2/core/operator.h"
7 
8 namespace caffe2 {
9 
10 template <class Context>
11 class ModOp final : public Operator<Context> {
12  public:
13  USE_OPERATOR_CONTEXT_FUNCTIONS;
14  ModOp(const OperatorDef& operator_def, Workspace* ws)
15  : Operator<Context>(operator_def, ws) {
16  divisor_ = OperatorBase::GetSingleArgument<int64_t>("divisor", 0);
17  CAFFE_ENFORCE_NE(divisor_, 0, "divisor must not be 0");
18  sign_follow_divisor_ =
19  OperatorBase::GetSingleArgument<bool>("sign_follow_divisor", false);
20  }
21 
22  bool RunOnDevice() override {
23  return DispatchHelper<TensorTypes<int, int64_t>>::call(this, Input(DATA));
24  }
25 
26  template <typename T>
27  bool DoRunWithType();
28 
29  protected:
30  INPUT_TAGS(DATA);
31 
32  private:
33  int64_t divisor_;
34  bool sign_follow_divisor_;
35 };
36 
37 } // namespace caffe2
38 
39 #endif // CAFFE_OPERATORS_MOD_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 ...