| 54 | } |
| 55 | |
| 56 | const vector<Tensor> Concat::Forward(int flag, const vector<Tensor>& inputs) { |
| 57 | // TODO(wangwei) check the inputs shape to be the same for all iterations |
| 58 | vector<Tensor> outputs; |
| 59 | slice_point_.clear(); |
| 60 | size_t offset = 0; |
| 61 | for (auto& x : inputs) { |
| 62 | offset += x.shape(axis_); |
| 63 | slice_point_.push_back(offset); |
| 64 | } |
| 65 | if (inputs.size() == 1u) { |
| 66 | outputs = inputs; |
| 67 | } else { |
| 68 | outputs.push_back(ConcatOn(inputs, axis_)); |
| 69 | } |
| 70 | return outputs; |
| 71 | } |
| 72 | |
| 73 | const std::pair<vector<Tensor>, vector<Tensor>> Concat::Backward( |
| 74 | int flag, const vector<Tensor>& grads) { |