| 5 | namespace TEngine { |
| 6 | |
| 7 | bool LSTM::InferShape(const std::vector<TShape>& ishape, std::vector<TShape>& oshape, int layout) |
| 8 | { |
| 9 | // input tensors: |
| 10 | // 0 --- input: [seq_length, batch_size, input_size] |
| 11 | // 1 --- kernel [ (input_size+hidden_size),cell_state_size] |
| 12 | // others: optional |
| 13 | |
| 14 | // output tensor: [output_len, batch_size,hidden_size] |
| 15 | // std::cout<<"!!!!!!!\n"; |
| 16 | const TShape input_shape = ishape[0]; |
| 17 | int batch_size = input_shape.Shape(1); |
| 18 | if(param_.mxnet_flag == 0) |
| 19 | { |
| 20 | batch_size = input_shape.Shape(0); |
| 21 | } |
| 22 | |
| 23 | // |
| 24 | std::vector<int> dims(3); |
| 25 | if(param_.mxnet_flag == 0) |
| 26 | { |
| 27 | dims[0] = batch_size; |
| 28 | dims[1] = input_shape.Shape(0); |
| 29 | dims[2] = param_.hidden_size; |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | dims[0] = input_shape.Shape(0); |
| 34 | dims[1] = batch_size; |
| 35 | dims[2] = param_.hidden_size; |
| 36 | } |
| 37 | |
| 38 | // std::cout<<dims[0]<<","<< dims[1]<<","<<dims[2]<<"\n"; |
| 39 | |
| 40 | oshape[0].SetDim(dims); |
| 41 | |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | void LSTM::SetSchema(void) |
| 46 | { |