| 3 | namespace TEngine{ |
| 4 | |
| 5 | bool Bias::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, int layout) |
| 6 | { |
| 7 | const TShape& input_shape = ishape[0]; |
| 8 | int input_h = input_shape.GetH(); |
| 9 | int input_w = input_shape.GetW(); |
| 10 | |
| 11 | int output_h = input_h; |
| 12 | int output_w = input_w; |
| 13 | |
| 14 | TShape shape; |
| 15 | if(layout == TENGINE_LAYOUT_NCHW) |
| 16 | { |
| 17 | std::vector<int> dim = {input_shape.GetN(), input_shape.GetC(), output_h, output_w}; |
| 18 | |
| 19 | shape.SetDim(dim); |
| 20 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); |
| 21 | } |
| 22 | else |
| 23 | { |
| 24 | std::vector<int> dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; |
| 25 | |
| 26 | shape.SetDim(dim); |
| 27 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); |
| 28 | } |
| 29 | oshape[0] = shape; |
| 30 | |
| 31 | return true; |
| 32 | } |
| 33 | |
| 34 | void Bias::SetSchema(void) |
| 35 | { |