Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit bf90641

Browse files
committed
dnn: remove inheritance from reduce functors
1 parent 85cb341 commit bf90641

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

modules/dnn/src/layers/reduce_layer.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
7474
class ReduceOpBase
7575
{
7676
public:
77-
bool hasSIMD = false;
78-
ReduceOpBase() {}
79-
virtual ~ReduceOpBase() {};
80-
virtual float apply(const float*, const float*, const float ikarea = 1.0f) = 0;
77+
//bool hasSIMD = false;
78+
//float apply(const float*, const float*, const float ikarea = 1.0f);
8179
};
8280

8381
// type == MIN
@@ -87,7 +85,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
8785
bool hasSIMD = true;
8886
ReduceOpMIN() {}
8987

90-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
88+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
9189
{
9290
return std::accumulate(first, last, FLT_MAX,
9391
[](float a, float b)
@@ -104,7 +102,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
104102
bool hasSIMD = true;
105103
ReduceOpMAX() {}
106104

107-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
105+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
108106
{
109107
return std::accumulate(first, last, -FLT_MAX,
110108
[](float a, float b)
@@ -121,7 +119,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
121119
bool hasSIMD = true;
122120
ReduceOpSUM() {}
123121

124-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
122+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
125123
{
126124
return std::accumulate(first, last, 0.f);
127125
}
@@ -134,7 +132,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
134132
bool hasSIMD = true;
135133
ReduceOpAVE() {}
136134

137-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
135+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
138136
{
139137
float output = std::accumulate(first, last, 0.f);
140138
return output * ikarea;
@@ -148,7 +146,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
148146
bool hasSIMD = true;
149147
ReduceOpSUM_SQUARE(){}
150148

151-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
149+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
152150
{
153151
return std::accumulate(first, last, 0.f,
154152
[](float a, float b)
@@ -165,7 +163,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
165163
bool hasSIMD = true;
166164
ReduceOpL1(){}
167165

168-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
166+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
169167
{
170168
return std::accumulate(first, last, 0.f,
171169
[](float a, float b)
@@ -182,7 +180,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
182180
bool hasSIMD = true;
183181
ReduceOpL2(){}
184182

185-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
183+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
186184
{
187185
float output = std::accumulate(first, last, 0.f,
188186
[](float a, float b)
@@ -200,7 +198,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
200198
bool hasSIMD = true;
201199
ReduceOpPROD(){}
202200

203-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
201+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
204202
{
205203
return std::accumulate(first, last, 1.0f, std::multiplies<float>());
206204
}
@@ -213,7 +211,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
213211
bool hasSIMD = false;
214212
ReduceOpLOG_SUM(){}
215213

216-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
214+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
217215
{
218216
float output = std::accumulate(first, last, 0.0f);
219217
return std::log(output);
@@ -226,7 +224,7 @@ class ReduceLayerImpl CV_FINAL : public ReduceLayer
226224
public:
227225
ReduceOpLOG_SUM_EXP(){}
228226

229-
float apply(const float* first, const float* last, const float ikarea = 1.0f) override
227+
float apply(const float* first, const float* last, const float ikarea = 1.0f)
230228
{
231229
float output = std::accumulate(first, last, 0.0f,
232230
[](float a, float b)

0 commit comments

Comments
 (0)