Documentation
¶
Overview ¶
Package notimplemented implements a backends.Builder interface that throws a "Not implemented" exception to all operations.
This can help bootstrap any backend implementation.
Index ¶
- Variables
- type Backend
- func (b *Backend) BufferCopyToDevice(source backends.Buffer, deviceNum backends.DeviceNum) (bufferOnDevice backends.Buffer, err error)
- func (b *Backend) BufferData(buffer backends.Buffer) (flat any, err error)
- func (b *Backend) BufferDeviceNum(buffer backends.Buffer) (backends.DeviceNum, error)
- func (b *Backend) BufferFinalize(buffer backends.Buffer) error
- func (b *Backend) BufferFromFlatData(deviceNum backends.DeviceNum, flat any, shape shapes.Shape) (backends.Buffer, error)
- func (b *Backend) BufferShape(buffer backends.Buffer) (shapes.Shape, error)
- func (b *Backend) BufferToFlatData(buffer backends.Buffer, flat any) error
- func (b *Backend) Builder(name string) backends.Builder
- func (b *Backend) Capabilities() backends.Capabilities
- func (b *Backend) Description() string
- func (b *Backend) DeviceDescription(deviceNum backends.DeviceNum) string
- func (b *Backend) Finalize()
- func (b *Backend) HasSharedBuffers() bool
- func (b *Backend) IsFinalized() bool
- func (b *Backend) Name() string
- func (b *Backend) NewSharedBuffer(deviceNum backends.DeviceNum, shape shapes.Shape) (buffer backends.Buffer, flat any, err error)
- func (b *Backend) NumDevices() int
- func (b *Backend) String() string
- type Builder
- func (b Builder) Compile() (backends.Executable, error)
- func (b Builder) DeviceAssignment(devices ...backends.DeviceNum) error
- func (b Builder) DistributedAutoSharding(meshes ...backends.Mesh) error
- func (b Builder) DistributedSPMD(numDevices int) error
- func (b Builder) Main() backends.Function
- func (b Builder) Name() string
- func (b Builder) NewFunction(name string) (backends.Function, error)
- func (b Builder) OpShape(op backends.Value) (shapes.Shape, error)
- type Function
- func (f Function) Abs(x backends.Value) (backends.Value, error)
- func (f Function) Add(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) AllReduce(inputs []backends.Value, reduceOp backends.ReduceOpType, replicaGroups [][]int) ([]backends.Value, error)
- func (f Function) ArgMinMax(x backends.Value, axis int, outputDType dtypes.DType, isMin bool) (backends.Value, error)
- func (f Function) Atan2(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) BatchNormForInference(operand, scale, offset, mean, variance backends.Value, epsilon float32, ...) (backends.Value, error)
- func (f Function) BatchNormForTraining(operand, scale, offset backends.Value, epsilon float32, axis int) (normalized, batchMean, batchVariance backends.Value, err error)
- func (f Function) BatchNormGradient(operand, scale, mean, variance, gradOutput backends.Value, epsilon float32, ...) (gradOperand, gradScale, gradOffset backends.Value, err error)
- func (f Function) BitCount(operand backends.Value) (backends.Value, error)
- func (f Function) Bitcast(x backends.Value, targetDType dtypes.DType) (backends.Value, error)
- func (f Function) BitwiseAnd(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) BitwiseNot(x backends.Value) (backends.Value, error)
- func (f Function) BitwiseOr(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) BitwiseXor(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) BroadcastInDim(x backends.Value, outputShape shapes.Shape, broadcastAxes []int) (backends.Value, error)
- func (f Function) Call(target backends.Function, inputs ...backends.Value) ([]backends.Value, error)
- func (f Function) Ceil(x backends.Value) (backends.Value, error)
- func (f Function) Clamp(min backends.Value, x backends.Value, max backends.Value) (backends.Value, error)
- func (f Function) Closure() (backends.Function, error)
- func (f Function) Clz(x backends.Value) (backends.Value, error)
- func (f Function) Complex(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Concatenate(axis int, operands ...backends.Value) (backends.Value, error)
- func (f Function) Conj(x backends.Value) (backends.Value, error)
- func (f Function) Constant(flat any, dims ...int) (backends.Value, error)
- func (f Function) ConvGeneral(input backends.Value, kernel backends.Value, axes backends.ConvolveAxesConfig, ...) (backends.Value, error)
- func (f Function) ConvertDType(x backends.Value, dtype dtypes.DType) (backends.Value, error)
- func (f Function) Cos(x backends.Value) (backends.Value, error)
- func (f Function) Div(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) DotGeneral(lhs backends.Value, lhsContractingAxes []int, lhsBatchAxes []int, ...) (backends.Value, error)
- func (f Function) DynamicSlice(operand backends.Value, startIndices []backends.Value, sliceDims []int) (backends.Value, error)
- func (f Function) DynamicUpdateSlice(operand backends.Value, update backends.Value, startIndices []backends.Value) (backends.Value, error)
- func (f Function) Equal(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) EqualTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Erf(x backends.Value) (backends.Value, error)
- func (f Function) Exp(x backends.Value) (backends.Value, error)
- func (f Function) Expm1(x backends.Value) (backends.Value, error)
- func (f Function) FFT(operand backends.Value, fftType backends.FFTType, fftLength []int) (backends.Value, error)
- func (f Function) Floor(x backends.Value) (backends.Value, error)
- func (f Function) FusedAttentionQKVProjection(x, wQKV, biasQ, biasK, biasV backends.Value, queryDim, keyValueDim int) (query, key, value backends.Value, err error)
- func (f Function) FusedDense(x backends.Value, weight backends.Value, bias backends.Value, ...) (backends.Value, error)
- func (f Function) FusedGelu(x backends.Value, exact bool) (backends.Value, error)
- func (f Function) FusedLayerNorm(x backends.Value, axes []int, epsilon float64, gamma backends.Value, ...) (backends.Value, error)
- func (f Function) FusedQuantizedDense(x backends.Value, weights backends.Value, bias backends.Value, ...) (backends.Value, error)
- func (f Function) FusedScaledDotProductAttention(query backends.Value, key backends.Value, value backends.Value, ...) (backends.Value, error)
- func (f Function) FusedSoftmax(x backends.Value, axis int) (backends.Value, error)
- func (f Function) Gather(operand backends.Value, startIndices backends.Value, indexVectorAxis int, ...) (backends.Value, error)
- func (f Function) GreaterOrEqual(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) GreaterOrEqualTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) GreaterThan(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) GreaterThanTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Identity(x backends.Value) (backends.Value, error)
- func (f Function) If(pred backends.Value, trueBranch, falseBranch backends.Function) ([]backends.Value, error)
- func (f Function) Imag(x backends.Value) (backends.Value, error)
- func (f Function) Iota(shape shapes.Shape, iotaAxis int) (backends.Value, error)
- func (f Function) IsFinite(x backends.Value) (backends.Value, error)
- func (f Function) IsNaN(x backends.Value) (backends.Value, error)
- func (f Function) LessOrEqual(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) LessOrEqualTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) LessThan(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) LessThanTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Log(x backends.Value) (backends.Value, error)
- func (f Function) Log1p(x backends.Value) (backends.Value, error)
- func (f Function) LogicalAnd(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) LogicalNot(x backends.Value) (backends.Value, error)
- func (f Function) LogicalOr(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) LogicalXor(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Logistic(x backends.Value) (backends.Value, error)
- func (f Function) Max(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Min(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Mul(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Name() string
- func (f Function) Neg(x backends.Value) (backends.Value, error)
- func (f Function) NotEqual(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) NotEqualTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Pad(x backends.Value, fillValue backends.Value, axesConfig ...backends.PadAxis) (backends.Value, error)
- func (f Function) Parameter(name string, shape shapes.Shape, spec *backends.ShardingSpec) (backends.Value, error)
- func (f Function) Parent() backends.Function
- func (f Function) Pow(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) QuantizedEmbeddingLookup(data backends.Value, indices backends.Value, ...) (backends.Value, error)
- func (f Function) RNGBitGenerator(state backends.Value, shape shapes.Shape) (newState, values backends.Value, err error)
- func (f Function) Real(x backends.Value) (backends.Value, error)
- func (f Function) ReduceBitwiseAnd(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceBitwiseOr(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceBitwiseXor(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceLogicalAnd(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceLogicalOr(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceLogicalXor(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceMax(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceMin(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceProduct(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceSum(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) ReduceWindow(x backends.Value, reductionType backends.ReduceOpType, ...) (backends.Value, error)
- func (f Function) Rem(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Reshape(x backends.Value, dimensions ...int) (backends.Value, error)
- func (f Function) Return(outputs []backends.Value, shardings []*backends.ShardingSpec) error
- func (f Function) Reverse(x backends.Value, axes ...int) (backends.Value, error)
- func (f Function) Round(x backends.Value) (backends.Value, error)
- func (f Function) Rsqrt(x backends.Value) (backends.Value, error)
- func (f Function) ScatterMax(operand backends.Value, scatterIndices backends.Value, updates backends.Value, ...) (backends.Value, error)
- func (f Function) ScatterMin(operand backends.Value, scatterIndices backends.Value, updates backends.Value, ...) (backends.Value, error)
- func (f Function) ScatterSum(operand backends.Value, scatterIndices backends.Value, updates backends.Value, ...) (backends.Value, error)
- func (f Function) SelectAndScatterMax(operand backends.Value, source backends.Value, windowDimensions []int, ...) (backends.Value, error)
- func (f Function) SelectAndScatterMin(operand backends.Value, source backends.Value, windowDimensions []int, ...) (backends.Value, error)
- func (f Function) ShiftLeft(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) ShiftRightArithmetic(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) ShiftRightLogical(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Sign(x backends.Value) (backends.Value, error)
- func (f Function) Sin(x backends.Value) (backends.Value, error)
- func (f Function) Slice(x backends.Value, starts []int, limits []int, strides []int) (backends.Value, error)
- func (f Function) Sort(comparator backends.Function, axis int, isStable bool, ...) ([]backends.Value, error)
- func (f Function) Sqrt(x backends.Value) (backends.Value, error)
- func (f Function) Sub(lhs backends.Value, rhs backends.Value) (backends.Value, error)
- func (f Function) Tanh(x backends.Value) (backends.Value, error)
- func (f Function) Transpose(x backends.Value, permutation ...int) (backends.Value, error)
- func (f Function) Where(condition backends.Value, onTrue backends.Value, onFalse backends.Value) (backends.Value, error)
- func (f Function) While(cond, body backends.Function, initialState ...backends.Value) ([]backends.Value, error)
Constants ¶
This section is empty.
Variables ¶
var NotImplementedError = backends.ErrNotImplemented
NotImplementedError is returned by every method.
It doesn't contain a stack, attach a stack to with with errors.Wrapf(ErrNotImplemented, "...") when using it.
Functions ¶
This section is empty.
Types ¶
type Backend ¶ added in v0.25.0
type Backend struct{}
Backend is a dummy backend that can be imported to create mock backends.
func (*Backend) BufferCopyToDevice ¶ added in v0.25.0
func (b *Backend) BufferCopyToDevice( source backends.Buffer, deviceNum backends.DeviceNum, ) (bufferOnDevice backends.Buffer, err error)
BufferCopyToDevice returns NotImplementedError.
func (*Backend) BufferData ¶ added in v0.25.0
BufferData returns NotImplementedError.
func (*Backend) BufferDeviceNum ¶ added in v0.25.0
BufferDeviceNum returns NotImplementedError.
func (*Backend) BufferFinalize ¶ added in v0.25.0
BufferFinalize returns NotImplementedError.
func (*Backend) BufferFromFlatData ¶ added in v0.25.0
func (b *Backend) BufferFromFlatData( deviceNum backends.DeviceNum, flat any, shape shapes.Shape, ) (backends.Buffer, error)
BufferFromFlatData returns NotImplementedError.
func (*Backend) BufferShape ¶ added in v0.25.0
BufferShape returns NotImplementedError.
func (*Backend) BufferToFlatData ¶ added in v0.25.0
BufferToFlatData returns NotImplementedError.
func (*Backend) Capabilities ¶ added in v0.25.0
func (b *Backend) Capabilities() backends.Capabilities
Capabilities returns empty capabilities.
func (*Backend) Description ¶ added in v0.25.0
Description is a longer description of the Backend.
func (*Backend) DeviceDescription ¶ added in v0.25.0
DeviceDescription returns a description of the device.
func (*Backend) Finalize ¶ added in v0.25.0
func (b *Backend) Finalize()
Finalize does nothing for this dummy backend.
func (*Backend) HasSharedBuffers ¶ added in v0.25.0
HasSharedBuffers returns false.
func (*Backend) IsFinalized ¶ added in v0.25.0
IsFinalized always returns false for this dummy backend.
func (*Backend) NewSharedBuffer ¶ added in v0.25.0
func (b *Backend) NewSharedBuffer( deviceNum backends.DeviceNum, shape shapes.Shape, ) (buffer backends.Buffer, flat any, err error)
NewSharedBuffer panics as shared buffers are not supported.
func (*Backend) NumDevices ¶ added in v0.25.0
NumDevices returns 1 as the number of devices available.
type Builder ¶
type Builder struct {
// ErrFn is called to generate the error returned, if not nil. Otherwise NotImplementedError is returned directly.
//
// For non-ops methods (like Builder.Name and Builder.Compile) you will have to override them.
ErrFn func(op backends.OpType) error
// contains filtered or unexported fields
}
Builder implements backends.Builder and returns the NotImplementedError wrapped with the stack-trace, the operation name, and the custom message Builder.ErrMessage for every operation.
func (Builder) DeviceAssignment ¶ added in v0.25.0
DeviceAssignment returns nil if it's an assignment to device #0. Otherwise, it returns a non-implemented error.
func (Builder) DistributedAutoSharding ¶ added in v0.25.0
func (Builder) DistributedSPMD ¶ added in v0.25.0
func (Builder) NewFunction ¶ added in v0.27.0
type Function ¶ added in v0.27.0
type Function struct {
// ErrFn is called to generate the error returned, if not nil.
// Otherwise NotImplementedError is returned directly.
ErrFn func(op backends.OpType) error
}
Function implements backends.Function and returns NotImplementedError for every operation.
func (Function) Abs ¶ added in v0.27.0
Abs returns the Op that represents the output of the corresponding operation.
func (Function) Add ¶ added in v0.27.0
Add returns the element-wise sum of the two values. Standard broadcasting rules apply (see documentation).
func (Function) ArgMinMax ¶ added in v0.27.0
func (f Function) ArgMinMax(x backends.Value, axis int, outputDType dtypes.DType, isMin bool) (backends.Value, error)
ArgMinMax calculates the "argmin" or "argmax" across an axis of the given input array x.
outputDType defines the output of the argmin/argmax, it doesn't need to be the same as the input. It's a form of reduction on the given axis, and that axis goes away. So the rank of the result is one less than the rank of x.
If there is a NaN in the slice being examined, it is chosen for ArgMinMax -- this is inline with Jax, TensorFlow, and PyTorch.
Examples:
ArgMinMax(x={{2, 0, 7}, {-3, 4, 2}}, axis=1, isMin=true) -> {1, 0} // (it chooses the 0 and the -3)
ArgMinMax(x={{2, 0, 7}, {-3, 4, 2}}, axis=0, isMin=false) -> {0, 1, 0} // (it chooses the 2, 4, and 7)
func (Function) Atan2 ¶ added in v0.27.0
Atan2 returns element-wise the arc tangent of y/x, using the signs of both arguments to determine the correct quadrant of the result. Standard broadcasting rules apply (see documentation).
func (Function) BatchNormForInference ¶ added in v0.27.0
func (Function) BatchNormForTraining ¶ added in v0.27.0
func (Function) BatchNormGradient ¶ added in v0.27.0
func (Function) BitCount ¶ added in v0.27.0
BitCount returns the number of bits that are set to one. Also known as Population Count ("Popcnt") or Hamming Weight.
func (Function) Bitcast ¶ added in v0.27.0
Bitcast performs an elementwise bit-cast operation from a dtype to another dtype.
The Bitcast doesn't "convert", rather it just reinterprets the bits from x.DType() to the targetDType.
If x.DType() and targetDType use the same number of bytes (targetDType.Size() == x.DType().Size()), the dimensions are not changed, simply the dtype is changed.
If targetDType.Size() > x.DType().Size(), it requires x last axis to have a dimension of targetDType.Size() / x.DType().Size(), and the returned shape will trim the last axis.
If targetDType.Size() < x.DType().Size(), the returned shape will have an extra axis in the end, with dimension of x.DType().Size() / targetDType.Size().
E.g: Bitcast([1]uint32{0xdeadbeef}, dtypes.UInt16) -> [1][2]uint16{{0xbeef, 0xdead}} // Little-endian encoding.
func (Function) BitwiseAnd ¶ added in v0.27.0
BitwiseAnd returns the element-wise bitwise AND operation.
func (Function) BitwiseNot ¶ added in v0.27.0
BitwiseNot returns the element-wise bitwise AND operation.
func (Function) BitwiseOr ¶ added in v0.27.0
BitwiseOr returns the element-wise bitwise OR operation.
func (Function) BitwiseXor ¶ added in v0.27.0
BitwiseXor returns the element-wise bitwise XOR operator.
func (Function) BroadcastInDim ¶ added in v0.27.0
func (f Function) BroadcastInDim(x backends.Value, outputShape shapes.Shape, broadcastAxes []int) (backends.Value, error)
BroadcastInDim broadcasts x to an output with the given shape. broadcastAxes has an output axes value for each x axes (len(broadcastAxes) == x.Shape.Rank()). The i-th axis of x is mapped to the broadcastAxes[i]-th dimension of the output. broadcastAxes must be also increasing: this operation cannot be used to transpose axes, it will only broadcast and introduce new axes in-between. This also requires that the i-th input axis is either 1 or is the same as the output dimension it's broadcasting into. For example, say operand `x = (s32)[2]{1, 2}`; outputShape = `(s32)[2,2]`:
- Specifying []int{1} as broadcastAxes will generate output {{1, 2}, {1, 2}}
- On the other hand, specifying []int{0} as broadcastAxes will generate output {{1 , 1}, {2 , 2}}
func (Function) Ceil ¶ added in v0.27.0
Ceil returns the Op that represents the output of the corresponding operation.
func (Function) Clamp ¶ added in v0.27.0
func (f Function) Clamp(min backends.Value, x backends.Value, max backends.Value) (backends.Value, error)
Clamp returns the element-wise clamping operation.
The values max and min can either be a scalar or have the same shape as x.
func (Function) Clz ¶ added in v0.27.0
Clz returns element-wise the "count leading zeros" bits of input node x -- for integer values.
func (Function) Complex ¶ added in v0.27.0
Complex returns the complex number taking x0 as the real part and x1 as the imaginary part. The real (x0) and imaginary (x1) must have the same dtype, and they must be either `dtypes.Float32` or `dtypes.Float64`. The output will be either `dtypes.Complex64` or `dtypes.Complex128`, depending on x0 and x1 dtypes. The shapes of `real` or `imaginary` must be the same, or one must be a scalar, in which case the value is broadcast to every other value.
func (Function) Concatenate ¶ added in v0.27.0
Concatenate operands on the given axis.
All axes that are not being concatenated must match dimensions, except on the axes being concatenated. It doesn't work with scalars -- use ExpandAxes. If there is only one operand, it is returned and this is a no-op.
func (Function) Conj ¶ added in v0.27.0
Conj returns the conjugate of a complex number. E.g: Conj(1+3i) = 1-3i
func (Function) ConvGeneral ¶ added in v0.27.0
func (f Function) ConvGeneral(input backends.Value, kernel backends.Value, axes backends.ConvolveAxesConfig, strides []int, paddings [][2]int, inputDilations []int, kernelDilations []int, channelGroupCount int, batchGroupCount int) (backends.Value, error)
ConvGeneral is a generic Convolution operation with support for: - Arbitrary number of spatial axes. - Arbitrary transposition of axes. - Strides and padding. - Dilations of the input. - Dilations of the kernel, aka. atrous convolution. - Channels grouping (on the input channels). - Batch grouping. Some details in https://www.tensorflow.org/xla/operation_semantics#convwithgeneralpadding_convolution. There operand and filter are called lhs and rhs. (XLA documentation is unfortunately poor, much is guess-work). Also useful, https://arxiv.org/pdf/1603.07285v1.pdf. Note:
- Another common term for "channels" is "features".
- "Kernel" is also commonly called "weights" or "filters".
func (Function) ConvertDType ¶ added in v0.27.0
ConvertDType of x to dtype.
func (Function) Cos ¶ added in v0.27.0
Cos returns the Op that represents the output of the corresponding operation.
func (Function) Div ¶ added in v0.27.0
Div returns the element-wise division of the two values. Standard broadcasting rules apply (see documentation).
func (Function) DotGeneral ¶ added in v0.27.0
func (f Function) DotGeneral(lhs backends.Value, lhsContractingAxes []int, lhsBatchAxes []int, rhs backends.Value, rhsContractingAxes []int, rhsBatchAxes []int, config backends.DotGeneralConfig) (backends.Value, error)
DotGeneral takes as input lhs (left-hand-side) and rhs (right-hand-side) specifications for a general vector product -- a generalized "Einsum". Each axis can be:
- Just aligned (batch axes), so the output has the same axes as the inputs. The dimensions must match in lhs and rhs.
- Crossed (default), in which case the output is the combination (concatenation) of the dimensions.
- Contracted (contracting axes), where the output does multiply the values and reduce sum those dimensions.
It follows that the resulting dimension number starts with the batch dimension, then the 'lhs' non-contracting/non-batch dimension, and finally the 'rhs' non-contracting/non-batch dimension. It provides the basic means of implementing Einsum.
func (Function) DynamicSlice ¶ added in v0.27.0
func (f Function) DynamicSlice(operand backends.Value, startIndices []backends.Value, sliceDims []int) (backends.Value, error)
DynamicSlice extracts a slice from the operand at the startIndices position and the given sliceSizes.
- operand: tensor from where to take the slice. - startIndices: scalar tensors, one per axis of operand: len(startIndices) == operand.Rank(). - sliceSizes: static values and fixed to keep the shape of the output static.
The startIndices are adjusted as follows:
adjustedStartIndices[i] = clamp(0, StartIndices[i], operand.Dimensions[i] - sliceSizes[i])
See description in https://openxla.org/xla/operation_semantics#dynamicslice
func (Function) DynamicUpdateSlice ¶ added in v0.27.0
func (f Function) DynamicUpdateSlice(operand backends.Value, update backends.Value, startIndices []backends.Value) (backends.Value, error)
DynamicUpdateSlice updates the operand with the values given in update, at the position given by startIndices.
- operand: original value that to be updated. - update: values to "paste" on top of operand, at position startIndices. - startIndices: scalar tensors, one per axis of operand: len(startIndices) == operand.Rank(). - sliceSizes: static values and fixed to keep the shape of the output static.
It returns a value with the same shape as the operand, with the values updated.
The startIndices are adjusted as follows:
adjustedStartIndices[i] = clamp(0, StartIndices[i], operand.Dimensions[i] - update.Dimensions[i])
func (Function) Equal ¶ added in v0.27.0
Equal performs element-wise equality check, returns boolean results with the same dimensions as input.
func (Function) EqualTotalOrder ¶ added in v0.27.0
EqualTotalOrder returns the element-wise operation. Standard broadcasting rules apply (see documentation). The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
func (Function) Erf ¶ added in v0.27.0
Erf returns the "error function", defined as erf(x) = 2/Pi * \int_{0}^{x}{e^{-t^2}dt}.
func (Function) Exp ¶ added in v0.27.0
Exp returns the Op that represents the output of the corresponding operation.
func (Function) Expm1 ¶ added in v0.27.0
Expm1 returns the Op that represents the output of the corresponding operation.
func (Function) FFT ¶ added in v0.27.0
func (f Function) FFT(operand backends.Value, fftType backends.FFTType, fftLength []int) (backends.Value, error)
FFT calls the XLA FFT operation, which implements {Forward, Inverse} x {Complex, Real} versions. See documentation in https://www.tensorflow.org/xla/operation_semantics. Underlying, CPU FFT is backed by Eigen's TensorFFT, and GPU FFT uses cuFFT.
func (Function) Floor ¶ added in v0.27.0
Floor returns the Op that represents the output of the corresponding operation.
func (Function) FusedAttentionQKVProjection ¶ added in v0.27.0
func (Function) FusedDense ¶ added in v0.27.0
func (f Function) FusedDense(x backends.Value, weight backends.Value, bias backends.Value, activation backends.ActivationType) (backends.Value, error)
FusedDense performs fused matmul + optional bias + optional activation.
It does y = activation(x @ W + bias). Where @ is a standard matmul, it contracts x's last axis with weight's first axis.
- x: [batch..., in_features], weight: [in_features, out_features...], - bias: [out_features...] (nil-able). - activation: applied after the matmul+bias; set to ActivationNone for no activation.
func (Function) FusedGelu ¶ added in v0.27.0
FusedGelu computes Gaussian Error Linear Unit activation. If exact is true, the exact GELU (using erf) is computed; otherwise the tanh approximation is used.
func (Function) FusedLayerNorm ¶ added in v0.27.0
func (f Function) FusedLayerNorm(x backends.Value, axes []int, epsilon float64, gamma backends.Value, beta backends.Value) (backends.Value, error)
FusedLayerNorm applies layer normalization over specified axes. gamma and beta can be nil if no learned scale/offset. epsilon: numerical stability constant (typically 1e-5).
func (Function) FusedQuantizedDense ¶ added in v0.27.0
func (f Function) FusedQuantizedDense(x backends.Value, weights backends.Value, bias backends.Value, weightsQuantization *backends.Quantization, activation backends.ActivationType) (backends.Value, error)
FusedQuantizedDense performs fused dequantization + matmul + optional bias + optional activation.
It computes y = activation(x @ dequant(weights, weightsQuantization) + bias), where the dequantization and matmul are fused into a single pass to avoid materializing the full float32 weight matrix.
Inputs:
- x: [batch..., K] float32 input activations.
- weights: For Linear/NF4: [K, N] with dtype reflecting storage precision (e.g. Int4, Int8). For sub-byte types the caller should Bitcast packed uint8 data to the correct dtype before calling. For GGML: [N, bytesPerRow] Uint8 with native GGML block layout, where N is the output-features dimension and bytesPerRow = (K / valuesPerBlock) * bytesPerBlock.
- bias: [N] float32 (nil-able), added after matmul but before activation.
- weightsQuantization: describes how to dequantize the weights tensor. Must not be nil.
- activation: applied after matmul+bias; set to ActivationNone for no activation.
Future: inputQuantization, outputQuantization, and biasQuantization parameters may be added to support fully quantized operations where the activations and/or output are also quantized.
func (Function) FusedScaledDotProductAttention ¶ added in v0.27.0
func (f Function) FusedScaledDotProductAttention(query backends.Value, key backends.Value, value backends.Value, mask backends.Value, numHeads int, numKVHeads int, axesLayout backends.AxesLayout, scale float64, causal bool, options *backends.ScaledDotProductAttentionConfig) (backends.Value, error)
FusedScaledDotProductAttention computes multi-head scaled dot-product attention.
output = softmax(query @ key^T * scale + mask) @ value, computed per-head with GQA support.
Inputs:
- query, key, value: 4D tensors whose axis ordering is determined by axesLayout. For AxesLayoutBHSD: query [batch, numHeads, seqLen, headDim], key/value [batch, numKVHeads, kvLen, headDim]. For AxesLayoutBSHD: query [batch, seqLen, numHeads, headDim], key/value [batch, kvLen, numKVHeads, headDim].
- mask: [seqLen, kvLen] (seqLen is the query sequence length): optional (can be nil) mask that can be either boolean or additive (any dtype other than Bool). See also causal below. Boolean mask: true = attend, false = ignore. Float/additive mask: added to scores before softmax. Must be broadcastable to the score tensor shape.
Parameters:
- numHeads: number of query attention heads
- numKVHeads: number of key/value attention heads (for GQA; numHeads must be divisible by numKVHeads)
- axesLayout: determines the axis ordering of query/key/value tensors
- scale: scaling factor applied to query @ key^T (typically 1/sqrt(headDim))
- causal: if true, apply causal (lower-triangular) mask. Callers (e.g. attention.Core) treat causal and mask as mutually exclusive, folding causal into the mask before calling this method when both are needed. Backends may assume they won't both be set.
- options: optional optimization hints (nil uses defaults). See ScaledDotProductAttentionConfig.
Output: same shape as query.
func (Function) FusedSoftmax ¶ added in v0.27.0
FusedSoftmax computes softmax along the specified axis.
Note: unlike the generic softmax in GoMLX's graph package, the fused softmax only accepts one axis. The axis must be non-negative (the caller normalizes negative indices before calling).
func (Function) Gather ¶ added in v0.27.0
func (f Function) Gather(operand backends.Value, startIndices backends.Value, indexVectorAxis int, offsetOutputAxes []int, collapsedSliceAxes []int, startIndexMap []int, sliceSizes []int, indicesAreSorted bool) (backends.Value, error)
Gather is a powerful but cumbersome Gather operation offered by XLA. Full details in https://www.tensorflow.org/xla/operation_semantics#gather or in https://openxla.org/stablehlo/spec#gather (StableHLO also adds batch axes).
The output of Gather has the same DType of the operand, from where we are pulling the data.
Its output shape will be composed of 2 parts:
- Batch axes: they come from the axes of startIndices, except the "indexVectorAxis" (usually the last) that is used as the indices into the operand. (*)
- "Offset axes": these are axes that come from the operand, the sizes given by sliceSizes. Notice that if sliceSizes for an axis is 1, and that axis is present in the collapsedSliceAxes list, this axis gets omitted in the output.
So in general output.Rank() = startIndices.Rank() - 1 + len(offsetAxes).
(*) One exception is if indexVectorAxis == startIndices.Rank(), in which case we assume there is an extra implicit axis in startIndices of size 1, in which case output.Rank() = startIndices.Rank() + len(offsetAxes).
Arguments:
- operand: the values from where we are gathering. The output DType will follow the operand one.
- startIndices: are the indices we want to gather. The axis pointed by indexVector lists the indices of the slice to be gathered in the operand array (their values are mapped to the axis in the operand according to startIndexMap). All other axes are "batch dimensions" and they will have equivalent axes (same dimensions) in the output.
- indexVectorAxis: which of the axis in startIndices is collected and used as the start index for slices to be gathered in the operand. It is typically the last axis of startIndices, so startIndices.Shape.Rank()-1. There is a special case where indexVectorAxis == startIndices.Rank() in which case we assume there is an extra virtual axis in startIndices of size 1, in which case output.Rank() = startIndices.Rank() + len(offsetAxes).
- offsetOutputAxes: _output_ axes (not the operand's) that will hold the "offset slices", slices that are not collapsed. It points in which position (axis) in the output these slices should show up. The len(offsetOutputAxes) must match the dimension of indexVectorAxis (== startIndices.Dimensions[indexVectorAxis]). Notice all axes in the operand will either become an "offset axis" in the output, of optionally collapsed (or "squeezed") in the output, if included in collapsedSliceAxes. The axes in the output (given in offsetAxes) to the axes in the operand (the axes not present in collapsedSliceAxes) sequentially. One must have Rank(operand) == len(collapsedSliceAxes) + len(offsetAxes).
- collapsedSliceAxes: _operand_ axes (for which sliceSizes are 1) not to be included in the output. One must have sliceSizes[collapsedSliceAxes[i]] == 1 for all i. Also, one must have Rank(operand) == len(collapsedSliceAxes) + len(offsetOutputAxes).
- startIndexMap: this maps which value in startIndices is used for which axis in the operand, select the slice to be gathered. Notice len(startIndexMap) must match the startIndices.Dimensions[indexVectorAxis]. Also, len(startIndexMap) == len(offsetOutputAxes) -- offsetOutputAxes maps the same axes in the output. E.g.: if startIndices.shape=(2, 3), indexVectorAxis=1, and operand.rank=4 and startIndexMap=[]int{0, 1, 2}, this means each row of the startIndices will point to the first 3 axes (0,1 and 2) in the operand. In many cases this is [0, 1, 2, ..., operand.Shape.Rank()-1], that is, each "index vector" fully defines an element on the operand. In some this is only a prefix of the operand's rank. For those axes in the operand not explicitly set (so if len(startIndexMap) < operand.Rank()), the corresponding axis start index is considered to be 0, and one sets the sliceSizes to take the slice one wants (typically the full slice).
- sliceSizes: a size for each operand's axis, so len(sliceSize) = operand.Rank(). once the start index from where to gather is resolved, this defines how much data in each axis to gather. Constraints: sliceSizes[collapsedSliceAxes[i]] == 1, for all i.
- indicesAreSorted: can be set to true if it's guaranteed that startIndices are sorted (in ascending order, after scattering its values according to start_index_map) by the user. This allows for some optimizations in some platforms.
Out-of-bound (and negative) indices <i> are adjusted with max(min(<i>, axisDimension-1), 0), meaning they are taken from the border of the axes. TODO: Add batch support: operandBatchingAxes and startIndicesBatchingAxes.
func (Function) GreaterOrEqual ¶ added in v0.27.0
GreaterOrEqual performs element-wise comparison, returns boolean results with the same dimensions as input.
func (Function) GreaterOrEqualTotalOrder ¶ added in v0.27.0
func (f Function) GreaterOrEqualTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
GreaterOrEqualTotalOrder returns the element-wise operation. Standard broadcasting rules apply (see documentation). The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
func (Function) GreaterThan ¶ added in v0.27.0
GreaterThan performs element-wise comparison, returns boolean results with the same dimensions as input.
func (Function) GreaterThanTotalOrder ¶ added in v0.27.0
func (f Function) GreaterThanTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
GreaterThanTotalOrder returns the element-wise operation. Standard broadcasting rules apply (see documentation). The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
func (Function) Imag ¶ added in v0.27.0
Imag returns the imaginary part of a complex number. It returns 0 if the x is a float number.
func (Function) Iota ¶ added in v0.27.0
Iota creates a constant of the given shape with increasing numbers (starting from 0) on the given axis. So Iota([2,2], 1) returns [[0 1][0 1]], while Iota([2,2], 0) returns [[0 0][1 1]].
func (Function) IsFinite ¶ added in v0.27.0
IsFinite tests whether each element of operand is finite, i.e., if it is not positive nor negative infinity, and it is not NaN. It returns the same shape as the input, but with boolean values where each element is true if and only if the corresponding input element is finite.
func (Function) IsNaN ¶ added in v0.27.0
IsNaN tests whether each element of operand is NaN, i.e., if it is not a finite number.
func (Function) LessOrEqual ¶ added in v0.27.0
LessOrEqual performs element-wise comparison, returns boolean results with the same dimensions as input.
func (Function) LessOrEqualTotalOrder ¶ added in v0.27.0
func (f Function) LessOrEqualTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
LessOrEqualTotalOrder returns the element-wise operation. Standard broadcasting rules apply (see documentation). The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
func (Function) LessThan ¶ added in v0.27.0
LessThan performs element-wise comparison, returns boolean results with the same dimensions as input.
func (Function) LessThanTotalOrder ¶ added in v0.27.0
func (f Function) LessThanTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
LessThanTotalOrder returns the element-wise operation. Standard broadcasting rules apply (see documentation). The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
func (Function) Log ¶ added in v0.27.0
Log returns the Op that represents the output of the corresponding operation.
func (Function) LogicalAnd ¶ added in v0.27.0
LogicalAnd returns the element-wise logical AND operation.
func (Function) LogicalNot ¶ added in v0.27.0
LogicalNot returns the Op that represents the output of the corresponding operation.
func (Function) LogicalOr ¶ added in v0.27.0
LogicalOr returns the element-wise logical OR operation.
func (Function) LogicalXor ¶ added in v0.27.0
LogicalXor returns the element-wise logical XOR operator.
func (Function) Logistic ¶ added in v0.27.0
Logistic returns the element-wise expression 1/(1+exp(-x)). Also known as the Sigmoid function.
func (Function) Mul ¶ added in v0.27.0
Mul returns the element-wise multiplication of the two values. Standard broadcasting rules apply (see documentation).
func (Function) Neg ¶ added in v0.27.0
Neg returns the Op that represents the output of the corresponding operation.
func (Function) NotEqual ¶ added in v0.27.0
NotEqual performs element-wise inequality check, returns boolean results with the same dimensions as input.
func (Function) NotEqualTotalOrder ¶ added in v0.27.0
func (f Function) NotEqualTotalOrder(lhs backends.Value, rhs backends.Value) (backends.Value, error)
NotEqualTotalOrder returns the element-wise operation. Standard broadcasting rules apply (see documentation). The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
func (Function) Pad ¶ added in v0.27.0
func (f Function) Pad(x backends.Value, fillValue backends.Value, axesConfig ...backends.PadAxis) (backends.Value, error)
Pad injects padding on the start, end, or interior (in between each element) of the given operand. There must be at most `operand.Rank()` axesConfig values. Missing PadAxis are assumed to be zeros, that is, no padding for those axes.
func (Function) Pow ¶ added in v0.27.0
Pow returns the Op that represents the output of the corresponding operation.
func (Function) QuantizedEmbeddingLookup ¶ added in v0.27.3
func (f Function) QuantizedEmbeddingLookup(data backends.Value, indices backends.Value, dataQuantization *backends.Quantization) (backends.Value, error)
QuantizedEmbeddingLookup performs a quantized embedding lookup (row gather) with on-the-fly dequantization.
This is the quantized analogue of embedding lookup, inspired by llama.cpp's ggml_get_rows. For now it is only implemented for the GGML quantization scheme, but could be extended for others if/when needed.
Inputs:
- data: [vocabSize, bytesPerRow] Uint8 with native GGML block layout.
- indices: integer tensor with last dimension = 1 (same as Gather convention). For embeddings: [batch, seqLen, 1].
- dataQuantization: describes how to dequantize the data rows. Must not be nil. Only QuantGGML scheme is currently supported.
Output: float32 tensor with shape [batch..., K] where K = (bytesPerRow / bytesPerBlock) * valuesPerBlock.
For embeddings with indices [batch, seqLen, 1]: output is [batch, seqLen, K].
func (Function) RNGBitGenerator ¶ added in v0.27.0
func (Function) Real ¶ added in v0.27.0
Real return the real part of a complex number. It returns x if the x is a float number.
func (Function) ReduceBitwiseAnd ¶ added in v0.27.0
ReduceBitwiseAnd reduces x over the axes selected, performing a BitwiseAnd on the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceBitwiseOr ¶ added in v0.27.0
ReduceBitwiseOr reduces x over the axes selected, performing a BitwiseOr on the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceBitwiseXor ¶ added in v0.27.0
ReduceBitwiseXor reduces x over the axes selected, performing a BitwiseXor on the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceLogicalAnd ¶ added in v0.27.0
ReduceLogicalAnd reduces x over the axes selected, performing a LogicalAnd on the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceLogicalOr ¶ added in v0.27.0
ReduceLogicalOr reduces x over the axes selected, performing a LogicalOr on the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceLogicalXor ¶ added in v0.27.0
ReduceLogicalXor reduces x over the axes selected, performing a LogicalXor on the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceMax ¶ added in v0.27.0
ReduceMax reduces x over the axes selected, taking the Max value of the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceMin ¶ added in v0.27.0
ReduceMin reduces x over the axes selected, taking the Min value of the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceProduct ¶ added in v0.27.0
ReduceProduct reduces x over the axes selected, taking the product of the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceSum ¶ added in v0.27.0
ReduceSum reduces x over the axes selected, taking the sum of the slices reduced.
The returned result rank is decreased by len(axes).
If no axes are given, it reduces the full array.
func (Function) ReduceWindow ¶ added in v0.27.0
func (Function) Rem ¶ added in v0.27.0
Rem returns the remainder operation, also known as modulo (or Mod for short). Notice despite the name XLA implements Mod not IEEE754 Remainder operation.
func (Function) Reshape ¶ added in v0.27.0
Reshape reshapes x to the new dimensions. Total size cannot change, it's just a "reinterpretation" of the same flat data. The dtype remains the same, see ConvertDType to actually convert the values.
func (Function) Reverse ¶ added in v0.27.0
Reverse returns x with the values for the given dimensions reversed, that is, the value indexed at `i` will be swapped with the value at indexed `(dimension_size - 1 - i)`. The shape remains the same.
func (Function) Round ¶ added in v0.27.0
Round returns the Op that represents the output of the corresponding operation. This operation rounds to the nearest even.
func (Function) Rsqrt ¶ added in v0.27.0
Rsqrt returns the element-wise reciprocal of square root operation 1/sqrt(x).
func (Function) ScatterMax ¶ added in v0.27.0
func (f Function) ScatterMax(operand backends.Value, scatterIndices backends.Value, updates backends.Value, indexVectorAxis int, updateWindowAxes []int, insertedWindowAxes []int, scatterAxesToOperandAxes []int, indicesAreSorted bool, uniqueIndices bool) (backends.Value, error)
ScatterMax scatter values from updates pointed by scatterIndices to operand, by taking the Max.
func (Function) ScatterMin ¶ added in v0.27.0
func (f Function) ScatterMin(operand backends.Value, scatterIndices backends.Value, updates backends.Value, indexVectorAxis int, updateWindowAxes []int, insertedWindowAxes []int, scatterAxesToOperandAxes []int, indicesAreSorted bool, uniqueIndices bool) (backends.Value, error)
ScatterMin scatter values from updates pointed by scatterIndices to operand, by taking the Min.
func (Function) ScatterSum ¶ added in v0.27.0
func (f Function) ScatterSum(operand backends.Value, scatterIndices backends.Value, updates backends.Value, indexVectorAxis int, updateWindowAxes []int, insertedWindowAxes []int, scatterAxesToOperandAxes []int, indicesAreSorted bool, uniqueIndices bool) (backends.Value, error)
ScatterSum values from updates pointed by scatterIndices to operand.
func (Function) SelectAndScatterMax ¶ added in v0.27.0
func (f Function) SelectAndScatterMax(operand backends.Value, source backends.Value, windowDimensions []int, windowStrides []int, paddings [][2]int) (backends.Value, error)
SelectAndScatterMax runs windows (similar to ReduceWindow) over the operand, selects values to update the output (like ScatterAdd) It selects the values in the window such that it works as reverse for a PoolMax operation. See details in https://openxla.org/xla/operation_semantics#selectandscatter
func (Function) SelectAndScatterMin ¶ added in v0.27.0
func (f Function) SelectAndScatterMin(operand backends.Value, source backends.Value, windowDimensions []int, windowStrides []int, paddings [][2]int) (backends.Value, error)
SelectAndScatterMin runs windows (similar to ReduceWindow) over the operand, selects values to update the output (like ScatterAdd) It selects the values in the window such that it works as reverse for a PoolMin operation. See details in https://openxla.org/xla/operation_semantics#selectandscatter
func (Function) ShiftLeft ¶ added in v0.27.0
ShiftLeft n bits. It implicitly preserves the sign bit if there is no overflow. So ShiftLeft(-1, 1) = -2.
func (Function) ShiftRightArithmetic ¶ added in v0.27.0
func (f Function) ShiftRightArithmetic(lhs backends.Value, rhs backends.Value) (backends.Value, error)
ShiftRightArithmetic shifts right by n bits, preserving the sign bit. So ShiftRight(-2, 1) = -1.
func (Function) ShiftRightLogical ¶ added in v0.27.0
ShiftRightLogical shifts right by n bits, destroying the sign bit.
func (Function) Sign ¶ added in v0.27.0
Sign returns element-wise +1, +/-0 or -1 depending on the sign of x. It returns NaN if the input is NaN.
func (Function) Sin ¶ added in v0.27.0
Sin returns the Op that represents the output of the corresponding operation.
func (Function) Slice ¶ added in v0.27.0
func (f Function) Slice(x backends.Value, starts []int, limits []int, strides []int) (backends.Value, error)
Slice extracts a subarray from the input array. The subarray is of the same rank as the input and contains the values inside a bounding box within the input array where the dimensions and indices of the bounding box are given as arguments to the slice operation. The strides set the input stride of the slice in each axis and must be >= 1. It is optional, and if missing, it is assumed to be 1 for every dimension. Examples:
Slice(x={0, 1, 2, 3, 4}, starts={2}, limits={4}, strides=nil) -> {2, 3}
Slice(x={0, 1, 2, 3, 4}, starts={2}, limits={5}, strides={2}) -> {2, 4}
func (Function) Sqrt ¶ added in v0.27.0
Sqrt returns the Op that represents the output of the corresponding operation.
func (Function) Sub ¶ added in v0.27.0
Sub returns the element-wise subtraction of the two values. Standard broadcasting rules apply (see documentation).
func (Function) Tanh ¶ added in v0.27.0
Tanh returns the Op that represents the output of the corresponding operation.
func (Function) Transpose ¶ added in v0.27.0
Transpose axes of x. There should be one value in permutations for each axis in x. The output will have: output.Shape.Dimension[ii] = x.Shape.Dimension[permutations[i]].
func (Function) Where ¶ added in v0.27.0
func (f Function) Where(condition backends.Value, onTrue backends.Value, onFalse backends.Value) (backends.Value, error)
Where takes element-wise values from onTrue or onFalse depending on the value of the condition (must be boolean).
The condition must be boolean, and onTrue and onFalse must have the same dtype.
If either condition, onTrue or onFalse is a scalar, it will be broadcasted to the shape of the other operands.