MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / byteSizeOfEncodedStrings

Function byteSizeOfEncodedStrings

tensorflow/go/tensor.go:287–298  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

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.
287func 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.

Callers 1

NewTensorFunction · 0.85

Calls 2

InterfaceMethod · 0.80
IndexMethod · 0.45

Tested by

no test coverage detected