Commit d6af13ef authored by Michael Yang's avatar Michael Yang
Browse files

runner: simplify tensor split parsing

parent a59f6652
...@@ -943,12 +943,11 @@ func Execute(args []string) error { ...@@ -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)
} }
} }
......
...@@ -881,12 +881,11 @@ func Execute(args []string) error { ...@@ -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)
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment