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

Method WriteContentsTo

tensorflow/go/tensor.go:196–201  ·  view source on GitHub ↗

WriteContentsTo writes the serialized contents of t to w. Returns the number of bytes written. See ReadTensor for reconstructing a Tensor from the serialized form. WARNING: WriteContentsTo is not comprehensive and will fail if t.DataType() is non-numeric (e.g., String). See https://github.com/tens

(w io.Writer)

Source from the content-addressed store, hash-verified

194// if t.DataType() is non-numeric (e.g., String). See
195// https://github.com/tensorflow/tensorflow/issues/6003.
196func (t *Tensor) WriteContentsTo(w io.Writer) (int64, error) {
197 if err := isTensorSerializable(t.DataType()); err != nil {
198 return 0, err
199 }
200 return io.Copy(w, bytes.NewReader(tensorData(t.c)))
201}
202
203func tensorData(c *C.TF_Tensor) []byte {
204 // See: https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices

Calls 4

DataTypeMethod · 0.95
isTensorSerializableFunction · 0.85
tensorDataFunction · 0.85
CopyMethod · 0.45

Tested by 4

TestTensorSerializationFunction · 0.76
TestReadTensorReadAllFunction · 0.76