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/06/02 18:41:49 UTC
[GitHub] [tvm] jcoplin-quic opened a new pull request, #11549: [HEXAGON] Initial clip operator for Hexagon
jcoplin-quic opened a new pull request, #11549:
URL: https://github.com/apache/tvm/pull/11549
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
cc @mehrdadh
--
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] jcoplin-quic commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
jcoplin-quic commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r907537875
##########
tests/python/contrib/test_hexagon/topi/test_clip.py:
##########
@@ -0,0 +1,127 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from ..infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 8, 4, 32], [1, 8, 4, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
+ @tvm.testing.requires_hexagon
+ def test_clip_slice(
+ self,
+ input_shape,
+ output_shape,
+ input_np,
+ input_layout,
+ output_layout,
+ dtype,
+ A_min,
+ A_max,
+ transformed_input_np,
+ transformed_expected_output_np,
+ hexagon_session,
+ ):
+ # establish target and input placeholder
+ target_hexagon = tvm.target.hexagon("v68")
+ A = te.placeholder(input_shape, name="A", dtype=dtype)
+
+ # get the compute function and schedule
+ M = sl.clip_compute(A, A_min, A_max)
+
+ # Assume layout is nhwc-8h2w32c2w-2d
+ tir_schedule = sl.clip_schedule(M, A, output_layout, input_layout)
+ sch = tir_schedule.mod
+
+ # build the function
+ with tvm.transform.PassContext(opt_level=3):
+ func = tvm.build(
+ sch, [A, M], tvm.target.Target(target_hexagon, host=target_hexagon), name="clip"
Review Comment:
Thanks @csullivan and @Lunderberg . At line 85, I assign `tir_schedule.mod` to `sch`. So `sch` should be `IRModule`, not `tvm.tir.Schedule`
--
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] jcoplin-quic commented on pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
jcoplin-quic commented on PR #11549:
URL: https://github.com/apache/tvm/pull/11549#issuecomment-1146183496
@mehrdadh I'm seeing a segmentation fault in one of the CPU integration steps. Is this a known issue? If so is there a fix?
--
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] jcoplin-quic commented on pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
jcoplin-quic commented on PR #11549:
URL: https://github.com/apache/tvm/pull/11549#issuecomment-1155385898
@TejashShah could you please assign some reviewers to this PR
--
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] mehrdadh commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
mehrdadh commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r902830263
##########
tests/python/contrib/test_hexagon/test_clip.py:
##########
@@ -0,0 +1,126 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from .infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 256, 256, 32], [1, 256, 256, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
Review Comment:
add `@tvm.testing.requires_hexagon`?
--
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] TejashShah commented on pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
TejashShah commented on PR #11549:
URL: https://github.com/apache/tvm/pull/11549#issuecomment-1155714496
cc @Lunderberg @cconvey @csullivan
--
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] jcoplin-quic commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
jcoplin-quic commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r906108069
##########
tests/python/contrib/test_hexagon/topi/test_clip.py:
##########
@@ -0,0 +1,127 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from ..infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 8, 4, 32], [1, 8, 4, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
+ @tvm.testing.requires_hexagon
+ def test_clip_slice(
+ self,
+ input_shape,
+ output_shape,
+ input_np,
+ input_layout,
+ output_layout,
+ dtype,
+ A_min,
+ A_max,
+ transformed_input_np,
+ transformed_expected_output_np,
+ hexagon_session,
+ ):
+ # establish target and input placeholder
+ target_hexagon = tvm.target.hexagon("v68")
+ A = te.placeholder(input_shape, name="A", dtype=dtype)
+
+ # get the compute function and schedule
+ M = sl.clip_compute(A, A_min, A_max)
+
+ # Assume layout is nhwc-8h2w32c2w-2d
+ tir_schedule = sl.clip_schedule(M, A, output_layout, input_layout)
+ sch = tir_schedule.mod
+
+ # build the function
+ with tvm.transform.PassContext(opt_level=3):
+ func = tvm.build(
+ sch, [A, M], tvm.target.Target(target_hexagon, host=target_hexagon), name="clip"
Review Comment:
Hi @Lunderberg removing this argument is causing the build to fail. It's not immediately evident to me why. Would you have any insight?
--
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] Lunderberg commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
Lunderberg commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r905085325
##########
tests/python/contrib/test_hexagon/topi/test_clip.py:
##########
@@ -0,0 +1,127 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from ..infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 8, 4, 32], [1, 8, 4, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
+ @tvm.testing.requires_hexagon
+ def test_clip_slice(
+ self,
+ input_shape,
+ output_shape,
+ input_np,
+ input_layout,
+ output_layout,
+ dtype,
+ A_min,
+ A_max,
+ transformed_input_np,
+ transformed_expected_output_np,
+ hexagon_session,
+ ):
+ # establish target and input placeholder
+ target_hexagon = tvm.target.hexagon("v68")
+ A = te.placeholder(input_shape, name="A", dtype=dtype)
+
+ # get the compute function and schedule
+ M = sl.clip_compute(A, A_min, A_max)
+
+ # Assume layout is nhwc-8h2w32c2w-2d
+ tir_schedule = sl.clip_schedule(M, A, output_layout, input_layout)
+ sch = tir_schedule.mod
+
+ # build the function
+ with tvm.transform.PassContext(opt_level=3):
+ func = tvm.build(
+ sch, [A, M], tvm.target.Target(target_hexagon, host=target_hexagon), name="clip"
Review Comment:
The `[A, M]` argument can be removed. See comment [here](https://github.com/apache/tvm/pull/11522#discussion_r887987912).
--
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] driazati commented on pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
driazati commented on PR #11549:
URL: https://github.com/apache/tvm/pull/11549#issuecomment-1163507076
hey @jcoplin-quic, CI was busted when you pushed so the build never started, could you rebase/merge with `main` and push to your PR branch again?
--
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] jcoplin-quic commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
jcoplin-quic commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r907545763
##########
tests/python/contrib/test_hexagon/topi/test_clip.py:
##########
@@ -0,0 +1,127 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from ..infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 8, 4, 32], [1, 8, 4, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
+ @tvm.testing.requires_hexagon
+ def test_clip_slice(
+ self,
+ input_shape,
+ output_shape,
+ input_np,
+ input_layout,
+ output_layout,
+ dtype,
+ A_min,
+ A_max,
+ transformed_input_np,
+ transformed_expected_output_np,
+ hexagon_session,
+ ):
+ # establish target and input placeholder
+ target_hexagon = tvm.target.hexagon("v68")
+ A = te.placeholder(input_shape, name="A", dtype=dtype)
+
+ # get the compute function and schedule
+ M = sl.clip_compute(A, A_min, A_max)
+
+ # Assume layout is nhwc-8h2w32c2w-2d
+ tir_schedule = sl.clip_schedule(M, A, output_layout, input_layout)
+ sch = tir_schedule.mod
+
+ # build the function
+ with tvm.transform.PassContext(opt_level=3):
+ func = tvm.build(
+ sch, [A, M], tvm.target.Target(target_hexagon, host=target_hexagon), name="clip"
Review Comment:
I think it had to do with optional argument `target `being treated as a positional argument
--
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] mehrdadh commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
mehrdadh commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r902830638
##########
tests/python/contrib/test_hexagon/test_clip.py:
##########
@@ -0,0 +1,126 @@
+# Licensed to the Apache Software Foundation (ASF) under one
Review Comment:
please move this file to `test_hexagon/topi`
--
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] csullivan commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
csullivan commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r906178546
##########
tests/python/contrib/test_hexagon/topi/test_clip.py:
##########
@@ -0,0 +1,127 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from ..infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 8, 4, 32], [1, 8, 4, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
+ @tvm.testing.requires_hexagon
+ def test_clip_slice(
+ self,
+ input_shape,
+ output_shape,
+ input_np,
+ input_layout,
+ output_layout,
+ dtype,
+ A_min,
+ A_max,
+ transformed_input_np,
+ transformed_expected_output_np,
+ hexagon_session,
+ ):
+ # establish target and input placeholder
+ target_hexagon = tvm.target.hexagon("v68")
+ A = te.placeholder(input_shape, name="A", dtype=dtype)
+
+ # get the compute function and schedule
+ M = sl.clip_compute(A, A_min, A_max)
+
+ # Assume layout is nhwc-8h2w32c2w-2d
+ tir_schedule = sl.clip_schedule(M, A, output_layout, input_layout)
+ sch = tir_schedule.mod
+
+ # build the function
+ with tvm.transform.PassContext(opt_level=3):
+ func = tvm.build(
+ sch, [A, M], tvm.target.Target(target_hexagon, host=target_hexagon), name="clip"
Review Comment:
Hi @jcoplin-quic, with TIR schedules you'll want to pass in the module, sch.mod, in which case you don't need the tensor list as @Lunderberg pointed out.
--
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] Lunderberg commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
Lunderberg commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r907495539
##########
tests/python/contrib/test_hexagon/topi/test_clip.py:
##########
@@ -0,0 +1,127 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from ..infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 8, 4, 32], [1, 8, 4, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
+ @tvm.testing.requires_hexagon
+ def test_clip_slice(
+ self,
+ input_shape,
+ output_shape,
+ input_np,
+ input_layout,
+ output_layout,
+ dtype,
+ A_min,
+ A_max,
+ transformed_input_np,
+ transformed_expected_output_np,
+ hexagon_session,
+ ):
+ # establish target and input placeholder
+ target_hexagon = tvm.target.hexagon("v68")
+ A = te.placeholder(input_shape, name="A", dtype=dtype)
+
+ # get the compute function and schedule
+ M = sl.clip_compute(A, A_min, A_max)
+
+ # Assume layout is nhwc-8h2w32c2w-2d
+ tir_schedule = sl.clip_schedule(M, A, output_layout, input_layout)
+ sch = tir_schedule.mod
+
+ # build the function
+ with tvm.transform.PassContext(opt_level=3):
+ func = tvm.build(
+ sch, [A, M], tvm.target.Target(target_hexagon, host=target_hexagon), name="clip"
Review Comment:
Agreed, the `IRModule` should be passed to `tvm.build`, rather than the `tvm.tir.Schedule`. I've submitted https://github.com/apache/tvm/pull/11913 to improve the error message, as I can definitely see the confusion when the error message doesn't distinguish between expected a `te.Schedule` or `tir.Schedule`.
--
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] kparzysz-quic merged pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
kparzysz-quic merged PR #11549:
URL: https://github.com/apache/tvm/pull/11549
--
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] jcoplin-quic commented on a diff in pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
jcoplin-quic commented on code in PR #11549:
URL: https://github.com/apache/tvm/pull/11549#discussion_r903934192
##########
tests/python/contrib/test_hexagon/test_clip.py:
##########
@@ -0,0 +1,126 @@
+# 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.
+
+# pylint: disable=invalid-name
+
+import pytest
+import numpy as np
+
+from tvm import te, topi
+
+import tvm.testing
+from tvm.topi import testing
+from tvm.contrib.hexagon.build import HexagonLauncher
+import tvm.topi.hexagon.slice_ops as sl
+from .infrastructure import allocate_hexagon_array, transform_numpy
+
+input_layout = tvm.testing.parameter(
+ "nhwc-8h2w32c2w-2d",
+)
+
+
+@tvm.testing.fixture
+def input_np(input_shape, dtype):
+ return np.random.random(input_shape).astype(dtype)
+
+
+@tvm.testing.fixture
+def transformed_expected_output_np(expected_output_np, output_layout):
+ return transform_numpy(expected_output_np, "nhwc", output_layout)
+
+
+@tvm.testing.fixture
+def transformed_input_np(input_np, input_layout):
+ return transform_numpy(input_np, "nhwc", input_layout)
+
+
+class TestClipSlice:
+ input_shape, output_shape, A_min, A_max, output_layout, dtype = tvm.testing.parameters(
+ ([1, 256, 256, 32], [1, 256, 256, 32], 0.1, 0.5, "nhwc-8h2w32c2w-2d", "float16")
+ )
+
+ @tvm.testing.fixture
+ def expected_output_np(self, input_np, A_min, A_max):
+ ref_np = np.clip(input_np, A_min, A_max)
+ return ref_np
+
Review Comment:
Done
##########
tests/python/contrib/test_hexagon/test_clip.py:
##########
@@ -0,0 +1,126 @@
+# Licensed to the Apache Software Foundation (ASF) under one
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] jcoplin-quic commented on pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
jcoplin-quic commented on PR #11549:
URL: https://github.com/apache/tvm/pull/11549#issuecomment-1161897067
@mehrdadh I'm not sure why the tests are failing. Would you be able to provide any insight?
--
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] mehrdadh commented on pull request #11549: [HEXAGON] Initial clip operator for Hexagon
Posted by GitBox <gi...@apache.org>.
mehrdadh commented on PR #11549:
URL: https://github.com/apache/tvm/pull/11549#issuecomment-1157916831
@jcoplin-quic please add some detail to the PR description.
--
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