You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/08/22 10:59:40 UTC
[GitHub] [tvm] NicolaLancellotti opened a new pull request, #12535: [ETHOSN] Add support for Resize
NicolaLancellotti opened a new pull request, #12535:
URL: https://github.com/apache/tvm/pull/12535
This commit adds support for the resize operator for the Arm(R) Ethos(TM)-N NPU.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] NicolaLancellotti commented on a diff in pull request #12535: [ETHOSN] Add support for Resize
Posted by GitBox <gi...@apache.org>.
NicolaLancellotti commented on code in PR #12535:
URL: https://github.com/apache/tvm/pull/12535#discussion_r952805038
##########
tests/python/contrib/test_ethosn/test_resize.py:
##########
@@ -0,0 +1,119 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Arm(R) Ethos(TM)-N integration resize tests"""
+
+import pytest
+import numpy as np
+import tvm
+from tvm import relay
+from tvm.testing import requires_ethosn
+from . import infrastructure as tei
+
+
+def _get_model(shape, dtype, size, input_zp, input_sc, output_zp, output_sc):
+ x = relay.var("x", shape=shape, dtype=dtype)
+ resize = relay.image.resize2d(
+ data=x,
+ size=size,
+ layout="NHWC",
+ method="nearest_neighbor",
+ coordinate_transformation_mode="asymmetric",
+ )
+ model = relay.qnn.op.requantize(
+ resize,
+ input_scale=relay.const(input_sc, "float32"),
+ input_zero_point=relay.const(input_zp, "int32"),
+ output_scale=relay.const(output_sc, "float32"),
+ output_zero_point=relay.const(output_zp, "int32"),
+ out_dtype=dtype,
+ )
+ return model
+
+
+@requires_ethosn
+@pytest.mark.parametrize("dtype", ["uint8", "int8"])
+@pytest.mark.parametrize(
+ "shape, size",
+ [
+ ((1, 4, 4, 2), (8, 8)),
+ ((1, 4, 4, 2), (7, 7)),
+ ((1, 4, 8, 3), (8, 16)),
+ ((1, 4, 8, 3), (7, 15)),
+ ],
+)
+def test_resize(dtype, shape, size):
+ np.random.seed(0)
+ zp_min = np.iinfo(dtype).min
+ zp_max = np.iinfo(dtype).max
+ inputs = {
+ "x": tvm.nd.array(np.random.randint(zp_min, high=zp_max + 1, size=shape, dtype=dtype)),
+ }
+ outputs = []
+ for npu in [False, True]:
+ model = _get_model(
+ shape=shape,
+ dtype=dtype,
+ size=size,
+ input_zp=zp_min + 128,
+ input_sc=0.0784314,
+ output_zp=zp_min + 128,
+ output_sc=0.0784314,
+ )
+ mod = tei.make_module(model, {})
+ x = tei.build_and_run(mod, inputs, 1, {}, npu=npu)
+ outputs.append(x)
+
+ tei.verify(outputs, dtype, 1)
+
+
+@requires_ethosn
+def test_requantize_failure():
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] leandron commented on pull request #12535: [ETHOSN] Add support for Resize
Posted by GitBox <gi...@apache.org>.
leandron commented on PR #12535:
URL: https://github.com/apache/tvm/pull/12535#issuecomment-1224268224
This can be merged once CI is green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] leandron commented on a diff in pull request #12535: [ETHOSN] Add support for Resize
Posted by GitBox <gi...@apache.org>.
leandron commented on code in PR #12535:
URL: https://github.com/apache/tvm/pull/12535#discussion_r952317035
##########
tests/python/contrib/test_ethosn/test_resize.py:
##########
@@ -0,0 +1,119 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Arm(R) Ethos(TM)-N integration resize tests"""
+
+import pytest
+import numpy as np
+import tvm
+from tvm import relay
+from tvm.testing import requires_ethosn
+from . import infrastructure as tei
+
+
+def _get_model(shape, dtype, size, input_zp, input_sc, output_zp, output_sc):
+ x = relay.var("x", shape=shape, dtype=dtype)
+ resize = relay.image.resize2d(
+ data=x,
+ size=size,
+ layout="NHWC",
+ method="nearest_neighbor",
+ coordinate_transformation_mode="asymmetric",
+ )
+ model = relay.qnn.op.requantize(
+ resize,
+ input_scale=relay.const(input_sc, "float32"),
+ input_zero_point=relay.const(input_zp, "int32"),
+ output_scale=relay.const(output_sc, "float32"),
+ output_zero_point=relay.const(output_zp, "int32"),
+ out_dtype=dtype,
+ )
+ return model
+
+
+@requires_ethosn
+@pytest.mark.parametrize("dtype", ["uint8", "int8"])
+@pytest.mark.parametrize(
+ "shape, size",
+ [
+ ((1, 4, 4, 2), (8, 8)),
+ ((1, 4, 4, 2), (7, 7)),
+ ((1, 4, 8, 3), (8, 16)),
+ ((1, 4, 8, 3), (7, 15)),
+ ],
+)
+def test_resize(dtype, shape, size):
+ np.random.seed(0)
+ zp_min = np.iinfo(dtype).min
+ zp_max = np.iinfo(dtype).max
+ inputs = {
+ "x": tvm.nd.array(np.random.randint(zp_min, high=zp_max + 1, size=shape, dtype=dtype)),
+ }
+ outputs = []
+ for npu in [False, True]:
+ model = _get_model(
+ shape=shape,
+ dtype=dtype,
+ size=size,
+ input_zp=zp_min + 128,
+ input_sc=0.0784314,
+ output_zp=zp_min + 128,
+ output_sc=0.0784314,
+ )
+ mod = tei.make_module(model, {})
+ x = tei.build_and_run(mod, inputs, 1, {}, npu=npu)
+ outputs.append(x)
+
+ tei.verify(outputs, dtype, 1)
+
+
+@requires_ethosn
+def test_requantize_failure():
Review Comment:
Is `test_requantize_failure` the expected name in this function?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] leandron merged pull request #12535: [ETHOSN] Add support for Resize
Posted by GitBox <gi...@apache.org>.
leandron merged PR #12535:
URL: https://github.com/apache/tvm/pull/12535
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org