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

[BUG] Shape Func of Split Op Error #8887

Merged
merged 3 commits into from
Sep 3, 2021
Merged

[BUG] Shape Func of Split Op Error #8887

merged 3 commits into from
Sep 3, 2021

Conversation

wangxiang2713
Copy link
Contributor

Function split_shape_func converts indices_or_sections to a list if indices_or_sections is actually indices (a int num):

if isinstance(indices_or_sections, int):
    indices_or_sections = [indices_or_sections]

and remains indices_or_sections a list if indices_or_sections is actually sections.

Then funtion _split_shape_func treats indices_or_sections as indices if len(indices_or_sections) == 1, treats indices_or_sections as sections otherwise:

if len(indices_or_sections) == 1:
    ...
else:
    ...

However, if indices_or_sections is actually sections but only contains one element, it will be treated as indices in error.

@vinx13
Copy link
Member

vinx13 commented Sep 1, 2021

Thanks for the PR. Could you add a test case?

@wangxiang2713
Copy link
Contributor Author

Thanks for the PR. Could you add a test case?

Hi, a test case just added. This case may occur when convert a tensorflow model. As this code will be excute:

size_splits = _get_param(params, inputs[1])
section_beginnings = np.cumsum(size_splits)[:-1]
indices_or_sections = tuple(section_beginnings)

np.cumsum may convert a two elements list to one elements list.

@masahi
Copy link
Member

masahi commented Sep 3, 2021

I confirmed that the new tests work with your fix, thanks @wangxiang2713

@masahi masahi merged commit ac9bfd9 into apache:main Sep 3, 2021
@wangxiang2713 wangxiang2713 deleted the commit1 branch September 22, 2021 05:17
ylc pushed a commit to ylc/tvm that referenced this pull request Sep 29, 2021
* [BUG] Shape Func of Split Op Error

* Convert Tab to Space

* Add Test Case
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* [BUG] Shape Func of Split Op Error

* Convert Tab to Space

* Add Test Case
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.

None yet

3 participants