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

[TOPI] Treat undefined elements as constants in Array #7232

Merged
merged 4 commits into from
Jan 9, 2021

Conversation

comaniac
Copy link
Contributor

@comaniac comaniac commented Jan 8, 2021

#7018 introduces the dynamic support to strided_slice. However, in the following case, the static workload will be treat as a dynamic:

cpp.strided_slice(weight, begin=[0, 0, 0, 0], end=[None, None, filter_h, filter_w])

This is because the None in end is not IntImmNode and will be judged as a non-constant array. This PR changes the behavior by ignoring the undefined elements.

In addition, the dynamic path also assumes strides array is always given, but it will be initialized to array of 1 after this path. Since I'm not sure what's the right behavior, I only add a checker to error out.

cc @kevinthesun @mbrookhart

@comaniac comaniac changed the title Fix const array [TOPI] Treat undefined elements as constants in Array Jan 8, 2021
@mbrookhart
Copy link
Contributor

I didn't know we could use None. Is there a way to test it in the unit tests?

I'd like to see a unit test, but otherwise it looks good.

@comaniac
Copy link
Contributor Author

comaniac commented Jan 8, 2021

I didn't know we could use None. Is there a way to test it in the unit tests?

I'd like to see a unit test, but otherwise it looks good.

It is supported here: https://github.com/apache/tvm/blob/main/include/tvm/topi/transform.h#L658 (so does begin). A test case is also added.

@comaniac comaniac merged commit 02ef6e6 into apache:main Jan 9, 2021
@comaniac comaniac deleted the fix_const_array branch January 9, 2021 03:49
@comaniac
Copy link
Contributor Author

comaniac commented Jan 9, 2021

Thanks @mbrookhart @yzhliu

tkonolige pushed a commit to tkonolige/incubator-tvm that referenced this pull request Jan 11, 2021
* [TOPI] Treat undefined elements as constants in Array

* Add a checker

* fix

* add test case
masahi pushed a commit to masahi/tvm that referenced this pull request Jan 14, 2021
* [TOPI] Treat undefined elements as constants in Array

* Add a checker

* fix

* add test case
masahi pushed a commit to masahi/tvm that referenced this pull request Jan 18, 2021
* [TOPI] Treat undefined elements as constants in Array

* Add a checker

* fix

* add test case
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Jan 20, 2021
* [TOPI] Treat undefined elements as constants in Array

* Add a checker

* fix

* add test case
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jan 21, 2021
* [TOPI] Treat undefined elements as constants in Array

* Add a checker

* fix

* add test case
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
* [TOPI] Treat undefined elements as constants in Array

* Add a checker

* fix

* 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.

3 participants