byteSizeOfEncodedStrings returns the size of the encoded strings in val. val MUST be a string, or a container (array/slice etc.) of strings.
(val interface{})
| 285 | // byteSizeOfEncodedStrings returns the size of the encoded strings in val. |
| 286 | // val MUST be a string, or a container (array/slice etc.) of strings. |
| 287 | func byteSizeOfEncodedStrings(val interface{}) uintptr { |
| 288 | if s, ok := val.(string); ok { |
| 289 | return uintptr(C.TF_StringEncodedSize(C.size_t(len(s)))) |
| 290 | } |
| 291 | // Otherwise must be an array or slice. |
| 292 | var size uintptr |
| 293 | v := reflect.ValueOf(val) |
| 294 | for i := 0; i < v.Len(); i++ { |
| 295 | size += byteSizeOfEncodedStrings(v.Index(i).Interface()) |
| 296 | } |
| 297 | return size |
| 298 | } |
| 299 | |
| 300 | // encodeTensor writes v to the specified buffer using the format specified in |
| 301 | // c_api.h. Use stringEncoder for String tensors. |