Caffe2 - C++ API
A deep learning, cross platform ML framework
mod_op.h
1 
17 #ifndef CAFFE_OPERATORS_MOD_OP_H_
18 #define CAFFE_OPERATORS_MOD_OP_H_
19 
20 #include "caffe2/core/context.h"
21 #include "caffe2/core/logging.h"
22 #include "caffe2/core/operator.h"
23 
24 namespace caffe2 {
25 
26 template <class Context>
27 class ModOp final : public Operator<Context> {
28  public:
29  USE_OPERATOR_CONTEXT_FUNCTIONS;
30  ModOp(const OperatorDef& operator_def, Workspace* ws)
31  : Operator<Context>(operator_def, ws) {
32  divisor_ = OperatorBase::GetSingleArgument<int64_t>("divisor", 0);
33  CAFFE_ENFORCE_NE(divisor_, 0, "divisor must not be 0");
34  sign_follow_divisor_ =
35  OperatorBase::GetSingleArgument<bool>("sign_follow_divisor", false);
36  }
37 
38  bool RunOnDevice() override {
39  return DispatchHelper<TensorTypes<int, int64_t>>::call(this, Input(DATA));
40  }
41 
42  template <typename T>
43  bool DoRunWithType();
44 
45  protected:
46  INPUT_TAGS(DATA);
47 
48  private:
49  int64_t divisor_;
50  bool sign_follow_divisor_;
51 };
52 
53 } // namespace caffe2
54 
55 #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:63
Copyright (c) 2016-present, Facebook, Inc.