runner: simplify tensor split parsing

This commit is contained in:
Michael Yang 2025-02-26 15:16:22 -08:00
parent a59f665235
commit d6af13efed
2 changed files with 8 additions and 10 deletions

View File

@ -943,12 +943,11 @@ func Execute(args []string) error {
var tensorSplitFloats []float32 var tensorSplitFloats []float32
if *tensorSplit != "" { if *tensorSplit != "" {
stringFloats := regexp.MustCompile(",").Split(*tensorSplit, -1) splits := strings.Split(*tensorSplit, ",")
tensorSplitFloats = make([]float32, len(splits))
tensorSplitFloats = make([]float32, 0, len(stringFloats)) for i, s := range splits {
for _, s := range stringFloats {
f, _ := strconv.ParseFloat(s, 32) f, _ := strconv.ParseFloat(s, 32)
tensorSplitFloats = append(tensorSplitFloats, float32(f)) tensorSplitFloats[i] = float32(f)
} }
} }

View File

@ -881,12 +881,11 @@ func Execute(args []string) error {
var tensorSplitFloats []float32 var tensorSplitFloats []float32
if *tensorSplit != "" { if *tensorSplit != "" {
stringFloats := regexp.MustCompile(",").Split(*tensorSplit, -1) splits := strings.Split(*tensorSplit, ",")
tensorSplitFloats = make([]float32, len(splits))
tensorSplitFloats = make([]float32, 0, len(stringFloats)) for i, s := range splits {
for _, s := range stringFloats {
f, _ := strconv.ParseFloat(s, 32) f, _ := strconv.ParseFloat(s, 32)
tensorSplitFloats = append(tensorSplitFloats, float32(f)) tensorSplitFloats[i] = float32(f)
} }
} }