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

Function typeOf

tensorflow/go/tensor.go:260–275  ·  view source on GitHub ↗

typeOf converts from a DataType and Shape to the equivalent Go type.

(dt DataType, shape []int64)

Source from the content-addressed store, hash-verified

258
259// typeOf converts from a DataType and Shape to the equivalent Go type.
260func typeOf(dt DataType, shape []int64) reflect.Type {
261 var ret reflect.Type
262 for _, t := range types {
263 if dt == DataType(t.dataType) {
264 ret = t.typ
265 break
266 }
267 }
268 if ret == nil {
269 panic(bug("DataType %v is not supported (see https://www.tensorflow.org/code/tensorflow/core/framework/types.proto)", dt))
270 }
271 for range shape {
272 ret = reflect.SliceOf(ret)
273 }
274 return ret
275}
276
277func numElements(shape []int64) int64 {
278 n := int64(1)

Callers 4

NewTensorFunction · 0.85
ReadTensorFunction · 0.85
ValueMethod · 0.85
decodeMethod · 0.85

Calls 2

bugFunction · 0.85
DataTypeTypeAlias · 0.70

Tested by

no test coverage detected