gorgonia.org/tensor@v0.9.24/interfaces.go (about) 1 package tensor 2 3 import ( 4 "reflect" 5 6 "gorgonia.org/tensor/internal/storage" 7 ) 8 9 // Dtyper is any type that has a Dtype 10 type Dtyper interface { 11 Dtype() Dtype 12 } 13 14 // Eq is any type where you can perform an equality test 15 type Eq interface { 16 Eq(interface{}) bool 17 } 18 19 // Cloner is any type that can clone itself 20 type Cloner interface { 21 Clone() interface{} 22 } 23 24 // Dataer is any type that returns the data in its original form (typically a Go slice of something) 25 type Dataer interface { 26 Data() interface{} 27 } 28 29 // Boolable is any type has a zero and one value, and is able to set itself to either 30 type Boolable interface { 31 Zeroer 32 Oner 33 } 34 35 // A Zeroer is any type that can set itself to the zeroth value. It's used to implement the arrays 36 type Zeroer interface { 37 Zero() 38 } 39 40 // A Oner is any type that can set itself to the equivalent of one. It's used to implement the arrays 41 type Oner interface { 42 One() 43 } 44 45 // A MemSetter is any type that can set itself to a value. 46 type MemSetter interface { 47 Memset(interface{}) error 48 } 49 50 // A Densor is any type that can return a *Dense 51 type Densor interface { 52 Dense() *Dense 53 } 54 55 // ScalarRep is any Tensor that can represent a scalar 56 type ScalarRep interface { 57 IsScalar() bool 58 ScalarValue() interface{} 59 } 60 61 // View is any Tensor that can provide a view on memory 62 type View interface { 63 Tensor 64 IsView() bool 65 IsMaterializable() bool 66 Materialize() Tensor 67 } 68 69 // Slicer is any tensor that can slice 70 type Slicer interface { 71 Slice(...Slice) (View, error) 72 } 73 74 // DenseTensor is the interface for any Dense tensor. 75 type DenseTensor interface { 76 Tensor 77 Info() *AP 78 79 IsMatrix() bool 80 IsVector() bool 81 IsRowVec() bool 82 IsColVec() bool 83 84 // headerer 85 // arrayer 86 unsafeMem 87 setAP(*AP) 88 rtype() reflect.Type 89 reshape(dims ...int) error 90 91 setDataOrder(o DataOrder) 92 isTransposed() bool 93 ostrides() []int 94 oshape() Shape 95 transposeAxes() []int 96 transposeIndex(i int, transposePat, strides []int) int 97 oldAP() *AP 98 setOldAP(ap *AP) 99 parentTensor() *Dense 100 setParentTensor(*Dense) 101 len() int 102 cap() int 103 104 // operations 105 Inner(other Tensor) (retVal interface{}, err error) 106 MatMul(other Tensor, opts ...FuncOpt) (retVal *Dense, err error) 107 MatVecMul(other Tensor, opts ...FuncOpt) (retVal *Dense, err error) 108 TensorMul(other Tensor, axesA, axesB []int) (retVal *Dense, err error) 109 stackDense(axis int, others ...DenseTensor) (DenseTensor, error) 110 } 111 112 type SparseTensor interface { 113 Sparse 114 AsCSC() 115 AsCSR() 116 Indices() []int 117 Indptr() []int 118 119 // headerer 120 } 121 122 type MaskedTensor interface { 123 DenseTensor 124 IsMasked() bool 125 SetMask([]bool) 126 Mask() []bool 127 } 128 129 // Kinder. Bueno. 130 type Kinder interface { 131 Kind() reflect.Kind 132 } 133 134 type headerer interface { 135 hdr() *storage.Header 136 } 137 138 type arrayer interface { 139 arr() array 140 arrPtr() *array 141 } 142 143 type unsafeMem interface { 144 Set(i int, x interface{}) 145 GetF64(i int) float64 146 GetF32(i int) float32 147 Ints() []int 148 Float64s() []float64 149 Float32s() []float32 150 Complex64s() []complex64 151 Complex128s() []complex128 152 }