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)
| 194 | // if t.DataType() is non-numeric (e.g., String). See |
| 195 | // https://github.com/tensorflow/tensorflow/issues/6003. |
| 196 | func (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 | |
| 203 | func tensorData(c *C.TF_Tensor) []byte { |
| 204 | // See: https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices |