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
if *tensorSplit != "" {
stringFloats := regexp.MustCompile(",").Split(*tensorSplit, -1)
tensorSplitFloats = make([]float32, 0, len(stringFloats))
for _, s := range stringFloats {
splits := strings.Split(*tensorSplit, ",")
tensorSplitFloats = make([]float32, len(splits))
for i, s := range splits {
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
if *tensorSplit != "" {
stringFloats := regexp.MustCompile(",").Split(*tensorSplit, -1)
tensorSplitFloats = make([]float32, 0, len(stringFloats))
for _, s := range stringFloats {
splits := strings.Split(*tensorSplit, ",")
tensorSplitFloats = make([]float32, len(splits))
for i, s := range splits {
f, _ := strconv.ParseFloat(s, 32)
tensorSplitFloats = append(tensorSplitFloats, float32(f))
tensorSplitFloats[i] = float32(f)
}
}