| 27 | namespace TEngine { |
| 28 | |
| 29 | bool ExpandDims::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, int layout) |
| 30 | { |
| 31 | const TShape& input = ishape[0]; |
| 32 | |
| 33 | const std::vector<int>& in_dim = input.GetDim(); |
| 34 | std::vector<int> out_dim; |
| 35 | int in_size = in_dim.size(); |
| 36 | for(int i = 0; i < in_size; i++){ |
| 37 | out_dim.push_back(in_dim[i]); |
| 38 | } |
| 39 | out_dim.push_back(0); |
| 40 | |
| 41 | int out_size = in_size + 1; |
| 42 | for(int i = 0; i < out_size; i++){ |
| 43 | if( i < param_.axis){ |
| 44 | out_dim = in_dim; |
| 45 | } else if(i == param_.axis){ |
| 46 | out_dim[i] = 1; |
| 47 | } else { |
| 48 | out_dim[i] = in_dim[i-1]; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | TShape shape; |
| 53 | shape.SetDim(out_dim); |
| 54 | shape.SetDataLayout(input.GetDataLayout()); |
| 55 | oshape[0] = shape; |
| 56 | |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | void ExpandDims::SetSchema(void) |
| 61 | { |
nothing calls this directly
no test coverage detected