| 54 | } |
| 55 | |
| 56 | const vector<Tensor> Slice::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 | CHECK_EQ(inputs.size(), 1u) << "Split layer only have one input tensor."; |
| 60 | size_t offset = 0; |
| 61 | for (auto& s : slice_point_) { |
| 62 | outputs.push_back(SliceOn(inputs.at(0), offset, s, axis_)); |
| 63 | offset = s; |
| 64 | } |
| 65 | outputs.push_back(SliceOn(inputs.at(0), offset, inputs.at(0).shape(axis_), |
| 66 | axis_)); |
| 67 | return outputs; |
| 68 | } |
| 69 | |
| 70 | const std::pair<vector<Tensor>, vector<Tensor>> Slice::Backward( |
| 71 | int flag, const vector<Tensor>& grads) { |