Documentation ¶
Index ¶
- func AllClose(tensor, other Tensor, rtol, atol float64) bool
- func Equal(tensor, other Tensor) bool
- func IsComplex(tensor Tensor) bool
- func IsConj(tensor Tensor) bool
- func IsFloatingPoint(tensor Tensor) bool
- func IsGradEnabled() bool
- func IsNonzero(tensor Tensor) bool
- func ManualSeed(seed int64)
- func Numel(tensor Tensor) int64
- func SetGradEnabled(value bool)
- func SetNumThreads(numThreads int32)
- func StdMean(tensor Tensor) (Tensor, Tensor)
- func StdMeanByDim(tensor Tensor, dim int, unbiased bool, keep_dims bool) (Tensor, Tensor)
- func ToSlice(tensor Tensor) interface{}
- func VarMean(tensor Tensor) (Tensor, Tensor)
- func VarMeanByDim(tensor Tensor, dim int, unbiased bool, keep_dims bool) (Tensor, Tensor)
- type Device
- type Dtype
- type IValue
- func (ivalue IValue) IsBool() bool
- func (ivalue IValue) IsBoolList() bool
- func (ivalue IValue) IsCapsule() bool
- func (ivalue IValue) IsComplexDouble() bool
- func (ivalue IValue) IsComplexDoubleList() bool
- func (ivalue IValue) IsCustomClass() bool
- func (ivalue IValue) IsDevice() bool
- func (ivalue IValue) IsDouble() bool
- func (ivalue IValue) IsDoubleList() bool
- func (ivalue IValue) IsEnum() bool
- func (ivalue IValue) IsFuture() bool
- func (ivalue IValue) IsGenerator() bool
- func (ivalue IValue) IsGenericDict() bool
- func (ivalue IValue) IsInt() bool
- func (ivalue IValue) IsIntList() bool
- func (ivalue IValue) IsList() bool
- func (ivalue IValue) IsModule() bool
- func (ivalue IValue) IsNil() bool
- func (ivalue IValue) IsObject() bool
- func (ivalue IValue) IsPtrType() bool
- func (ivalue IValue) IsPyObject() bool
- func (ivalue IValue) IsQuantizer() bool
- func (ivalue IValue) IsRRef() bool
- func (ivalue IValue) IsScalar() bool
- func (ivalue IValue) IsStorage() bool
- func (ivalue IValue) IsStream() bool
- func (ivalue IValue) IsString() bool
- func (ivalue IValue) IsTensor() bool
- func (ivalue IValue) IsTensorList() bool
- func (ivalue IValue) IsTuple() bool
- func (ivalue IValue) LengthDict() int64
- func (ivalue IValue) LengthList() int64
- func (ivalue IValue) LengthTuple() int64
- func (ivalue IValue) ToBool() bool
- func (ivalue IValue) ToComplexDouble() complex128
- func (ivalue IValue) ToDevice() Device
- func (ivalue IValue) ToDouble() float64
- func (ivalue IValue) ToGenericDict() map[interface{}]IValue
- func (ivalue IValue) ToInt() int
- func (ivalue IValue) ToList() []IValue
- func (ivalue IValue) ToNone() string
- func (ivalue IValue) ToString() string
- func (ivalue IValue) ToTensor() Tensor
- func (ivalue IValue) ToTensorList() []Tensor
- func (ivalue IValue) ToTuple() []IValue
- type Tensor
- func Abs(tensor Tensor) Tensor
- func Abs_(tensor Tensor) Tensor
- func Add(tensor, other Tensor, alpha float32) Tensor
- func All(tensor Tensor) Tensor
- func AllByDim(tensor Tensor, dim int, keep_dims bool) Tensor
- func Any(tensor Tensor) Tensor
- func AnyByDim(tensor Tensor, dim int, keep_dims bool) Tensor
- func Arange(begin, end, step float32, options TensorOptions) Tensor
- func Argmax(tensor Tensor) Tensor
- func ArgmaxByDim(tensor Tensor, dim int, keep_dims bool) Tensor
- func Argmin(tensor Tensor) Tensor
- func ArgminByDim(tensor Tensor, dim int, keep_dims bool) Tensor
- func Cat(tensors []Tensor, dim int64) Tensor
- func Decode(buffer []byte) (Tensor, error)
- func Div(tensor, other Tensor) Tensor
- func Empty(size []int64, options TensorOptions) Tensor
- func EmptyLike(reference Tensor) Tensor
- func Eq(tensor, other Tensor) Tensor
- func Eye(n, m int64, options TensorOptions) Tensor
- func Flatten(tensor Tensor, startDim, endDim int64) Tensor
- func Full(size []int64, value float32, options TensorOptions) Tensor
- func FullLike(reference Tensor, value float32) Tensor
- func Greater(tensor, other Tensor) Tensor
- func GreaterEqual(tensor, other Tensor) Tensor
- func IndexSelect(tensor Tensor, dim int64, index Tensor) Tensor
- func IsClose(tensor, other Tensor, rtol, atol float64) Tensor
- func IsFinite(tensor Tensor) Tensor
- func IsIn(tensor, other Tensor) Tensor
- func IsInf(tensor Tensor) Tensor
- func IsNaN(tensor Tensor) Tensor
- func IsNegInf(tensor Tensor) Tensor
- func IsPosInf(tensor Tensor) Tensor
- func IsReal(tensor Tensor) Tensor
- func Less(tensor, other Tensor) Tensor
- func LessEqual(tensor, other Tensor) Tensor
- func Linspace(begin, end float32, steps int64, options TensorOptions) Tensor
- func Load(path string) (Tensor, error)
- func LogSoftmax(t Tensor, dim int64) Tensor
- func Logspace(begin, end float32, steps int64, base float64, options TensorOptions) Tensor
- func MM(a, b Tensor) Tensor
- func Max(tensor Tensor) Tensor
- func Maximum(tensor, other Tensor) Tensor
- func Mean(tensor Tensor) Tensor
- func MeanByDim(tensor Tensor, dim int, keep_dims bool) Tensor
- func Median(tensor Tensor) Tensor
- func Min(tensor Tensor) Tensor
- func Minimum(tensor, other Tensor) Tensor
- func Mul(tensor, other Tensor) Tensor
- func NewTensor(data interface{}) Tensor
- func NewTensorFromBlob(data unsafe.Pointer, dtype Dtype, sizes []int64) Tensor
- func NewTorchTensor(tensor *unsafe.Pointer) Tensor
- func NotEqual(tensor, other Tensor) Tensor
- func Ones(size []int64, options TensorOptions) Tensor
- func OnesLike(reference Tensor) Tensor
- func Permute(tensor Tensor, dims ...int64) Tensor
- func Pow(tensor Tensor, exponent float64) Tensor
- func Rand(size []int64, options TensorOptions) Tensor
- func RandInt(size []int64, low int64, high int64, options TensorOptions) Tensor
- func RandIntLike(reference Tensor, low int64, high int64) Tensor
- func RandLike(reference Tensor) Tensor
- func RandN(size []int64, options TensorOptions) Tensor
- func RandNLike(reference Tensor) Tensor
- func Range(begin, end, step float32, options TensorOptions) Tensor
- func Reshape(tensor Tensor, shape ...int64) Tensor
- func Sigmoid(t Tensor) Tensor
- func Slice(tensor Tensor, dim, start, stop, step int64) Tensor
- func Sqrt(tensor Tensor) Tensor
- func Sqrt_(tensor Tensor) Tensor
- func Square(tensor Tensor) Tensor
- func Square_(tensor Tensor) Tensor
- func Squeeze(tensor Tensor, dim ...int64) Tensor
- func Stack(tensors []Tensor, dim int64) Tensor
- func Std(tensor Tensor) Tensor
- func StdByDim(tensor Tensor, dim int, unbiased bool, keep_dims bool) Tensor
- func Sub(tensor, other Tensor, alpha float32) Tensor
- func Sum(tensor Tensor) Tensor
- func SumByDim(tensor Tensor, dim int, keep_dims bool) Tensor
- func Tanh(t Tensor) Tensor
- func TensorFromBlob(data unsafe.Pointer, dtype Dtype, sizes []int64) Tensor
- func Transpose(tensor Tensor, dim0, dim1 int64) Tensor
- func Unsqueeze(tensor Tensor, dim int64) Tensor
- func Var(tensor Tensor) Tensor
- func VarByDim(tensor Tensor, dim int, unbiased bool, keep_dims bool) Tensor
- func Zeros(size []int64, options TensorOptions) Tensor
- func ZerosLike(reference Tensor) Tensor
- func (tensor Tensor) Abs() Tensor
- func (tensor Tensor) Abs_() Tensor
- func (tensor Tensor) Add(other Tensor, alpha float32) Tensor
- func (tensor Tensor) Add_(other Tensor, alpha float32) Tensor
- func (tensor Tensor) All() Tensor
- func (tensor Tensor) AllByDim(dim int, keep_dims bool) Tensor
- func (tensor Tensor) AllClose(other Tensor, rtol, atol float64) bool
- func (tensor Tensor) Any() Tensor
- func (tensor Tensor) AnyByDim(dim int, keep_dims bool) Tensor
- func (tensor Tensor) Argmax() Tensor
- func (tensor Tensor) ArgmaxByDim(dim int, keep_dims bool) Tensor
- func (tensor Tensor) Argmin() Tensor
- func (tensor Tensor) ArgminByDim(dim int, keep_dims bool) Tensor
- func (tensor Tensor) Backward()
- func (tensor Tensor) CastTo(dtype Dtype) Tensor
- func (tensor Tensor) Clone() Tensor
- func (tensor Tensor) CopyTo(device Device) Tensor
- func (tensor Tensor) Copy_(b Tensor)
- func (tensor Tensor) Detach() Tensor
- func (tensor Tensor) Dim() int64
- func (tensor Tensor) Div(other Tensor) Tensor
- func (tensor Tensor) Div_(other Tensor) Tensor
- func (tensor Tensor) Dtype() Dtype
- func (tensor Tensor) Encode() ([]byte, error)
- func (tensor Tensor) Eq(other Tensor) Tensor
- func (tensor Tensor) Equal(other Tensor) bool
- func (tensor Tensor) Expand(shape ...int64) Tensor
- func (tensor Tensor) ExpandAs(other Tensor) Tensor
- func (tensor Tensor) Flatten(startDim, endDim int64) Tensor
- func (tensor Tensor) Grad() Tensor
- func (tensor Tensor) Greater(other Tensor) Tensor
- func (tensor Tensor) GreaterEqual(other Tensor) Tensor
- func (tensor Tensor) Index(index Tensor) Tensor
- func (tensor Tensor) IndexSelect(dim int64, index Tensor) Tensor
- func (tensor Tensor) IsClose(other Tensor, rtol, atol float64) Tensor
- func (tensor Tensor) IsComplex() bool
- func (tensor Tensor) IsConj() bool
- func (tensor Tensor) IsFinite() Tensor
- func (tensor Tensor) IsFloatingPoint() bool
- func (tensor Tensor) IsIn(other Tensor) Tensor
- func (tensor Tensor) IsInf() Tensor
- func (tensor Tensor) IsNaN() Tensor
- func (tensor Tensor) IsNegInf() Tensor
- func (tensor Tensor) IsNonzero() bool
- func (tensor Tensor) IsPosInf() Tensor
- func (tensor Tensor) IsReal() Tensor
- func (tensor Tensor) Item() interface{}
- func (tensor Tensor) Less(other Tensor) Tensor
- func (tensor Tensor) LessEqual(other Tensor) Tensor
- func (a Tensor) LogSoftmax(dim int64) Tensor
- func (tensor Tensor) MM(other Tensor) Tensor
- func (tensor Tensor) Max() Tensor
- func (tensor Tensor) MaxByDim(dim int, keep_dims bool) ValueIndexPair
- func (tensor Tensor) Maximum(other Tensor) Tensor
- func (tensor Tensor) Mean() Tensor
- func (tensor Tensor) MeanByDim(dim int, keep_dims bool) Tensor
- func (tensor Tensor) Median() Tensor
- func (tensor Tensor) MedianByDim(dim int, keep_dims bool) ValueIndexPair
- func (tensor Tensor) Min() Tensor
- func (tensor Tensor) MinByDim(dim int, keep_dims bool) ValueIndexPair
- func (tensor Tensor) Minimum(other Tensor) Tensor
- func (tensor Tensor) Mul(other Tensor) Tensor
- func (tensor Tensor) Mul_(other Tensor) Tensor
- func (tensor Tensor) NotEqual(other Tensor) Tensor
- func (tensor Tensor) Numel() int64
- func (tensor Tensor) Permute(dims ...int64) Tensor
- func (tensor Tensor) Pow(exponent float64) Tensor
- func (tensor Tensor) RequiresGrad() bool
- func (tensor Tensor) Reshape(shape ...int64) Tensor
- func (tensor Tensor) ReshapeAs(other Tensor) Tensor
- func (tensor Tensor) Save(path string) error
- func (tensor Tensor) SetData(b Tensor)
- func (tensor Tensor) SetRequiresGrad(requiresGrad bool)
- func (tensor Tensor) Shape() []int64
- func (a Tensor) Sigmoid() Tensor
- func (tensor Tensor) Slice(dim, start, stop, step int64) Tensor
- func (tensor Tensor) Sort(dim int64, descending bool) ValueIndexPair
- func (tensor Tensor) Sqrt() Tensor
- func (tensor Tensor) Sqrt_() Tensor
- func (tensor Tensor) Square() Tensor
- func (tensor Tensor) Square_() Tensor
- func (tensor Tensor) Squeeze(dim ...int64) Tensor
- func (tensor Tensor) Std() Tensor
- func (tensor Tensor) StdByDim(dim int, unbiased bool, keep_dims bool) Tensor
- func (tensor Tensor) StdMean() (Tensor, Tensor)
- func (tensor Tensor) StdMeanByDim(dim int, unbiased bool, keep_dims bool) (Tensor, Tensor)
- func (tensor Tensor) String() string
- func (tensor Tensor) Sub(other Tensor, alpha float32) Tensor
- func (tensor Tensor) Sub_(other Tensor, alpha float32) Tensor
- func (tensor Tensor) Sum() Tensor
- func (tensor Tensor) SumByDim(dim int, keep_dims bool) Tensor
- func (a Tensor) Tanh() Tensor
- func (tensor Tensor) To(device Device, dtype Dtype) Tensor
- func (tensor Tensor) ToSlice() interface{}
- func (tensor Tensor) TopK(k, dim int64, largest, sorted bool) ValueIndexPair
- func (tensor Tensor) Transpose(dim0, dim1 int64) Tensor
- func (tensor Tensor) Unsqueeze(dim int64) Tensor
- func (tensor Tensor) Var() Tensor
- func (tensor Tensor) VarByDim(dim int, unbiased bool, keep_dims bool) Tensor
- func (tensor Tensor) VarMean() (Tensor, Tensor)
- func (tensor Tensor) VarMeanByDim(dim int, unbiased bool, keep_dims bool) (Tensor, Tensor)
- func (tensor Tensor) View(shape ...int64) Tensor
- func (tensor Tensor) ViewAs(other Tensor) Tensor
- type TensorOptions
- type ValueIndexPair
- func MaxByDim(tensor Tensor, dim int, keep_dims bool) ValueIndexPair
- func MedianByDim(tensor Tensor, dim int, keep_dims bool) ValueIndexPair
- func MinByDim(tensor Tensor, dim int, keep_dims bool) ValueIndexPair
- func Sort(tensor Tensor, dim int64, descending bool) ValueIndexPair
- func TopK(tensor Tensor, k, dim int64, largest, sorted bool) ValueIndexPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFloatingPoint ¶
func SetNumThreads ¶
func SetNumThreads(numThreads int32)
/ Set the number of threads used for intraop parallelism on CPU.
func StdMeanByDim ¶
Reduce a tensor to its mean value and standard deviation along given dimension.
func ToSlice ¶
func ToSlice(tensor Tensor) interface{}
Convert a torch Tensor to a Go slice. This function implies a flattening of the tensor to return 1-dimensional vectors.
Types ¶
type Dtype ¶
type Dtype int8
An enumeration of the data-types in libtorch.
const ( Byte Dtype = iota // Byte Dtype 0 Char // Char Dtype 1 Short // Short Dtype 2 Int // Int Dtype 3 Long // Long Dtype 4 Half // Half Dtype 5 Float // Float Dtype 6 Double // Double Dtype 7 ComplexHalf // ComplexHalf Dtype 8 ComplexFloat // ComplexFloat Dtype 9 ComplexDouble // ComplexDouble Dtype 10 Bool // Bool Dtype 11 QInt8 // QInt8 Dtype 12 QUInt8 // QUInt8 Dtype 13 QInt32 // QInt32 Dtype 14 BFloat16 // BFloat16 Dtype 15 Invalid Dtype = -1 // Invalid Dtype )
func GetDtypeOfKind ¶
Map an element type kind to its associated Dtype.
type IValue ¶
IValue wraps a pointer to a C.IValue as an unsafe Pointer.
func (IValue) IsBoolList ¶
func (IValue) IsComplexDouble ¶
func (IValue) IsComplexDoubleList ¶
func (IValue) IsCustomClass ¶
func (IValue) IsDoubleList ¶
func (IValue) IsGenerator ¶
func (IValue) IsGenericDict ¶
func (IValue) IsPyObject ¶
func (IValue) IsQuantizer ¶
func (IValue) IsTensorList ¶
func (IValue) LengthDict ¶
func (IValue) LengthList ¶
func (IValue) LengthTuple ¶
func (IValue) ToComplexDouble ¶
func (ivalue IValue) ToComplexDouble() complex128
func (IValue) ToGenericDict ¶
func (IValue) ToTensorList ¶
type Tensor ¶
Tensor wraps a pointer to a C.Tensor as an unsafe Pointer.
func Arange ¶
func Arange(begin, end, step float32, options TensorOptions) Tensor
func ArgmaxByDim ¶
Reduce a tensor to its maximum index along the given dimension.
func ArgminByDim ¶
Reduce a tensor to its minimum index along the given dimension.
func Empty ¶
func Empty(size []int64, options TensorOptions) Tensor
func Eye ¶
func Eye(n, m int64, options TensorOptions) Tensor
func GreaterEqual ¶
func LogSoftmax ¶
func Logspace ¶
func Logspace(begin, end float32, steps int64, base float64, options TensorOptions) Tensor
func NewTensorFromBlob ¶
Create a new tensor that clones existing contiguous memory pointed to by data, of given data-type, and with given size. This function copies the input data to subsequent in-place operations performed on the tensor will not mutate the input data.
func NewTorchTensor ¶
Create a new tensor and configure garbage collection.
func Ones ¶
func Ones(size []int64, options TensorOptions) Tensor
func Rand ¶
func Rand(size []int64, options TensorOptions) Tensor
func RandN ¶
func RandN(size []int64, options TensorOptions) Tensor
func Range ¶
func Range(begin, end, step float32, options TensorOptions) Tensor
func TensorFromBlob ¶
Create a tensor view that wraps around existing contiguous memory pointed to by data, of given data-type, and with given size. This function does not copy the data buffer so in-place operations performed on the tensor will mutate the input data.
func Zeros ¶
func Zeros(size []int64, options TensorOptions) Tensor
func (Tensor) AllByDim ¶
Check if all values in the tensor evaluate to true along the given dimension.
func (Tensor) AnyByDim ¶
Check if any values in the tensor evaluate to true along the given dimension.
func (Tensor) ArgmaxByDim ¶
Reduce a tensor to its maximum index along the given dimension.
func (Tensor) ArgminByDim ¶
Reduce a tensor to its minimum index along the given dimension.
func (Tensor) Encode ¶
Encode a tensor into a pickled representation. Tensors are copied to the CPU before encoding.
func (Tensor) GreaterEqual ¶
func (Tensor) IsFloatingPoint ¶
func (Tensor) Item ¶
func (tensor Tensor) Item() interface{}
Return the value of this tensor as a standard Go number. This only works for tensors with one element. @details users should do type assertion and get the value like:
```
if value, ok := a.Item().(float64); ok { // process the value }
```
This function currently only supports signed data types.
func (Tensor) LogSoftmax ¶
func (Tensor) MaxByDim ¶
func (tensor Tensor) MaxByDim(dim int, keep_dims bool) ValueIndexPair
Reduce a tensor to its maximum value along the given dimension.
func (Tensor) MedianByDim ¶
func (tensor Tensor) MedianByDim(dim int, keep_dims bool) ValueIndexPair
Reduce a tensor to its median value along the given dimension.
func (Tensor) MinByDim ¶
func (tensor Tensor) MinByDim(dim int, keep_dims bool) ValueIndexPair
Reduce a tensor to its minimum value along the given dimension.
func (Tensor) RequiresGrad ¶
func (Tensor) SetRequiresGrad ¶
func (Tensor) StdMeanByDim ¶
Reduce a tensor to its mean value and standard deviation along given dimension.
func (Tensor) VarMeanByDim ¶
Reduce a tensor to its mean value and variance along given dimension.
type TensorOptions ¶
TensorOptions wraps a pointer to a C.TensorOptions as an unsafe Pointer.
func (TensorOptions) Device ¶
func (options TensorOptions) Device(device Device) TensorOptions
Create a new TensorOptions with the given compute device.
func (TensorOptions) Dtype ¶
func (options TensorOptions) Dtype(value Dtype) TensorOptions
Create a new TensorOptions with the given data type.
func (TensorOptions) PinnedMemory ¶
func (options TensorOptions) PinnedMemory(pinnedMemory bool) TensorOptions
Create a new TensorOptions with the given memory pinning state.
func (TensorOptions) RequiresGrad ¶
func (options TensorOptions) RequiresGrad(requiresGrad bool) TensorOptions
Create a new TensorOptions with the given gradient taping state.
type ValueIndexPair ¶
type ValueIndexPair struct {
Values, Indices Tensor
}
A representation of the return type for a paired value/index selection call.
func MaxByDim ¶
func MaxByDim(tensor Tensor, dim int, keep_dims bool) ValueIndexPair
Reduce a tensor to its maximum value along the given dimension.
func MedianByDim ¶
func MedianByDim(tensor Tensor, dim int, keep_dims bool) ValueIndexPair
Reduce a tensor to its median value along the given dimension.