Пример #1
0
func (phi *ConvMulti) Apply(x *rimg64.Multi) (*rimg64.Multi, error) {
	if x.Channels != phi.Filters.Channels {
		err := fmt.Errorf(
			"channels: image has %d, filter bank has %d",
			x.Channels, phi.Filters.Channels,
		)
		return nil, err
	}
	if phi.Stride <= 1 {
		return slide.CorrMultiBankBLAS(x, phi.Filters)
	}
	return slide.CorrMultiBankStrideBLAS(x, phi.Filters, phi.Stride)
}
Пример #2
0
func TestCorrMultiBankBLAS_vsNaive(t *testing.T) {
	const (
		m   = 40
		n   = 30
		w   = 100
		h   = 80
		p   = 4
		q   = 6
		eps = 1e-9
	)
	f := randMulti(w, h, p)
	g := randMultiBank(w, h, p, q)
	naive, err := slide.CorrMultiBankNaive(f, g)
	if err != nil {
		t.Fatal(err)
	}
	blas, err := slide.CorrMultiBankBLAS(f, g)
	if err != nil {
		t.Fatal(err)
	}
	if err := errIfNotEqMulti(naive, blas, eps); err != nil {
		t.Fatal(err)
	}
}