NewTensorHandle creates a new tensor handle from a tensor.
(t *Tensor)
| 44 | |
| 45 | // NewTensorHandle creates a new tensor handle from a tensor. |
| 46 | func NewTensorHandle(t *Tensor) (*TensorHandle, error) { |
| 47 | status := newStatus() |
| 48 | cHandle := C.TFE_NewTensorHandle(t.c, status.c) |
| 49 | if err := status.Err(); err != nil { |
| 50 | return nil, err |
| 51 | } |
| 52 | |
| 53 | th := &TensorHandle{c: cHandle} |
| 54 | runtime.SetFinalizer(th, (*TensorHandle).finalizer) |
| 55 | return th, nil |
| 56 | } |
| 57 | |
| 58 | func (th *TensorHandle) finalizer() { |
| 59 | C.TFE_DeleteTensorHandle(th.c) |