"server/text_generation_server/layers/attention/ipex.py" did not exist on "b64c70c9e7a2a416117cb6b317cb85e5d679717a"
chunks_test.go 1.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package chunks

import (
	"slices"
	"testing"
)

func TestOf(t *testing.T) {
	cases := []struct {
		total     int64
		chunkSize int64
		want      []Chunk
	}{
		{0, 1, nil},
		{1, 1, []Chunk{{0, 0}}},
		{1, 2, []Chunk{{0, 0}}},
		{2, 1, []Chunk{{0, 0}, {1, 1}}},
		{10, 9, []Chunk{{0, 8}, {9, 9}}},
	}

	for _, tt := range cases {
		got := slices.Collect(Of(tt.total, tt.chunkSize))
		if !slices.Equal(got, tt.want) {
			t.Errorf("[%d/%d]: got %v; want %v", tt.total, tt.chunkSize, got, tt.want)
		}
	}
}

func TestSize(t *testing.T) {
	cases := []struct {
		c    Chunk
		want int64
	}{
		{Chunk{0, 0}, 1},
		{Chunk{0, 1}, 2},
		{Chunk{3, 4}, 2},
	}

	for _, tt := range cases {
		got := tt.c.Size()
		if got != tt.want {
			t.Errorf("%v: got %d; want %d", tt.c, got, tt.want)
		}
	}
}

func TestCount(t *testing.T) {
	cases := []struct {
		total     int64
		chunkSize int64
		want      int64
	}{
		{0, 1, 0},
		{1, 1, 1},
		{1, 2, 1},
		{2, 1, 2},
		{10, 9, 2},
	}
	for _, tt := range cases {
		got := Count(tt.total, tt.chunkSize)
		if got != tt.want {
			t.Errorf("[%d/%d]: got %d; want %d", tt.total, tt.chunkSize, got, tt.want)
		}
	}
}