Unmap a subset of item (data) back to the original set of items (of size count)
(data, count, inds, fill=0)
| 26 | |
| 27 | |
| 28 | def unmap(data, count, inds, fill=0): |
| 29 | """ Unmap a subset of item (data) back to the original set of items (of |
| 30 | size count) """ |
| 31 | if data.dim() == 1: |
| 32 | ret = data.new_full((count, ), fill) |
| 33 | ret[inds] = data |
| 34 | else: |
| 35 | new_size = (count, ) + data.size()[1:] |
| 36 | ret = data.new_full(new_size, fill) |
| 37 | ret[inds, :] = data |
| 38 | return ret |
| 39 | |
| 40 | |
| 41 | def add_prefix(inputs, prefix): |