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

fix frontends.torch.{h,v,d}split #10810

Merged
merged 4 commits into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,40 @@ def split(tensor, split_size_or_sections, dim=0):
)


def _get_indices_or_sections(indices_or_sections, indices, sections):
if not ivy.exists(indices_or_sections):
if ivy.exists(indices) and not ivy.exists(sections):
indices_or_sections = indices
elif ivy.exists(sections) and not ivy.exists(indices):
indices_or_sections = sections
else:
raise ivy.utils.exception.IvyError(
"got invalid argument for indices_or_sections"
)
return indices_or_sections


@to_ivy_arrays_and_back
def dsplit(input, indices_or_sections):
def dsplit(input, indices_or_sections=None, /, *, indices=None, sections=None):
indices_or_sections = _get_indices_or_sections(
indices_or_sections, indices, sections
)
return tuple(ivy.dsplit(input, indices_or_sections))


@to_ivy_arrays_and_back
def hsplit(input, indices_or_sections):
def hsplit(input, indices_or_sections=None, /, *, indices=None, sections=None):
indices_or_sections = _get_indices_or_sections(
indices_or_sections, indices, sections
)
return tuple(ivy.hsplit(input, indices_or_sections))


@to_ivy_arrays_and_back
def vsplit(input, indices_or_sections):
def vsplit(input, indices_or_sections=None, /, *, indices=None, sections=None):
indices_or_sections = _get_indices_or_sections(
indices_or_sections, indices, sections
)
return tuple(ivy.vsplit(input, indices_or_sections))


Expand Down