| 1 |
package execution // import "gorgonia.org/tensor/internal/execution" |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"reflect" |
| 6 |
"unsafe" |
| 7 |
|
| 8 |
"gorgonia.org/tensor/internal/storage" |
| 9 |
) |
| 10 |
|
| 11 |
// E is the standard engine. It's to be embedded in package tensor |
| 12 |
type E struct{} |
| 13 |
|
| 14 |
// basic types supported. |
| 15 |
var ( |
| 16 |
Bool = reflect.TypeOf(true) |
| 17 |
Int = reflect.TypeOf(int(1)) |
| 18 |
Int8 = reflect.TypeOf(int8(1)) |
| 19 |
Int16 = reflect.TypeOf(int16(1)) |
| 20 |
Int32 = reflect.TypeOf(int32(1)) |
| 21 |
Int64 = reflect.TypeOf(int64(1)) |
| 22 |
Uint = reflect.TypeOf(uint(1)) |
| 23 |
Uint8 = reflect.TypeOf(uint8(1)) |
| 24 |
Uint16 = reflect.TypeOf(uint16(1)) |
| 25 |
Uint32 = reflect.TypeOf(uint32(1)) |
| 26 |
Uint64 = reflect.TypeOf(uint64(1)) |
| 27 |
Float32 = reflect.TypeOf(float32(1)) |
| 28 |
Float64 = reflect.TypeOf(float64(1)) |
| 29 |
Complex64 = reflect.TypeOf(complex64(1)) |
| 30 |
Complex128 = reflect.TypeOf(complex128(1)) |
| 31 |
String = reflect.TypeOf("") |
| 32 |
|
| 33 |
// aliases |
| 34 |
Byte = Uint8 |
| 35 |
|
| 36 |
// extras |
| 37 |
Uintptr = reflect.TypeOf(uintptr(0)) |
| 38 |
UnsafePointer = reflect.TypeOf(unsafe.Pointer(&Uintptr)) |
| 39 |
) |
| 40 |
|
| 41 |
func isScalar(a *storage.Header, t reflect.Type) bool { return a.TypedLen(t) == 1 } |
| 42 |
|
| 43 |
type errorIndices []int |
| 44 |
|
| 45 |
func (e errorIndices) Indices() []int { return []int(e) } |
| 46 |
func (e errorIndices) Error() string { return fmt.Sprintf("Error in indices %v", []int(e)) } |
| 47 |
|
| 48 |
const ( |
| 49 |
lenMismatch = `Cannot compare with differing lengths: %d and %d` |
| 50 |
reductionErrMsg = `Cannot reduce with function of type %T` |
| 51 |
defaultValueErrMsg = `Expected default value of type %T. Got %v of %T instead` |
| 52 |
typeMismatch = `TypeMismatch: a %T and b %T` |
| 53 |
) |