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

Function newTensorFromC

tensorflow/go/tensor.go:141–152  ·  view source on GitHub ↗

newTensorFromC takes ownership of c and returns the owning Tensor.

(c *C.TF_Tensor)

Source from the content-addressed store, hash-verified

139
140// newTensorFromC takes ownership of c and returns the owning Tensor.
141func 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
154func (t *Tensor) finalize() { C.TF_DeleteTensor(t.c) }
155

Callers 4

toGoMethod · 0.85
ToTensorMethod · 0.85
listAttributeFunction · 0.85
scalarAttributeFunction · 0.85

Calls 2

makeFunction · 0.85
int64Function · 0.85

Tested by

no test coverage detected