| 25 | |
| 26 | namespace TEngine { |
| 27 | bool Resize::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, int layout) |
| 28 | { |
| 29 | const TShape& input = ishape[0]; |
| 30 | |
| 31 | int out_h = ( int )(input.GetH() * param_.scale_h); |
| 32 | int out_w = ( int )(input.GetW() * param_.scale_w); |
| 33 | |
| 34 | TShape shape; |
| 35 | if(layout == TENGINE_LAYOUT_NHWC) |
| 36 | { |
| 37 | std::vector<int> dim = {input.GetN(), out_h, out_w, input.GetC()}; |
| 38 | shape.SetDim(dim); |
| 39 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | std::vector<int> dim = {input.GetN(), input.GetC(), out_h, out_w}; |
| 44 | shape.SetDim(dim); |
| 45 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); |
| 46 | } |
| 47 | oshape[0] = shape; |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | void Resize::SetSchema(void) |
| 53 | { |