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

[BYOC][ETHOSN] Introduce further operator support #6355

Merged
merged 9 commits into from
Sep 15, 2020

Conversation

mbaret
Copy link
Contributor

@mbaret mbaret commented Aug 28, 2020

This PR introduces support for the following operators via the Ethos-N codegen:

  • Quantized Fully Connected
  • Quantized Addition
  • Depth-to-space
  • Max/Avg Pool 2D
  • Quantized Relu (Clip)
  • Reshape
  • Quantized Sigmoid

Additionally, tests for mobilenet, inceptionv3/4 and ssd mobilenet are added.

Co-authored-by: Leo Blonk Leo.Blonk@arm.com
Co-authored-by: Tristan O'Connor tristan.oconnor@arm.com
Co-authored-by: Ramana Radhakrishnan ramana.radhakrishnan@arm.com

@mbaret
Copy link
Contributor Author

mbaret commented Aug 28, 2020

cc @Leo-arm @masahi @zhiics @comaniac

@mbaret
Copy link
Contributor Author

mbaret commented Sep 1, 2020

@tqchen could you advise on what to do about the failing build? It seems one of the docker images doesn't have tensorflow available, so is there a way we can avoid running the tests there?

python/tvm/relay/op/contrib/ethosn.py Outdated Show resolved Hide resolved
@@ -120,6 +120,14 @@ Module EthosnModule::LoadFromBinary(void* strm) {
return Module(n);
}

void EthosnModule::SaveToFile(const std::string& path, const std::string& format) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks me that this still saves a binary file. Are there specific use cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used by assert_lib_hash in the test infrastructure. See my comment further down on the purpose of the hashes.

tests/python/contrib/test_ethosn/test_addition.py Outdated Show resolved Hide resolved
"models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz",
model_sub_path="mobilenet_v1_1.0_224_quant.tflite",
input_dict={"input": (1, 224, 224, 3)},
compile_hash="81637c89339201a07dc96e3b5dbf836a",
Copy link
Contributor

Choose a reason for hiding this comment

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

How this hash comes from? In case someone in the future changes Ethos-N codegen, how can this be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is created by hashing the library output we get when compiling the model. We create the hash at a 'known good' point in time (i.e. when we run the HW tests internally and see everything is correct). The thinking here is that this provides a quick way to test whether changes in TVM have resulted in a behavioural change to our codegen.

We will remain responsible for updating these hashes while no public hardware is available. Should it become available, we'll no longer need the hashes as we can just test execution correctness directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Could you comment this on the code with TODO? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added in a comment rather than a TODO because I don't think this represents work that is yet to be done, but rather maintenance procedure. It explains the purpose of the hash and who to contact (myself and @Leo-arm ) should the test fail.

tests/python/contrib/test_ethosn/test_fullyconnected.py Outdated Show resolved Hide resolved
@leo-blonk
Copy link
Contributor

LGTM

@masahi
Copy link
Member

masahi commented Sep 9, 2020

@mbaret Can you act on @comaniac's comment?

return EthosnError();
}

EthosnError ConstructNetworkVisitor::MakeReluLayer(const Call& call,
Copy link
Member

Choose a reason for hiding this comment

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

Just a minor suggestion that you feel free to ignore, I think these functions can be replaced by a macro as they look exactly the same and only operator name matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we won't reimplement this for now, but there are subtle differences between these functions, mostly around the number and type of the inputs/outputs + how quantization params should be handled.

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.

Approved with concerns. Ideally, we hope everyone could jump in to maintain and improve a module if they have an interest. The current unit tests, however, can only be maintained by specific folks. I'll let others comment.

@mbaret
Copy link
Contributor Author

mbaret commented Sep 9, 2020

This is an unfortunate consequence of the lack of hardware availability in CI. While that isn't available, it will necessarily be the case that we (Arm) need to maintain this code. I don't believe this is uncommon with new hardware in open source projects.

@zhiics
Copy link
Member

zhiics commented Sep 11, 2020

@mbaret can you rebase?

@mbaret
Copy link
Contributor Author

mbaret commented Sep 14, 2020

'Black' has definitely decreased the readability of some of our tests quite considerably. Might have been worth having tests be exempt...

Copy link
Member

@zhiics zhiics left a comment

Choose a reason for hiding this comment

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

revert the vta changes

mbaret and others added 9 commits September 15, 2020 14:21
This PR introduces support for the following operators:
 - Quantized Fully Connected
 - Quantized Addition
 - Depth-to-space
 - Max/Avg Pool 2D
 - Quantized Relu (Clip)
 - Reshape
 - Quantized Sigmoid


Co-authored-by: Leo Blonk <Leo.Blonk@arm.com>
Co-authored-by: Tristan O'Connor <tristan.oconnor@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Change-Id: I11bcf4a78014fa63e7b8e3b0cb00eecfd6cb7760
Change-Id: I1fb1a11d0765f6d69f04c24b9c24e08665b8af6a
Change-Id: Id06063a0a0cf5f01356df23dc5d4bbbcb47cfa99
Change-Id: I330408dfabc4bd804373f100581ce909ff724052
Change-Id: I2c5007be485b323116a0e8bab0f9106ea5ec834b
Change-Id: I13828c918c959daa492b9ed942a882c86d6690d1
Change-Id: Idaa70ab9c2ec8db2828d51d15e7c23f28670ec82
Change-Id: I538171bd547a16395bef155a1dad28e8b3e347f2
@mbaret
Copy link
Contributor Author

mbaret commented Sep 15, 2020

vta change reverted

@mbaret
Copy link
Contributor Author

mbaret commented Sep 15, 2020

@zhiics @masahi is there anything left to do here?

@zhiics zhiics merged commit 4c5f0c0 into apache:master Sep 15, 2020
@zhiics
Copy link
Member

zhiics commented Sep 15, 2020

Thanks everyone!

@mbaret
Copy link
Contributor Author

mbaret commented Sep 15, 2020

Thanks for all the reviews everyone :)

kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 17, 2020
* [BYOC][ETHOSN] Introduce further operator support

This PR introduces support for the following operators:
 - Quantized Fully Connected
 - Quantized Addition
 - Depth-to-space
 - Max/Avg Pool 2D
 - Quantized Relu (Clip)
 - Reshape
 - Quantized Sigmoid


Co-authored-by: Leo Blonk <Leo.Blonk@arm.com>
Co-authored-by: Tristan O'Connor <tristan.oconnor@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>

* Skip tf imports if not available

Change-Id: I11bcf4a78014fa63e7b8e3b0cb00eecfd6cb7760

* ethos -> ethosn

Change-Id: I1fb1a11d0765f6d69f04c24b9c24e08665b8af6a

* Reduce random testing in test_addition

Change-Id: Id06063a0a0cf5f01356df23dc5d4bbbcb47cfa99

* Reduce random testing in test fullyconnected

Change-Id: I330408dfabc4bd804373f100581ce909ff724052

* Fix dumb mistake with rename

Change-Id: I2c5007be485b323116a0e8bab0f9106ea5ec834b

* Added comments to update the hashes in network tests when necessary

Change-Id: I13828c918c959daa492b9ed942a882c86d6690d1

* Fix github name

Change-Id: Idaa70ab9c2ec8db2828d51d15e7c23f28670ec82

* Use black formatting

Change-Id: I538171bd547a16395bef155a1dad28e8b3e347f2

Co-authored-by: Leo Blonk <Leo.Blonk@arm.com>
Co-authored-by: Tristan O'Connor <tristan.oconnor@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 18, 2020
* [BYOC][ETHOSN] Introduce further operator support

This PR introduces support for the following operators:
 - Quantized Fully Connected
 - Quantized Addition
 - Depth-to-space
 - Max/Avg Pool 2D
 - Quantized Relu (Clip)
 - Reshape
 - Quantized Sigmoid


Co-authored-by: Leo Blonk <Leo.Blonk@arm.com>
Co-authored-by: Tristan O'Connor <tristan.oconnor@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>

* Skip tf imports if not available

Change-Id: I11bcf4a78014fa63e7b8e3b0cb00eecfd6cb7760

* ethos -> ethosn

Change-Id: I1fb1a11d0765f6d69f04c24b9c24e08665b8af6a

* Reduce random testing in test_addition

Change-Id: Id06063a0a0cf5f01356df23dc5d4bbbcb47cfa99

* Reduce random testing in test fullyconnected

Change-Id: I330408dfabc4bd804373f100581ce909ff724052

* Fix dumb mistake with rename

Change-Id: I2c5007be485b323116a0e8bab0f9106ea5ec834b

* Added comments to update the hashes in network tests when necessary

Change-Id: I13828c918c959daa492b9ed942a882c86d6690d1

* Fix github name

Change-Id: Idaa70ab9c2ec8db2828d51d15e7c23f28670ec82

* Use black formatting

Change-Id: I538171bd547a16395bef155a1dad28e8b3e347f2

Co-authored-by: Leo Blonk <Leo.Blonk@arm.com>
Co-authored-by: Tristan O'Connor <tristan.oconnor@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Sep 18, 2020
* [BYOC][ETHOSN] Introduce further operator support

This PR introduces support for the following operators:
 - Quantized Fully Connected
 - Quantized Addition
 - Depth-to-space
 - Max/Avg Pool 2D
 - Quantized Relu (Clip)
 - Reshape
 - Quantized Sigmoid


Co-authored-by: Leo Blonk <Leo.Blonk@arm.com>
Co-authored-by: Tristan O'Connor <tristan.oconnor@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>

* Skip tf imports if not available

Change-Id: I11bcf4a78014fa63e7b8e3b0cb00eecfd6cb7760

* ethos -> ethosn

Change-Id: I1fb1a11d0765f6d69f04c24b9c24e08665b8af6a

* Reduce random testing in test_addition

Change-Id: Id06063a0a0cf5f01356df23dc5d4bbbcb47cfa99

* Reduce random testing in test fullyconnected

Change-Id: I330408dfabc4bd804373f100581ce909ff724052

* Fix dumb mistake with rename

Change-Id: I2c5007be485b323116a0e8bab0f9106ea5ec834b

* Added comments to update the hashes in network tests when necessary

Change-Id: I13828c918c959daa492b9ed942a882c86d6690d1

* Fix github name

Change-Id: Idaa70ab9c2ec8db2828d51d15e7c23f28670ec82

* Use black formatting

Change-Id: I538171bd547a16395bef155a1dad28e8b3e347f2

Co-authored-by: Leo Blonk <Leo.Blonk@arm.com>
Co-authored-by: Tristan O'Connor <tristan.oconnor@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants