convert: fix tensor sorting (#12015)

there's two bugs here.

1. the check for a layer id is incorrect and should be >= 0 since layer
   0 is valid
2. if both tensors have an layer identifier, it will only compare the
   layer id which will return 0 if the tensors are in the same layer.
   instead it should fallback to comparing the full tensor name
This commit is contained in:
Michael Yang
2025-08-26 13:57:46 -07:00
committed by GitHub
parent 85ccf7354d
commit 86834a2797
3 changed files with 29 additions and 25 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"io"
"log/slog"
"math"
"slices"
"strings"
@@ -276,7 +277,7 @@ type Tensor struct {
func (t Tensor) block() (n int) {
if _, err := fmt.Sscanf(t.Name, "blk.%d.", &n); err != nil {
return -1
return math.MaxInt
}
return