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  template <class... Args>
15  explicit ModOp(Args&&... args)
16  : Operator<Context>(std::forward<Args>(args)...) {
17  divisor_ = this->template GetSingleArgument<int64_t>("divisor", 0);
18  CAFFE_ENFORCE_NE(divisor_, 0, "divisor must not be 0");
19  sign_follow_divisor_ =
20  this->template GetSingleArgument<bool>("sign_follow_divisor", false);
21  }
22 
23  bool RunOnDevice() override {
24  return DispatchHelper<TensorTypes<int, int64_t>>::call(this, Input(DATA));
25  }
26 
27  template <typename T>
28  bool DoRunWithType();
29 
30  protected:
31  INPUT_TAGS(DATA);
32 
33  private:
34  int64_t divisor_;
35  bool sign_follow_divisor_;
36 };
37 
38 } // namespace caffe2
39 
40 #endif // CAFFE_OPERATORS_MOD_OP_H_
const Tensor & Input(int idx, DeviceType type=Context::GetDeviceType())
Retrieve a non-owning reference to the input at position &#39;idx&#39; for this operator. ...
Definition: operator.h:702
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13