| 1408 | } |
| 1409 | |
| 1410 | Tensor CopyRows(const Tensor &in, const size_t start, const size_t end) { |
| 1411 | CHECK_LT(start, end); |
| 1412 | CHECK_GE(in.shape(0), end) << "Tensor size must >= end"; |
| 1413 | Shape s = in.shape(); |
| 1414 | s[0] = end - start; |
| 1415 | size_t sample_size = in.Size() / in.shape(0); |
| 1416 | Tensor out(s, in.device(), in.data_type()); |
| 1417 | CopyDataToFrom(&out, in, out.Size(), 0, start * sample_size); |
| 1418 | return out; |
| 1419 | } |
| 1420 | |
| 1421 | Tensor SliceOn(const Tensor &in, const size_t start, const size_t end, |
| 1422 | int axis) { |