| 26 | namespace TEngine { |
| 27 | |
| 28 | bool Clip::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, int layout) |
| 29 | { |
| 30 | const TShape& input_shape = ishape[0]; |
| 31 | int input_h = input_shape.GetH(); |
| 32 | int input_w = input_shape.GetW(); |
| 33 | |
| 34 | int output_h = input_h; |
| 35 | int output_w = input_w; |
| 36 | |
| 37 | TShape shape; |
| 38 | if(layout == TENGINE_LAYOUT_NCHW) |
| 39 | { |
| 40 | std::vector<int> dim = {input_shape.GetN(), input_shape.GetC(), output_h, output_w}; |
| 41 | |
| 42 | shape.SetDim(dim); |
| 43 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | std::vector<int> dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; |
| 48 | |
| 49 | shape.SetDim(dim); |
| 50 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); |
| 51 | } |
| 52 | oshape[0] = shape; |
| 53 | |
| 54 | return true; |
| 55 | } |
| 56 | void Clip::SetSchema(void) |
| 57 | { |
| 58 | Input({"input:float"}).Output({"output:float"}).SetAttr("max", 0).SetAttr("min", 0).SetDoc(R"DOC(Clip Layer)DOC"); |