[Mlir-commits] [mlir] [mlir][SVE] Add more e2e test for vector.contract (PR #70367)
Benjamin Maxwell
llvmlistbot at llvm.org
Fri Oct 27 01:48:39 PDT 2023
================
@@ -30,6 +56,60 @@
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
+ // DP: {{[0-9]*}}
+ vector.print %dp1 : i32
----------------
MacDue wrote:
(Optional, I think this is fine)
Since the input vectors are splats, you know enough to (indirectly) check the output:
```suggestion
%dp1 = vector.contract #dotp_trait %vector_a, %vector_b, %acc
%dp1_divvl = arith.divui %dp1, %vscale : i32
// Dot product should be (123 * 314) * vscale
// So %dp/%vscale = 123 * 314 = 38622
// DP: 38622
vector.print %dp1_divvl
```
https://github.com/llvm/llvm-project/pull/70367
More information about the Mlir-commits
mailing list