Skip to content

Fix reduce NCHWc infer layout (do not keep reduced inner c when keepdims=false)#9821

Merged
comaniac merged 3 commits intoapache:mainfrom
masahi:reduce-alter-layout-fix
Jan 3, 2022
Merged

Fix reduce NCHWc infer layout (do not keep reduced inner c when keepdims=false)#9821
comaniac merged 3 commits intoapache:mainfrom
masahi:reduce-alter-layout-fix

Conversation

@masahi
Copy link
Member

@masahi masahi commented Jan 3, 2022

Closes #9813

The error happened at

ICHECK(exist_axis[axis - 'a' + 'A'])
<< "Invalid layout " << name << ": missing axis " << std::toupper(axis);
where it checks for the presence of the "primal" axis C when it finds a "non-primal" axis c. In the test case in #9813, the reduction is over the channel dimension, so the C axis would be gone unless keepdims = True. But ReduceInferCorrectLayout had a bug where it always preserved the inner 1c when the reduction is over the channel dimension. This resulted in an invalid layout NHW1c.

@ganler @comaniac

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM

@comaniac comaniac merged commit 11379f7 into apache:main Jan 3, 2022
@comaniac
Copy link
Contributor

comaniac commented Jan 3, 2022

Thanks @masahi

ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
…ims=false) (apache#9821)

* Fix reduce NCHWc infer layout (do not keep reduced inner c when keepdims=false)

* black

* lint
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
…ims=false) (apache#9821)

* Fix reduce NCHWc infer layout (do not keep reduced inner c when keepdims=false)

* black

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

[Bug] Layout Error when Putting argmin after conv2d

2 participants