Caffe2 - C++ API
A deep learning, cross platform ML framework
resize_nearest_dnnlowp_op.h
1 #pragma once
2 
3 #include "caffe2/operators/resize_op.h"
4 #include "caffe2/quantization/server/dnnlowp_op.h"
5 
6 namespace caffe2 {
7 
8 using ResizeNearestFP32Op = ResizeNearestOp<float, CPUContext>;
9 
10 template <typename T>
11 class ResizeNearestDNNLowPOp final : public DNNLowPOp<T, ResizeNearestFP32Op> {
12  public:
13  USE_OPERATOR_FUNCTIONS(CPUContext);
14  USE_DNNLOWP_OPERATOR_BASE_FUNCTIONS(T, ResizeNearestFP32Op);
15 
16  ResizeNearestDNNLowPOp(const OperatorDef& operator_def, Workspace* ws)
17  : BaseType(operator_def, ws),
18  width_scale_(this->template GetSingleArgument<float>("width_scale", 1)),
19  height_scale_(
20  this->template GetSingleArgument<float>("height_scale", 1)) {
21  CAFFE_ENFORCE_GT(width_scale_, 0);
22  CAFFE_ENFORCE_GT(height_scale_, 0);
23 
24  const auto& order = StringToStorageOrder(
25  this->template GetSingleArgument<std::string>("order", "NHWC"));
26  CAFFE_ENFORCE_EQ(order, StorageOrder::NHWC);
27  }
28 
29  bool RunOnDevice() override;
30 
31  private:
32  float width_scale_;
33  float height_scale_;
34 };
35 
36 } // namespace caffe2
The CPU Context, representing the bare minimum of what a Context class in Caffe2 should implement...
Definition: context.h:40
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 ...
Definition: blob.h:13
A convenient base class for C2 operators with DNNLOWP engine.
Definition: dnnlowp_op.h:77