gorgonia.org/gorgonia@v0.9.17/interfaces.go (about) 1 package gorgonia 2 3 import ( 4 "hash" 5 "unsafe" 6 7 "gorgonia.org/tensor" 8 ) 9 10 // Tensor is an interface that describes an ndarray 11 type Tensor interface { 12 // info about the ndarrayN 13 Shape() tensor.Shape 14 Strides() []int 15 Dtype() tensor.Dtype 16 Dims() int 17 Size() int 18 DataSize() int 19 20 // type overloading methods 21 IsScalar() bool 22 ScalarValue() interface{} 23 24 // engine/memory related stuff 25 // all Tensors should be able to be expressed of as a slab of memory 26 // Note: the size of each element can be acquired by T.Dtype().Size() 27 Engine() tensor.Engine // Engine can be nil 28 MemSize() uintptr // the size in memory 29 Uintptr() uintptr // the pointer to the first element, as a uintptr 30 Pointer() unsafe.Pointer // the pointer to the first elemment as a unsafe.Ponter 31 IsNativelyAccessible() bool // Can Go access the memory 32 IsManuallyManaged() bool // Must Go manage the memory 33 } 34 35 type hashWriter interface { 36 WriteHash(hash.Hash) 37 } 38 39 type arityer interface { 40 Arity() int 41 }