forked from alibaba/MNN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrop.cpp
More file actions
49 lines (40 loc) · 1.18 KB
/
Copy pathCrop.cpp
File metadata and controls
49 lines (40 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// Crop.cpp
// MNNConverter
//
// Created by MNN on 2019/01/31.
// Copyright © 2018, Alibaba Group Holding Limited
//
#include "OpConverter.hpp"
#include "logkit.h"
class Crop : public OpConverter {
public:
virtual void run(MNN::OpT* dstOp, const caffe::LayerParameter& parameters, const caffe::LayerParameter& weight);
Crop() {
}
virtual ~Crop() {
}
virtual MNN::OpType opType() {
return MNN::OpType_Crop;
}
virtual MNN::OpParameter type() {
return MNN::OpParameter_Crop;
}
};
void Crop::run(MNN::OpT* dstOp, const caffe::LayerParameter& parameters, const caffe::LayerParameter& weight) {
auto cropParam = new MNN::CropT;
auto& caffeCrop = parameters.crop_param();
if (caffeCrop.has_axis()) {
cropParam->axis = caffeCrop.axis();
} else {
cropParam->axis = 2;
}
const int offsetSize = caffeCrop.offset_size();
DCHECK(offsetSize >= 1) << "crop offset error";
cropParam->offset.resize(offsetSize);
for (int i = 0; i < offsetSize; ++i) {
cropParam->offset[i] = caffeCrop.offset().data()[i];
}
dstOp->main.value = cropParam;
}
static OpConverterRegister<Crop> c("Crop");