Commit 4aff18c1 authored by Paul's avatar Paul
Browse files

Formatting

parent c044272e
...@@ -57,29 +57,17 @@ struct cpu_convolution ...@@ -57,29 +57,17 @@ struct cpu_convolution
struct max_pool struct max_pool
{ {
static std::string name() { return "max"; } static std::string name() { return "max"; }
static double start() static double start() { return std::numeric_limits<double>::lowest(); }
{
return std::numeric_limits<double>::lowest();
}
static double apply(double x, double y) static double apply(double x, double y) { return x + y; }
{
return x + y;
}
static double final(double x, double) static double final(double x, double) { return (x); }
{
return (x);
}
}; };
struct avg_pool struct avg_pool
{ {
static std::string name() { return "average"; } static std::string name() { return "average"; }
static double start() static double start() { return 0.0; }
{
return 0.0;
}
static double apply(double x, double y) static double apply(double x, double y)
{ {
...@@ -87,14 +75,10 @@ struct avg_pool ...@@ -87,14 +75,10 @@ struct avg_pool
return (m); return (m);
} }
static double final(double x, double y) static double final(double x, double y) { return x / y; }
{
return x / y;
}
}; };
template <class Op>
template<class Op>
struct cpu_pooling struct cpu_pooling
{ {
pooling op; pooling op;
...@@ -106,8 +90,8 @@ struct cpu_pooling ...@@ -106,8 +90,8 @@ struct cpu_pooling
argument result{output_shape}; argument result{output_shape};
visit_all(result, args[0])([&](auto output, auto input) { visit_all(result, args[0])([&](auto output, auto input) {
using type = typename decltype(output)::value_type; using type = typename decltype(output)::value_type;
auto in_h = input.get_shape().lens()[2]; auto in_h = input.get_shape().lens()[2];
auto in_w = input.get_shape().lens()[3]; auto in_w = input.get_shape().lens()[3];
dfor(output_shape.lens()[0], dfor(output_shape.lens()[0],
output_shape.lens()[1], output_shape.lens()[1],
...@@ -127,7 +111,6 @@ struct cpu_pooling ...@@ -127,7 +111,6 @@ struct cpu_pooling
const int w_w = (wend - start_y); const int w_w = (wend - start_y);
const int pool_size = std::max(w_h * w_w, 1); const int pool_size = std::max(w_h * w_w, 1);
double acc = Op::start(); double acc = Op::start();
dfor(w_h, w_w)([&](int x, int y) { dfor(w_h, w_w)([&](int x, int y) {
const int in_x = start_x + x; const int in_x = start_x + x;
...@@ -583,7 +566,6 @@ struct cpu_apply ...@@ -583,7 +566,6 @@ struct cpu_apply
prog->replace_instruction(ins, cpu_pooling<max_pool>{op}, ins->arguments); prog->replace_instruction(ins, cpu_pooling<max_pool>{op}, ins->arguments);
else if(op.mode == "average") else if(op.mode == "average")
prog->replace_instruction(ins, cpu_pooling<avg_pool>{op}, ins->arguments); prog->replace_instruction(ins, cpu_pooling<avg_pool>{op}, ins->arguments);
} }
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment