Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Torch] Add support for split #5174

Merged
merged 3 commits into from
Mar 31, 2020
Merged

[Torch] Add support for split #5174

merged 3 commits into from
Mar 31, 2020

Conversation

wyc-ruiker
Copy link
Contributor

Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.
add split in #5133 @masahi @alexwong @jwfromm

indices.append(now_indice)
now_indice += split_size

return _op.split(data, indices, dim)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this op is splitting the index evenly, you can just provide a number of sections to split to rather than a list of indices.

return _op.split(data, int(_infer_shape(data)[dim] / split_size), dim)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The split op in Relay and PyTorch have different behaviors. In Relay, if indices_or_sections is an integer, the input will be divided equally along the given axis. But in Pytorch, if split_size_or_sections is an integer type, then tensor will be split into equally sized chunks (if possible). The last chunk will be smaller if the tensor size along the given dimension dim is not divisible by split_size.

data = inputs[0]
dim = int(inputs[2])

now_indice = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name for this variable would be split_index.


class Split2(Module):
def forward(self, *args):
return torch.split(args[0], [2, 3, 5], 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this end up testing split_with_sizes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the Split2 will test split_with_sizes.

@masahi masahi merged commit 430cb89 into apache:master Mar 31, 2020
@masahi
Copy link
Member

masahi commented Mar 31, 2020

Thanks @wyc-ruiker

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Apr 1, 2020
* [Torch] Add support for split

* fix

* fix test class
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Apr 16, 2020
* [Torch] Add support for split

* fix

* fix test class
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Apr 17, 2020
* [Torch] Add support for split

* fix

* fix test class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants