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

[microNPU] Update Conv2D Tests to Use TF API to Gen Test Cases #9508

Merged
merged 10 commits into from
Dec 9, 2021

Conversation

dchauhan-arm
Copy link
Contributor

  • Previous implementation of conv2d tests would compare the conv2d operator against tvm's execution of the default schedule of conv2d as defined in TOPI, and that is not bitexact with tflite runtime's implemention. Therefore, a tolerance of "1" in quantized 8-bit domain was used.

  • Converts the current conv2d tests to use TensorFlow APIs to create test cases for conv2D, and compare against TFLite runtime.

Change-Id: I74b4a2a22fe90fa0d9176a65627adf81f127dbd0

@dchauhan-arm
Copy link
Contributor Author

Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

Thanks for the cleaning this up @dchauhan-arm ! Much appreciated :).
Broadly looks good and few suggestions to improve it a bit.

tests/python/contrib/test_ethosu/test_codegen.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_codegen.py Outdated Show resolved Hide resolved
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 for cleaning this up, good first patch :) While you are at it, can you also remove relay_ir_builder.py file since after this change we don't use relay_ir_builder any more?

tests/python/contrib/test_ethosu/test_codegen.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_codegen.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_codegen.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
@manupak
Copy link
Contributor

manupak commented Nov 23, 2021

@dchauhan-arm Shall we try to get this merged?

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

Thanks @dchauhan-arm it looks like this PR is almost ready :) Could you fix the formatting issues and a couple of very minor things?

It looks like linting is failing on running black, you can use ./docker/bash.sh tvm.ci_lint ./tests/lint/git-black.sh -i HEAD~1 locally to fix this

tests/python/contrib/test_ethosu/test_codegen.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
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.

Mostly looks good (modulo Luke's comments and linting fixes)! :)

Comment on lines 72 to 82
op = tf.nn.conv2d(
x,
filters=tf.constant(np.random.uniform(
size=(kernel_shape[0], kernel_shape[1], 3, 3)), dtype=tf.float32),
strides=strides
padding=padding,
data_format="NHWC",
dilations=dilation,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This currently tests a special case of input channels and output channels being equal, I think it would be better to test a more general case for the conv2d (e.g. if the legalization pass got ifm and ofm channels mixed up, we would never find out), but I wonder what @manupa-arm thinks about whether it's worth changing?

Copy link
Contributor

@manupak manupak Nov 25, 2021

Choose a reason for hiding this comment

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

Its a good point -- lets follow up with another PR to improve coverage.

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.

Almost there :) It needs to be rebased on top of #9597, but otherwise mostly looks good!

tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
tests/python/contrib/test_ethosu/test_legalize.py Outdated Show resolved Hide resolved
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.

LGTM, let's get this in! :)

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

LGTM! Well done with battling the multiple rebases this needed :)

Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

LGTM!.

Thanks for the hard work! and congratulations on getting your first PR in 🎉 .
I think we need to follow up to use a similiar structure as other tests (after @mbaret's refactor).
to be consistent.

@manupak manupak merged commit 1566fb1 into apache:main Dec 9, 2021
@manupak
Copy link
Contributor

manupak commented Dec 9, 2021

mikepapadim pushed a commit to mikepapadim/tvm that referenced this pull request Dec 9, 2021
…e#9508)

* Current conv2d tests compare the conv2d operator against tvm's execution of the default schedule of conv2d as defined in TOPI and that is not bitexact with tflite runtime's implemention. Therefore a tolerance of "1" in quantized 8-bit domain is used.

* Converts the current conv2d tests to use TensorFlow APIs to create a test cases for conv2D and compare against TFLite runtime.
lhutton1 added a commit to lhutton1/tvm that referenced this pull request Dec 22, 2021
In apache#9508 the decision was made to remove the UnsupportedLayout exception
and the checks that throw it, this PR is cleaning up some that remained.

Change-Id: I83bfe233381b83af886343c9569db753e33f9059
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
…e#9508)

* Current conv2d tests compare the conv2d operator against tvm's execution of the default schedule of conv2d as defined in TOPI and that is not bitexact with tflite runtime's implemention. Therefore a tolerance of "1" in quantized 8-bit domain is used.

* Converts the current conv2d tests to use TensorFlow APIs to create a test cases for conv2D and compare against TFLite runtime.
yangulei pushed a commit to yangulei/tvm that referenced this pull request Jan 11, 2022
…e#9508)

* Current conv2d tests compare the conv2d operator against tvm's execution of the default schedule of conv2d as defined in TOPI and that is not bitexact with tflite runtime's implemention. Therefore a tolerance of "1" in quantized 8-bit domain is used.

* Converts the current conv2d tests to use TensorFlow APIs to create a test cases for conv2D and compare against TFLite runtime.
yangulei pushed a commit to yangulei/tvm that referenced this pull request Jan 12, 2022
…e#9508)

* Current conv2d tests compare the conv2d operator against tvm's execution of the default schedule of conv2d as defined in TOPI and that is not bitexact with tflite runtime's implemention. Therefore a tolerance of "1" in quantized 8-bit domain is used.

* Converts the current conv2d tests to use TensorFlow APIs to create a test cases for conv2D and compare against TFLite runtime.
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
…e#9508)

* Current conv2d tests compare the conv2d operator against tvm's execution of the default schedule of conv2d as defined in TOPI and that is not bitexact with tflite runtime's implemention. Therefore a tolerance of "1" in quantized 8-bit domain is used.

* Converts the current conv2d tests to use TensorFlow APIs to create a test cases for conv2D and compare against TFLite runtime.
manupak pushed a commit that referenced this pull request Jan 17, 2022
* [microNPU] Remove remaining UnsupportedLayout checks

In #9508 the decision was made to remove the UnsupportedLayout exception
and the checks that throw it, this PR is cleaning up some that remained.

Change-Id: I83bfe233381b83af886343c9569db753e33f9059

* fix lint

Change-Id: I67c1a5371f0b2e51b6cd39435ef4073d8d17af51
Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

Summarizing the offline conversation we had to w.r.t. removal of the custom exception.

"""This module defines all error types associated with the Arm(R) Ethos(TM)-U NPU code generator."""


class EthosUCodegenError(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

We decided to remove the layout checks as we decided to rely on partitioning not to partition unsupported layouts to the codegen. Therefore, they are not likely to be exercised from a user flow. Therefore should not be an exception.

Furthermore, it felt unlikely to be triggered in dev flow too to replace them with an assertion -- however, we could revisit if that is experienced frequently.

yuanfz98 pushed a commit to yuanfz98/tvm that referenced this pull request Jan 24, 2022
* [microNPU] Remove remaining UnsupportedLayout checks

In apache#9508 the decision was made to remove the UnsupportedLayout exception
and the checks that throw it, this PR is cleaning up some that remained.

Change-Id: I83bfe233381b83af886343c9569db753e33f9059

* fix lint

Change-Id: I67c1a5371f0b2e51b6cd39435ef4073d8d17af51
crazydemo pushed a commit to crazydemo/tvm that referenced this pull request Jan 27, 2022
* [microNPU] Remove remaining UnsupportedLayout checks

In apache#9508 the decision was made to remove the UnsupportedLayout exception
and the checks that throw it, this PR is cleaning up some that remained.

Change-Id: I83bfe233381b83af886343c9569db753e33f9059

* fix lint

Change-Id: I67c1a5371f0b2e51b6cd39435ef4073d8d17af51
ylc pushed a commit to ylc/tvm that referenced this pull request Feb 16, 2022
* [microNPU] Remove remaining UnsupportedLayout checks

In apache#9508 the decision was made to remove the UnsupportedLayout exception
and the checks that throw it, this PR is cleaning up some that remained.

Change-Id: I83bfe233381b83af886343c9569db753e33f9059

* fix lint

Change-Id: I67c1a5371f0b2e51b6cd39435ef4073d8d17af51
qsqqsqqsq-intellif pushed a commit to qsqqsqqsq-intellif/tvm that referenced this pull request Apr 29, 2022
…e#9508)

* Current conv2d tests compare the conv2d operator against tvm's execution of the default schedule of conv2d as defined in TOPI and that is not bitexact with tflite runtime's implemention. Therefore a tolerance of "1" in quantized 8-bit domain is used.

* Converts the current conv2d tests to use TensorFlow APIs to create a test cases for conv2D and compare against TFLite runtime.
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.

5 participants