forked from alibaba/MNN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEltwise.cpp
More file actions
52 lines (47 loc) · 1.43 KB
/
Copy pathEltwise.cpp
File metadata and controls
52 lines (47 loc) · 1.43 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
50
51
52
//
// Eltwise.cpp
// MNNConverter
//
// Created by MNN on 2019/01/31.
// Copyright © 2018, Alibaba Group Holding Limited
//
#include "OpConverter.hpp"
#include "logkit.h"
class EltWise : public OpConverter {
public:
virtual void run(MNN::OpT* dstOp, const caffe::LayerParameter& parameters, const caffe::LayerParameter& weight);
EltWise() {
}
virtual ~EltWise() {
}
virtual MNN::OpType opType() {
return MNN::OpType_Eltwise;
}
virtual MNN::OpParameter type() {
return MNN::OpParameter_Eltwise;
}
};
void EltWise::run(MNN::OpT* dstOp, const caffe::LayerParameter& parameters, const caffe::LayerParameter& weight) {
auto elt = new MNN::EltwiseT;
dstOp->main.value = elt;
auto& caffeParam = parameters.eltwise_param();
switch (caffeParam.operation()) {
case caffe::EltwiseParameter_EltwiseOp_MAX:
elt->type = MNN::EltwiseType_MAXIMUM;
break;
case caffe::EltwiseParameter_EltwiseOp_SUM:
elt->type = MNN::EltwiseType_SUM;
break;
case caffe::EltwiseParameter_EltwiseOp_PROD:
elt->type = MNN::EltwiseType_PROD;
break;
default:
break;
}
const int coffSize = caffeParam.coeff_size();
elt->coeff.resize(coffSize);
for (int i = 0; i < coffSize; ++i) {
elt->coeff[i] = caffeParam.coeff(i);
}
}
static OpConverterRegister<EltWise> a("Eltwise");