Example #1
0
func TestCorrMultiBankStrideNaive_vsDecimate(t *testing.T) {
	const (
		numIn  = 3
		numOut = 4
		eps    = 1e-9
	)
	for _, q := range strideCases {
		f := randMulti(q.ImSize.X, q.ImSize.Y, numIn)
		g := randMultiBank(q.TmplSize.X, q.TmplSize.Y, numIn, numOut)
		h, err := slide.CorrMultiBankNaive(f, g)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		want := slide.DecimateMulti(h, q.K)
		got, err := slide.CorrMultiBankStrideNaive(f, g, q.K)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		if err := errIfNotEqMulti(want, got, eps); err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
	}
}
Example #2
0
func TestCorrMultiBankStrideBLAS_vsNaive(t *testing.T) {
	const (
		m      = 40
		n      = 30
		w      = 100
		h      = 80
		numIn  = 4
		numOut = 6
		r      = 3
		eps    = 1e-9
	)
	f := randMulti(w, h, numIn)
	g := randMultiBank(w, h, numIn, numOut)
	naive, err := slide.CorrMultiBankStrideNaive(f, g, r)
	if err != nil {
		t.Fatal(err)
	}
	blas, err := slide.CorrMultiBankStrideBLAS(f, g, r)
	if err != nil {
		t.Fatal(err)
	}
	if err := errIfNotEqMulti(naive, blas, eps); err != nil {
		t.Fatal(err)
	}
}