newTensorFromC takes ownership of c and returns the owning Tensor.
(c *C.TF_Tensor)
| 139 | |
| 140 | // newTensorFromC takes ownership of c and returns the owning Tensor. |
| 141 | func newTensorFromC(c *C.TF_Tensor) *Tensor { |
| 142 | var shape []int64 |
| 143 | if ndims := int(C.TF_NumDims(c)); ndims > 0 { |
| 144 | shape = make([]int64, ndims) |
| 145 | } |
| 146 | for i := range shape { |
| 147 | shape[i] = int64(C.TF_Dim(c, C.int(i))) |
| 148 | } |
| 149 | t := &Tensor{c: c, shape: shape} |
| 150 | runtime.SetFinalizer(t, (*Tensor).finalize) |
| 151 | return t |
| 152 | } |
| 153 | |
| 154 | func (t *Tensor) finalize() { C.TF_DeleteTensor(t.c) } |
| 155 |
no test coverage detected