Skip to content

Please add a split method, to iterate over subtensors of the given tensor #825

Description

@emchristiansen

Please add a method for splitting on a given axis, returning an iterator over subtensors selected in that axis.

For example, suppose mytensor is this 2x3 tensor:

[
  [1, 2, 3],
  [4, 5, 6],
]

Then mytensor.split(0) should return the iterator of length 2 containing tensors [1, 2, 3] and [4, 5, 6], and mytensor.split(1) should return the iterator of length 3 containing tensors [1, 4], [2, 5], and [3, 6].

Note, this is close to what select does (IIUC), but select consumes its input and so can't be used to construct an iterator like this.

Also, if the general case doesn't seem worth it, I'd be happy just having the function split_0 which would just split on the first axis.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions