| 5 | |
| 6 | namespace TEngine { |
| 7 | bool SparseToDense::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, int layout) |
| 8 | { |
| 9 | const TShape& input = ishape[0]; |
| 10 | const TShape& output_shape = ishape[1]; |
| 11 | const std::vector<int>& in_dim = input.GetDim(); |
| 12 | const std::vector<int>& out_dim = output_shape.GetDim(); |
| 13 | const int output_shape_size0 = param_.output_shape_size0; |
| 14 | const int output_shape_size1 = param_.output_shape_size1; |
| 15 | std::vector<int> output_shape_dim; |
| 16 | output_shape_dim.push_back(output_shape_size0); |
| 17 | |
| 18 | if(( int )in_dim.size() > 2) |
| 19 | { |
| 20 | return false; |
| 21 | } |
| 22 | |
| 23 | TShape shape; |
| 24 | |
| 25 | if((( int )out_dim.size() == 2) & (( int )in_dim.size() == 2) & (output_shape_size1 != 0)) |
| 26 | { |
| 27 | output_shape_dim.push_back(output_shape_size1); |
| 28 | shape.SetDim(output_shape_dim); |
| 29 | shape.SetDataLayout(input.GetDataLayout()); |
| 30 | oshape[0] = shape; |
| 31 | } |
| 32 | |
| 33 | else if((( int )out_dim.size() == 1) & (( int )in_dim.size() == 1 || ( int )in_dim.size() == 0)) |
| 34 | { |
| 35 | shape.SetDim(output_shape_dim); |
| 36 | oshape[0] = shape; |
| 37 | shape.SetDataLayout(input.GetDataLayout()); |
| 38 | } |
| 39 | |
| 40 | else |
| 41 | { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | |
| 46 | return true; |
| 47 | } |
| 48 | void SparseToDense::SetSchema(void) |
| 49 | { |
| 50 | Input({"input:int32", "output_shape:int32", "sparse_values:float32"}) |
nothing calls this directly
no test coverage detected