Add the Arm(R) Ethos(TM)-U NPU identity operator#9457
Conversation
ekalda
commented
Nov 5, 2021
- Add the ethosu.identity operator which returns the input tensor
- Add an opportunity to requantize the tensor
- Add legalization for reshape and strided slice
- Add a pass that puts an indentity op after a no-op
| def transform_module( | ||
| self, mod: tvm.ir.IRModule, ctx: tvm.ir.transform.PassContext | ||
| ) -> tvm.ir.IRModule: | ||
| """Legalize the oerators that can be offloaded to the NPU""" |
There was a problem hiding this comment.
A different docstring appeared in the rebase, so I kept that that different docstring
| qnn_avgpool2d_pattern(), | ||
| lambda pat: AvgPool2DParams(pat).is_valid(), | ||
| ), | ||
| ("ethosu.strided_slice", strided_slice_pattern(), lambda pat: True), |
There was a problem hiding this comment.
Let's put the proper restrictions here so we don't accidentally offload, for example, floating point tensors.
| Parameters | ||
| ---------- | ||
| stmt : tvm.tir.AttrStmt | ||
| The outermost attribute statement of a convolution loop nest. |
| .describe(R"code(Identity operator for Ethos-U NPUs. | ||
|
|
||
| This Relay operator performs the identity operation on Ethos(TM)-U NPU with a capability | ||
| to requantize the data. It accepts input with any shape that is less or equal to 4. |
There was a problem hiding this comment.
Maybe 'It accepts input tensors of 4 dimensions or less.'?
|
|
||
|
|
||
| @pytest.mark.parametrize("accel_type", ACCEL_TYPES) | ||
| @pytest.mark.parametrize( |
There was a problem hiding this comment.
We should either test the 'special' indices for reshape (-1 and -2), or we should explicitly disallow these.
| ], | ||
| ) | ||
| def test_relay_reshape_codegen(ifm_shape, new_shape, accel_type): | ||
| # Create a "partitioned" Relay graph |
There was a problem hiding this comment.
It seems like some of this could be refactored out into a common function and reused between tests.
| run_opt_pass(func, relay.transform.InferType()) | ||
|
|
||
|
|
||
| def test_ethosu_invalid_invalid_dtype(): |
There was a problem hiding this comment.
test_ethosu_identity_invalid_dtype
| run_opt_pass(func, relay.transform.InferType()) | ||
|
|
||
|
|
||
| def test_ethosu_identity_invalid_shape(): |
There was a problem hiding this comment.
I think we need to test the valid cases as well.
* Add the ethosu.identity operator which returns the input tensor * Add an opportunity to requantize the tensor * Add legalization for reshape and strided slice * Add a pass that puts an indentity op after a no-op Change-Id: I0adb5ca269f8529c79e0e7681ca4b5147d8f53c8
Change-Id: Icc9b6507f164681a5d6b1fcff2ae4a5051d44734
Change-Id: I63f30f84ad481789fc047ad8c2107f5313562f7f
75d1117 to
ac87b0b
Compare
|
@mbaret @NicolaLancellotti @lhutton1 thanks for the reviews, much appreciated! :) |
|
Thanks everyone, this is now merged! |
* Add the Arm(R) Ethos(TM)-U NPU identity operator * Add the ethosu.identity operator which returns the input tensor * Add an opportunity to requantize the tensor * Add legalization for reshape and strided slice * Add a pass that puts an indentity op after a no-op Change-Id: I0adb5ca269f8529c79e0e7681ca4b5147d8f53c8 * Fix the pylint errors Change-Id: Icc9b6507f164681a5d6b1fcff2ae4a5051d44734 * Changes in response to review comments Change-Id: I63f30f84ad481789fc047ad8c2107f5313562f7f
* Add the Arm(R) Ethos(TM)-U NPU identity operator * Add the ethosu.identity operator which returns the input tensor * Add an opportunity to requantize the tensor * Add legalization for reshape and strided slice * Add a pass that puts an indentity op after a no-op Change-Id: I0adb5ca269f8529c79e0e7681ca4b5147d8f53c8 * Fix the pylint errors Change-Id: Icc9b6507f164681a5d6b1fcff2ae4a5051d44734 * Changes in response to review comments Change-Id: I63f30f84ad481789fc047ad8c2107f5313562f7f
* Add the Arm(R) Ethos(TM)-U NPU identity operator * Add the ethosu.identity operator which returns the input tensor * Add an opportunity to requantize the tensor * Add legalization for reshape and strided slice * Add a pass that puts an indentity op after a no-op Change-Id: I0adb5ca269f8529c79e0e7681ca4b5147d8f53c8 * Fix the pylint errors Change-Id: Icc9b6507f164681a5d6b1fcff2ae4a5051d44734 * Changes in response to review comments Change-Id: I63f30f84ad481789fc047ad8c2107f5313562f7f
* Add the Arm(R) Ethos(TM)-U NPU identity operator * Add the ethosu.identity operator which returns the input tensor * Add an opportunity to requantize the tensor * Add legalization for reshape and strided slice * Add a pass that puts an indentity op after a no-op Change-Id: I0adb5ca269f8529c79e0e7681ca4b5147d8f53c8 * Fix the pylint errors Change-Id: Icc9b6507f164681a5d6b1fcff2ae4a5051d44734 * Changes in response to review comments Change-Id: I63f30f84ad481789fc047ad8c2107f5313562f7f
* Add the Arm(R) Ethos(TM)-U NPU identity operator * Add the ethosu.identity operator which returns the input tensor * Add an opportunity to requantize the tensor * Add legalization for reshape and strided slice * Add a pass that puts an indentity op after a no-op Change-Id: I0adb5ca269f8529c79e0e7681ca4b5147d8f53c8 * Fix the pylint errors Change-Id: Icc9b6507f164681a5d6b1fcff2ae4a5051d44734 * Changes in response to review comments Change-Id: I63f30f84ad481789fc047ad8c2107f5313562f7f