-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathzz_generated.diffusion_model_memory_usage.regression.go
130 lines (110 loc) · 4.3 KB
/
zz_generated.diffusion_model_memory_usage.regression.go
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package gguf_parser
import "math"
// GuessSD1DiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessSD1DiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{7876368.5672, 161.4230198633, 0.0078124893}
degree := 2
x := float64(width * height)
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}
// GuessSD2DiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessSD2DiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{-355043979.0562, -1193.3271458642, 0.0054023818}
degree := 2
x := float64(width * height)
if flashAttention {
coefficients = []float64{3780681.28078, 513.2102510935}
degree = 1
}
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}
// GuessSDXLDiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessSDXLDiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{55541290.3893, 138.3196116655, 0.0006109455}
degree := 2
x := float64(width * height)
if flashAttention {
coefficients = []float64{-5958802.78052, 500.0687898915}
degree = 1
}
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}
// GuessSDXLRefinerDiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessSDXLRefinerDiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{49395992.3449, 155.2477810191, 0.0007351736}
degree := 2
x := float64(width * height)
if flashAttention {
coefficients = []float64{7031343.31998, 599.4137437227}
degree = 1
}
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}
// GuessSD3MediumDiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessSD3MediumDiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{16529921.3700, 234.6656247718, 0.0014648995}
degree := 2
x := float64(width * height)
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}
// GuessSD35MediumDiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessSD35MediumDiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{17441103.4726, 281.6956819806, 0.0014651233}
degree := 2
x := float64(width * height)
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}
// GuessSD35LargeDiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessSD35LargeDiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{23204369.2029, 410.3731196298, 0.0023195947}
degree := 2
x := float64(width * height)
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}
// GuessFLUXDiffusionModelMemoryUsage returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func GuessFLUXDiffusionModelMemoryUsage(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{46511668.6742, 997.7758807792, 0.0014573393}
degree := 2
x := float64(width * height)
y := float64(0)
for i := 0; i <= degree; i++ {
y += coefficients[i] * math.Pow(x, float64(i))
}
return uint64(y)
}