| 26 | namespace TEngine { |
| 27 | |
| 28 | bool L2Pool::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, |
| 29 | int layout) |
| 30 | { |
| 31 | const TShape& input_shape = ishape[0]; |
| 32 | |
| 33 | int input_h = input_shape.GetH(); |
| 34 | int input_w = input_shape.GetW(); |
| 35 | int output_h = 0; |
| 36 | int output_w = 0; |
| 37 | |
| 38 | if(param_.padding == PaddingType::kSame) |
| 39 | { |
| 40 | output_h = (input_h + param_.stride_h - 1) / param_.stride_h; |
| 41 | output_w = (input_w + param_.stride_w - 1) / param_.stride_w; |
| 42 | } |
| 43 | else |
| 44 | { |
| 45 | output_h = (input_h + param_.stride_h - param_.kernel_h) / param_.stride_h; |
| 46 | output_w = (input_w + param_.stride_w - param_.kernel_w) / param_.stride_w; |
| 47 | } |
| 48 | |
| 49 | TShape shape; |
| 50 | std::vector<int> dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; |
| 51 | shape.SetDim(dim); |
| 52 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); |
| 53 | |
| 54 | oshape[0] = shape; |
| 55 | return true; |
| 56 | } |
| 57 | |
| 58 | float L2Pool::GetFops(const std::vector<TShape>& inputs, const std::vector<TShape>& outputs) |
| 59 | { |