diff --git a/.github/workflows/cmd.yml b/.github/workflows/cmd.yml index 01b3303..d35a539 100644 --- a/.github/workflows/cmd.yml +++ b/.github/workflows/cmd.yml @@ -40,7 +40,7 @@ jobs: with: go-version: "1.22.9" cache-dependency-path: | - **/go.sum + cmd/**/go.sum - name: Make run: make build env: diff --git a/gen.regression.go b/gen.regression.go index f03f254..ee7b28a 100644 --- a/gen.regression.go +++ b/gen.regression.go @@ -102,13 +102,13 @@ import "math" // {{ .Name }} returns the memory usage in bytes for the given width and height, // which is calculated by linear regression or polynomial regression. func {{ .Name }}(width, height uint32, flashAttention bool) uint64 { - coefficients := []float64{ {{ range .PolynomialRegression.Coefficients }}{{ printf "%.10f" . }}, {{ end }} } + coefficients := []float64{ {{ range $i, $c := .PolynomialRegression.Coefficients }}{{ if eq $i 0 }}{{ printf "%.5f" $c }}{{ else }}{{ printf "%.10f" $c }}{{ end }}, {{ end }} } degree := {{ .PolynomialRegression.Degree }} x := float64(width * height) {{ if .LinearRegression -}} if flashAttention { - coefficients = []float64{ {{ printf "%.10f" .LinearRegression.Intercept }}, {{ printf "%.10f" .LinearRegression.Slope }} } + coefficients = []float64{ {{ printf "%.5f" .LinearRegression.Intercept }}, {{ printf "%.10f" .LinearRegression.Slope }} } degree = 1 } {{- end }} diff --git a/zz_generated.diffusion_model_memory_usage.regression.go b/zz_generated.diffusion_model_memory_usage.regression.go index a3163d5..5a17e83 100644 --- a/zz_generated.diffusion_model_memory_usage.regression.go +++ b/zz_generated.diffusion_model_memory_usage.regression.go @@ -5,7 +5,7 @@ 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.5671798782, 161.4230198633, 0.0078124893} + coefficients := []float64{7876368.56718, 161.4230198633, 0.0078124893} degree := 2 x := float64(width * height) @@ -19,12 +19,12 @@ func GuessSD1DiffusionModelMemoryUsage(width, height uint32, flashAttention bool // 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.0561861396, -1193.3271458642, 0.0054023818} + coefficients := []float64{-355043979.05619, -1193.3271458642, 0.0054023818} degree := 2 x := float64(width * height) if flashAttention { - coefficients = []float64{3780681.2807775633, 513.2102510935} + coefficients = []float64{3780681.28078, 513.2102510935} degree = 1 } @@ -38,12 +38,12 @@ func GuessSD2DiffusionModelMemoryUsage(width, height uint32, flashAttention bool // 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.3892993033, 138.3196116655, 0.0006109455} + coefficients := []float64{55541290.38930, 138.3196116655, 0.0006109455} degree := 2 x := float64(width * height) if flashAttention { - coefficients = []float64{-5958802.7805216620, 500.0687898915} + coefficients = []float64{-5958802.78052, 500.0687898915} degree = 1 } @@ -57,12 +57,12 @@ func GuessSDXLDiffusionModelMemoryUsage(width, height uint32, flashAttention boo // 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.3448554799, 155.2477810191, 0.0007351736} + coefficients := []float64{49395992.34486, 155.2477810191, 0.0007351736} degree := 2 x := float64(width * height) if flashAttention { - coefficients = []float64{7031343.3199802125, 599.4137437227} + coefficients = []float64{7031343.31998, 599.4137437227} degree = 1 } @@ -76,7 +76,7 @@ func GuessSDXLRefinerDiffusionModelMemoryUsage(width, height uint32, flashAttent // 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.3700343315, 234.6656247718, 0.0014648995} + coefficients := []float64{16529921.37003, 234.6656247718, 0.0014648995} degree := 2 x := float64(width * height) @@ -90,7 +90,7 @@ func GuessSD3MediumDiffusionModelMemoryUsage(width, height uint32, flashAttentio // 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.4726444557, 281.6956819806, 0.0014651233} + coefficients := []float64{17441103.47264, 281.6956819806, 0.0014651233} degree := 2 x := float64(width * height) @@ -104,7 +104,7 @@ func GuessSD35MediumDiffusionModelMemoryUsage(width, height uint32, flashAttenti // 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.2029170133, 410.3731196298, 0.0023195947} + coefficients := []float64{23204369.20292, 410.3731196298, 0.0023195947} degree := 2 x := float64(width * height) @@ -118,7 +118,7 @@ func GuessSD35LargeDiffusionModelMemoryUsage(width, height uint32, flashAttentio // 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.6742372364, 997.7758807792, 0.0014573393} + coefficients := []float64{46511668.67424, 997.7758807792, 0.0014573393} degree := 2 x := float64(width * height)