fixed tensor.ValueGo() return []int

This commit is contained in:
sugarme 2022-02-13 23:50:45 +11:00
parent 961080760f
commit 8d586824c2
2 changed files with 14 additions and 1 deletions

View File

@ -43,7 +43,12 @@ func (ts *Tensor) ValueGo() interface{} {
if err != nil {
log.Fatal(err)
}
// fmt.Println(dst)
// convert []int32 -> int
if reflect.TypeOf(dst).String() == "[]int32" {
dst = sliceInt32ToInt(dst.([]int32))
}
return dst
}
func (ts *Tensor) ToSlice() reflect.Value {

View File

@ -490,3 +490,11 @@ func sliceIntToInt32(input []int) []int32 {
}
return out
}
func sliceInt32ToInt(input []int32) []int {
out := make([]int, len(input))
for i := 0; i < len(input); i++ {
out[i] = int(input[i])
}
return out
}