typeOf converts from a DataType and Shape to the equivalent Go type.
(dt DataType, shape []int64)
| 258 | |
| 259 | // typeOf converts from a DataType and Shape to the equivalent Go type. |
| 260 | func 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 | |
| 277 | func numElements(shape []int64) int64 { |
| 278 | n := int64(1) |