1 #include "caffe2/quantization/server/resize_nearest_dnnlowp_op.h" 6 bool ResizeNearestDNNLowPOp<T>::RunOnDevice() {
9 this->ParseDNNLowPOperatorArguments_();
12 in_qparams_[0] = GetInputTensorQuantizationParamsOf(
this, 0, qfactory_.get());
14 const auto& X = InputTensorCPU_(0);
15 auto* Y = OutputTensorCPU_(0);
17 CAFFE_ENFORCE_EQ(X.ndim(), 4);
18 const int N = X.dim32(0);
19 const int IH = X.dim32(1);
20 const int IW = X.dim32(2);
21 const int C = X.dim32(3);
22 const int OW = IW * width_scale_;
23 const int OH = IH * height_scale_;
25 Y->Resize(N, OH, OW, C);
26 const T* X_data = X.template data<T>();
27 T* Y_data = Y->template mutable_data<T>();
30 #pragma omp parallel for 32 for (
int n = 0; n < N; ++n) {
33 for (
int y = 0; y < OH; ++y) {
34 const int in_y = std::min((
int)(y / height_scale_), (IH - 1));
35 for (
int x = 0; x < OW; ++x) {
36 const int in_x = std::min((
int)(x / width_scale_), (IW - 1));
38 &Y_data[((n * OH + y) * OW + x) * C],
39 &X_data[((n * IH + in_y) * IW + in_x) * C],
48 PropagateOutputTensorQuantizationParams(
this, 0, in_qparams_[0]);
53 REGISTER_CPU_OPERATOR_WITH_ENGINE(
56 ResizeNearestDNNLowPOp<uint8_t>);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...