[dev.simd] cmd/compile, simd: reorder PairDotProdAccumulate

This CL reorderes the param order of PairDotProdAccumulate family to be
dotprod(x, y) + z instead of the old dotprod(y, z) + x.

This CL also updates some documentation of other ML Ops.

This CL added a test to test the behavior is correct.

This CL is partially generated by CL 688115.

Change-Id: I76a6ee55a2ad8e3aff388d7e4fa5218ec0e4800d
Reviewed-on: https://go-review.googlesource.com/c/go/+/688095
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Junyang Shao 2025-07-15 05:13:55 +00:00
parent ef5f6cc921
commit c61743e4f0
9 changed files with 288 additions and 1008 deletions

View file

@ -202,6 +202,25 @@ func TestAndNot(t *testing.T) {
[]int32{0b10, 0b00, 0b10, 0b00}, "AndNot")
}
func TestPairDotProdAccumulate(t *testing.T) {
if !simd.HasAVX512GFNI() {
// TODO: this function is actually VNNI, let's implement and call the right check.
t.Skip("Test requires HasAVX512GFNI, not available on this hardware")
return
}
x := simd.LoadInt16x8Slice([]int16{2, 2, 2, 2, 2, 2, 2, 2})
z := simd.LoadInt32x4Slice([]int32{3, 3, 3, 3})
want := []int32{11, 11, 11, 11}
got := make([]int32, 4)
z = x.PairDotProdAccumulate(x, z)
z.StoreSlice(got)
for i := range 4 {
if got[i] != want[i] {
t.Errorf("a and b differ at index %d, got=%d, want=%d", i, got[i], want[i])
}
}
}
// checkInt8Slices ensures that b and a are equal, to the end of b.
// also serves to use the slices, to prevent accidental optimization.
func checkInt8Slices(t *testing.T, a, b []int8) {