[Mlir-commits] [mlir] [mlir][SVE] Add more e2e test for vector.contract (PR #70367)
Benjamin Maxwell
llvmlistbot at llvm.org
Fri Oct 27 03:29:43 PDT 2023
================
@@ -30,6 +56,65 @@
iterator_types = ["parallel", "parallel", "reduction"]
}
+// Contraction: dot-product a x b.
+func.func @dot_product_i32() {
+ %acc = arith.constant 0: i32
+
+ %vector_a = arith.constant dense<123> : vector<[4]xi32>
+ %vector_b = arith.constant dense<314> : vector<[4]xi32>
+ %vector_c = arith.constant dense<0> : vector<[4]xi32>
+
+ // The result of this dot-product will depend
+ // on the vector length, so we are unable to verify it.
+ %dp1 = vector.contract #dotp_trait %vector_a, %vector_b, %acc
+ : vector<[4]xi32>, vector<[4]xi32> into i32
+ // Dot product should be (123 * 314) * 4 * vscale, so ...
+ %vscale = vector.vscale
+ %vscale_i32 = arith.index_cast %vscale : index to i32
+ %dp1_divvl = arith.divui %dp1, %vscale_i32 : i32
+ // ... %dp/%vscale = 123 * 314 * 4 = 154488
+ // DP: 154488
+ vector.print %dp1_divvl : i32
+
+ // The result of this dot-product should be 0.
+ %dp2 = vector.contract #dotp_trait %vector_a, %vector_c, %acc
+ : vector<[4]xi32>, vector<[4]xi32> into i32
+ // DP: 0
+ vector.print %dp2 : i32
+
+ // DP: SVE: END OF TEST OUTPUT
+ vector.print str "SVE: END OF TEST OUTPUT"
+
+ return
+}
+
+// Contraction: matrix-vector A x c
+func.func @matvec_i32() {
+ %acc = arith.constant dense<0>: vector<3xi32>
+
+ %vector_a = arith.constant dense<123> : vector<3x[4]xi32>
+ %vector_b = arith.constant dense<314> : vector<[4]xi32>
+ %vector_c = arith.constant dense<0> : vector<[4]xi32>
+
+ // The result of this matvec will depend on the vector length, so we are
+ // unable to verify it.
----------------
MacDue wrote:
P.s. You can do the same trick here :)
https://github.com/llvm/llvm-project/pull/70367
More information about the Mlir-commits
mailing list