Replicate each entry in a vector n times along depth (innermost dimension). The values are incremented by delta, creating ramps offset by each input value. This is used to create simple and predicatable variation.
| 100 | // The values are incremented by delta, creating ramps offset by each input |
| 101 | // value. This is used to create simple and predicatable variation. |
| 102 | std::vector<float> ReplicateDepthRamp(const std::vector<float>& image_plane, |
| 103 | int n, float delta) { |
| 104 | const int size = image_plane.size(); |
| 105 | std::vector<float> ramped_data(n * size); |
| 106 | // The input is treated as a 1-D even if logically it is multi-dimensional. |
| 107 | for (int input_index = 0; input_index < size; ++input_index) { |
| 108 | for (int depth = 0; depth < n; ++depth) { |
| 109 | ramped_data[n * input_index + depth] = |
| 110 | image_plane[input_index] + depth * delta; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | return ramped_data; |
| 115 | } |
| 116 | |
| 117 | TEST(FloatPoolingOpTest, AveragePool) { |
| 118 | FloatPoolingOpModel m(BuiltinOperator_AVERAGE_POOL_2D, |