Skip to content

Conversation

@Anndrey24
Copy link
Contributor

topi.arm_cpu.schedule_conv2d_NHWC_quantized_interleaved was failing compilation with the +i8mm extension enabled (as done in #14888) whenever the output height and output width were both equal to 1, such that OH x OW = 1.

Padding was being removed during the tir.BufferShapeLegalize pass, causing an error in the tir.BufferBindUnwrapper pass. Some of the removed padding was necessary for tensorize (using the gemm_acc_2x2_int8_int8_int32 intrinsic), which expects 2x2 output tiles. However, because of the optimisations mentioned above, the output tensor C_interleaved was reduced to having 1x2 tiles instead.

e.g. for A = [1x1x1x8], W = [1x1x8x24], C = [1x1x1x24]:

  • Before fix: C_interleaved = T.Buffer((1, 1, 2, 1, 6, 1, 2), "int32”)
  • After fix: C_interleaved = T.Buffer((1, 1, 2, 1, 6, 2, 2), "int32”)

To make sure the required padding is left untouched, while the rest of it is still removed, a dummy reference to the needed axis is declared.

In the end, the leftover padding is still disregarded when computing the final output tensor C.

`topi.arm_cpu.schedule_conv2d_NHWC_quantized_interleaved` was failing compilation with the `+i8mm` extension enabled whenever the output height and output width were both equal to 1, such that OH x OW = 1.

Padding was being removed during the `tir.BufferShapeLegalize` pass, causing an error in the `tir.BufferBindUnwrapper` pass. Some of the removed padding was necessary for tensorize (using the `gemm_acc_2x2_int8_int8_int32` intrinsic), which expects 2x2 output tiles. However, because of the optimisations mentioned above, the output tensor `C_interleaved` was reduced to having 1x2 tiles instead.

e.g. for A = [1x1x1x8], W = [1x1x8x24], C = [1x1x1x24]:
- Before fix:
`C_interleaved = T.Buffer((1, 1, 2, 1, 6, 1, 2), "int32”)`
- After fix:
`C_interleaved = T.Buffer((1, 1, 2, 1, 6, 2, 2), "int32”)`

To make sure the required padding is left untouched, while the rest of it is still removed, a dummy reference to the needed axis is declared.

Finally, the leftover padding is still disregarded when computing the final output tensor `C`.
@tvm-bot
Copy link
Collaborator

tvm-bot commented Aug 4, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: bugfix, topi See #10317 for details

Generated by tvm-bot

@Anndrey24
Copy link
Contributor Author

Copy link
Contributor

@ekalda ekalda left a comment

Choose a reason for hiding this comment

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

Thanks @Anndrey24, LGTM, great work!

@ekalda ekalda merged commit 93356cd into apache:main Aug 7, 2023
@ekalda
Copy link
Contributor

ekalda commented Aug 7, 2023

Thanks @Anndrey24!

@Anndrey24 Anndrey24 deleted the i8mm-schedule-bugfix branch August 7, 2023 08:58
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