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
+
+
[email protected](
+    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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to