You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "neildhickey (via GitHub)" <gi...@apache.org> on 2023/03/08 16:21:08 UTC
[GitHub] [tvm] neildhickey opened a new pull request, #14239: [SVE] Adding codegen tests for SVE
neildhickey opened a new pull request, #14239:
URL: https://github.com/apache/tvm/pull/14239
Now that ci_arm contains LLVM 15, add tests to check that code for SVE can be correctly generated.
Add tests to cover a selection of arithmetic ops and gather loads. The gather load is currently xfailed until work is completed to enable them through TVM and LLVM.
--
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] Mousius commented on a diff in pull request #14239: [SVE] Adding codegen tests for SVE
Posted by "Mousius (via GitHub)" <gi...@apache.org>.
Mousius commented on code in PR #14239:
URL: https://github.com/apache/tvm/pull/14239#discussion_r1129745661
##########
tests/python/unittest/test_target_codegen_aarch64.py:
##########
@@ -0,0 +1,545 @@
+# 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.
+import tvm
+from tvm import te
+from tvm.script import tir as TIR
+import re
+import os
+import ctypes
+import pytest
+
+from tvm.target.codegen import llvm_version_major
+
+
+@pytest.mark.skipif(
+ llvm_version_major() < 15, reason="Test requires an LLVM version of at least 15 to target SVE"
Review Comment:
What happens if we upgrade this in a non-SVE enabled environment?
--
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] neildhickey commented on a diff in pull request #14239: [SVE] Adding codegen tests for SVE
Posted by "neildhickey (via GitHub)" <gi...@apache.org>.
neildhickey commented on code in PR #14239:
URL: https://github.com/apache/tvm/pull/14239#discussion_r1130694786
##########
tests/python/unittest/test_target_codegen_aarch64.py:
##########
@@ -0,0 +1,545 @@
+# 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.
+import tvm
+from tvm import te
+from tvm.script import tir as TIR
+import re
+import os
+import ctypes
+import pytest
+
+from tvm.target.codegen import llvm_version_major
+
+
+@pytest.mark.skipif(
+ llvm_version_major() < 15, reason="Test requires an LLVM version of at least 15 to target SVE"
+)
+def test_mul():
+ target = "llvm -mtriple=aarch64-linux-gnu -mattr=+sve"
+
+ def check_correct_assembly(type):
+ m = te.var("m")
+ A = te.placeholder(m, dtype=type, name="A")
+ B = te.placeholder(m, dtype=type, name="B")
+ C = te.compute((m), lambda i: A[i] * B[i], name="C")
+ s = te.create_schedule([C.op])
+
+ f = tvm.build(s, [A, B, C], target)
+
+ # Verify we see SVE load instructions and mul instructions using z registers
+ assembly = f.get_source("asm")
+ loads = re.findall("ld1[whdb] { z", assembly)
+ matches = re.findall(
+ r"mul\tz[0-9].[shdb],( p[0-9]/[m],)? z[0-9].[shdb], z[0-9].[shdb]", assembly
+ )
+
+ assert len(loads) > 1
+ assert len(matches) > 1
+
+ check_correct_assembly("float")
+ check_correct_assembly("float16")
+ check_correct_assembly("uint8")
+ check_correct_assembly("uint16")
+ check_correct_assembly("uint32")
+ check_correct_assembly("uint64")
+ check_correct_assembly("int8")
+ check_correct_assembly("int16")
+ check_correct_assembly("int32")
+ check_correct_assembly("int64")
Review Comment:
Do you mean using @pytest.mark.parametrize for the dtype? Yes we could actually, thanks for pointing that out. Originally I'd tried to make use of python generics to allow different types but this didn't work within TVM, but I will make this improvement to the code.
--
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] tvm-bot commented on pull request #14239: [SVE] Adding codegen tests for SVE
Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #14239:
URL: https://github.com/apache/tvm/pull/14239#issuecomment-1460437981
<!---bot-comment-->
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
<!--bot-comment-ccs-start-->
* No users to tag found in teams: `sve` <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
<sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>
--
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 #14239: [SVE] Adding codegen tests for SVE
Posted by "leandron (via GitHub)" <gi...@apache.org>.
leandron merged PR #14239:
URL: https://github.com/apache/tvm/pull/14239
--
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] ashutosh-arm commented on a diff in pull request #14239: [SVE] Adding codegen tests for SVE
Posted by "ashutosh-arm (via GitHub)" <gi...@apache.org>.
ashutosh-arm commented on code in PR #14239:
URL: https://github.com/apache/tvm/pull/14239#discussion_r1129840752
##########
tests/python/unittest/test_target_codegen_aarch64.py:
##########
@@ -0,0 +1,545 @@
+# 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.
+import tvm
+from tvm import te
+from tvm.script import tir as TIR
+import re
+import os
+import ctypes
+import pytest
+
+from tvm.target.codegen import llvm_version_major
+
+
+@pytest.mark.skipif(
+ llvm_version_major() < 15, reason="Test requires an LLVM version of at least 15 to target SVE"
+)
+def test_mul():
+ target = "llvm -mtriple=aarch64-linux-gnu -mattr=+sve"
+
+ def check_correct_assembly(type):
+ m = te.var("m")
+ A = te.placeholder(m, dtype=type, name="A")
+ B = te.placeholder(m, dtype=type, name="B")
+ C = te.compute((m), lambda i: A[i] * B[i], name="C")
+ s = te.create_schedule([C.op])
+
+ f = tvm.build(s, [A, B, C], target)
+
+ # Verify we see SVE load instructions and mul instructions using z registers
+ assembly = f.get_source("asm")
+ loads = re.findall("ld1[whdb] { z", assembly)
+ matches = re.findall(
+ r"mul\tz[0-9].[shdb],( p[0-9]/[m],)? z[0-9].[shdb], z[0-9].[shdb]", assembly
+ )
+
+ assert len(loads) > 1
+ assert len(matches) > 1
+
+ check_correct_assembly("float")
+ check_correct_assembly("float16")
+ check_correct_assembly("uint8")
+ check_correct_assembly("uint16")
+ check_correct_assembly("uint32")
+ check_correct_assembly("uint64")
+ check_correct_assembly("int8")
+ check_correct_assembly("int16")
+ check_correct_assembly("int32")
+ check_correct_assembly("int64")
Review Comment:
I feel like there is a reason for not parameterizing these tests with dtype. I can't seem to recall now :thinking:
--
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] neildhickey commented on a diff in pull request #14239: [SVE] Adding codegen tests for SVE
Posted by "neildhickey (via GitHub)" <gi...@apache.org>.
neildhickey commented on code in PR #14239:
URL: https://github.com/apache/tvm/pull/14239#discussion_r1130683690
##########
tests/python/unittest/test_target_codegen_aarch64.py:
##########
@@ -0,0 +1,545 @@
+# 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.
+import tvm
+from tvm import te
+from tvm.script import tir as TIR
+import re
+import os
+import ctypes
+import pytest
+
+from tvm.target.codegen import llvm_version_major
+
+
+@pytest.mark.skipif(
+ llvm_version_major() < 15, reason="Test requires an LLVM version of at least 15 to target SVE"
Review Comment:
These are not execution tests, so as long as it have at least LLVM 15, these should still run fine
--
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] ashutosh-arm commented on a diff in pull request #14239: [SVE] Adding codegen tests for SVE
Posted by "ashutosh-arm (via GitHub)" <gi...@apache.org>.
ashutosh-arm commented on code in PR #14239:
URL: https://github.com/apache/tvm/pull/14239#discussion_r1130705811
##########
tests/python/unittest/test_target_codegen_aarch64.py:
##########
@@ -0,0 +1,545 @@
+# 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.
+import tvm
+from tvm import te
+from tvm.script import tir as TIR
+import re
+import os
+import ctypes
+import pytest
+
+from tvm.target.codegen import llvm_version_major
+
+
+@pytest.mark.skipif(
+ llvm_version_major() < 15, reason="Test requires an LLVM version of at least 15 to target SVE"
+)
+def test_mul():
+ target = "llvm -mtriple=aarch64-linux-gnu -mattr=+sve"
+
+ def check_correct_assembly(type):
+ m = te.var("m")
+ A = te.placeholder(m, dtype=type, name="A")
+ B = te.placeholder(m, dtype=type, name="B")
+ C = te.compute((m), lambda i: A[i] * B[i], name="C")
+ s = te.create_schedule([C.op])
+
+ f = tvm.build(s, [A, B, C], target)
+
+ # Verify we see SVE load instructions and mul instructions using z registers
+ assembly = f.get_source("asm")
+ loads = re.findall("ld1[whdb] { z", assembly)
+ matches = re.findall(
+ r"mul\tz[0-9].[shdb],( p[0-9]/[m],)? z[0-9].[shdb], z[0-9].[shdb]", assembly
+ )
+
+ assert len(loads) > 1
+ assert len(matches) > 1
+
+ check_correct_assembly("float")
+ check_correct_assembly("float16")
+ check_correct_assembly("uint8")
+ check_correct_assembly("uint16")
+ check_correct_assembly("uint32")
+ check_correct_assembly("uint64")
+ check_correct_assembly("int8")
+ check_correct_assembly("int16")
+ check_correct_assembly("int32")
+ check_correct_assembly("int64")
Review Comment:
I couldn't recall it was generics that were not working with TIR. Yes, I meant the `@pytest.mark.parametrize`. Thanks :)
--
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