Caffe2 - C++ API
A deep learning, cross platform ML framework
floor_op.h
1 #ifndef CAFFE2_OPERATORS_FLOOR_OP_H_
2 #define CAFFE2_OPERATORS_FLOOR_OP_H_
3 
4 #include "caffe2/core/common_omp.h"
5 #include "caffe2/core/context.h"
6 #include "caffe2/core/logging.h"
7 #include "caffe2/core/operator.h"
8 
9 namespace caffe2 {
10 
11 template <typename T, class Context>
12 class FloorOp final : public Operator<Context> {
13  public:
14  USE_OPERATOR_CONTEXT_FUNCTIONS;
15  USE_SIMPLE_CTOR_DTOR(FloorOp);
16 
17  bool RunOnDevice() override {
18  auto& X = Input(0);
19 
20  auto* Y = Output(0, X.sizes(), at::dtype<float>());
21 
22  const float* Xdata = X.template data<float>();
23  float* Ydata = Y->template mutable_data<float>();
24  for (int i = 0; i < X.numel(); ++i) {
25  Ydata[i] = std::floor(Xdata[i]);
26  }
27  return true;
28  }
29 };
30 
31 } // namespace caffe2
32 
33 #endif // CAFFE2_OPERATORS_FLOOR_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