notimplemented

package
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2025 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
var NotImplementedError = fmt.Errorf("not implemented")

NotImplementedError is returned by every method.

Functions

This section is empty.

Types

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
}

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) Abs

func (b Builder) Abs(x backends.Op) (backends.Op, error)

Abs returns the Op that represents the output of the corresponding operation.

func (Builder) Add

func (b Builder) Add(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Add returns the element-wise sum of the two values. Standard broadcasting rules apply (see documentation).

func (Builder) ArgMinMax

func (b Builder) ArgMinMax(x backends.Op, axis int, outputDType dtypes.DType, isMin bool) (backends.Op, 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 (Builder) BatchNormForInference

func (b Builder) BatchNormForInference(operand, scale, offset, mean, variance backends.Op, epsilon float32, axis int) (backends.Op, error)

func (Builder) BatchNormForTraining

func (b Builder) BatchNormForTraining(operand, scale, offset backends.Op, epsilon float32, axis int) (normalized, batchMean, batchVariance backends.Op, err error)

func (Builder) BatchNormGradient

func (b Builder) BatchNormGradient(operand, scale, mean, variance, gradOutput backends.Op, epsilon float32, axis int) (gradOperand, gradScale, gradOffset backends.Op, err error)

func (Builder) BitCount

func (b Builder) BitCount(operand backends.Op) (backends.Op, error)

BitCount returns the number of bits that are set to one. Also known as Population Count ("Popcnt") or Hamming Weight.

func (Builder) Bitcast

func (b Builder) Bitcast(x backends.Op, targetDType dtypes.DType) (backends.Op, error)

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 (Builder) BitwiseAnd

func (b Builder) BitwiseAnd(lhs backends.Op, rhs backends.Op) (backends.Op, error)

BitwiseAnd returns the element-wise bitwise AND operation.

func (Builder) BitwiseNot

func (b Builder) BitwiseNot(x backends.Op) (backends.Op, error)

BitwiseNot returns the element-wise bitwise AND operation.

func (Builder) BitwiseOr

func (b Builder) BitwiseOr(lhs backends.Op, rhs backends.Op) (backends.Op, error)

BitwiseOr returns the element-wise bitwise OR operation.

func (Builder) BitwiseXor

func (b Builder) BitwiseXor(lhs backends.Op, rhs backends.Op) (backends.Op, error)

BitwiseXor returns the element-wise bitwise XOR operator.

func (Builder) BroadcastInDim

func (b Builder) BroadcastInDim(x backends.Op, outputShape shapes.Shape, broadcastAxes []int) (backends.Op, 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 (Builder) Ceil

func (b Builder) Ceil(x backends.Op) (backends.Op, error)

Ceil returns the Op that represents the output of the corresponding operation.

func (Builder) Clamp added in v0.23.0

func (b Builder) Clamp(min backends.Op, x backends.Op, max backends.Op) (backends.Op, 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 (Builder) Clz

func (b Builder) Clz(x backends.Op) (backends.Op, error)

Clz returns element-wise the "count leading zeros" bits of input node x -- for integer values.

func (Builder) Compile

func (b Builder) Compile(outputs ...backends.Op) (backends.Executable, error)

func (Builder) Complex

func (b Builder) Complex(lhs backends.Op, rhs backends.Op) (backends.Op, error)

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 (Builder) Concatenate

func (b Builder) Concatenate(axis int, operands ...backends.Op) (backends.Op, error)

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 (Builder) Conj

func (b Builder) Conj(x backends.Op) (backends.Op, error)

Conj returns the conjugate of a complex number. E.g: Conj(1+3i) = 1-3i

func (Builder) Constant

func (b Builder) Constant(flat any, dims ...int) (backends.Op, error)

func (Builder) ConvGeneral added in v0.22.0

func (b Builder) ConvGeneral(input backends.Op, kernel backends.Op, axes backends.ConvolveAxesConfig, strides []int, paddings [][2]int, inputDilations []int, kernelDilations []int, channelGroupCount int, batchGroupCount int) (backends.Op, 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 (Builder) ConvertDType

func (b Builder) ConvertDType(x backends.Op, dtype dtypes.DType) (backends.Op, error)

ConvertDType of x to dtype.

func (Builder) Cos

func (b Builder) Cos(x backends.Op) (backends.Op, error)

Cos returns the Op that represents the output of the corresponding operation.

func (Builder) Div

func (b Builder) Div(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Div returns the element-wise division of the two values. Standard broadcasting rules apply (see documentation).

func (Builder) Dot

func (b Builder) Dot(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Dot returns the "dot product" operation. The exact semantics of this operation depend on the ranks of the operands: | Input | Output | Semantics | | vector [n] dot vector [n] | scalar | vector dot product | | matrix [m x k] dot vector [k] | vector [m] matrix-vector multiplication | | matrix [m x k] dot matrix [k x n] | matrix [m x n] | matrix-matrix multiplication | The operation performs sum of products over the second dimension of x0 (or the first if it has rank 1) and the first dimension of x1. These are the "contracted" dimensions. The contracted dimensions of x0 and x1 must be of the same size. In practice, it can be used to perform dot products between vectors, vector/matrix multiplications, or matrix/matrix multiplications.

func (Builder) DotGeneral

func (b Builder) DotGeneral(lhs backends.Op, lhsContractingAxes []int, lhsBatchAxes []int, rhs backends.Op, rhsContractingAxes []int, rhsBatchAxes []int) (backends.Op, 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 (Builder) DynamicSlice

func (b Builder) DynamicSlice(operand backends.Op, startIndices []backends.Op, sliceDims []int) (backends.Op, 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 (Builder) DynamicUpdateSlice

func (b Builder) DynamicUpdateSlice(operand backends.Op, update backends.Op, startIndices []backends.Op) (backends.Op, 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 (Builder) Equal

func (b Builder) Equal(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Equal performs element-wise equality check, returns boolean results with the same dimensions as input.

func (Builder) EqualTotalOrder

func (b Builder) EqualTotalOrder(lhs backends.Op, rhs backends.Op) (backends.Op, error)

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 (Builder) Erf

func (b Builder) Erf(x backends.Op) (backends.Op, error)

Erf returns the "error function", defined as erf(x) = 2/Pi * \int_{0}^{x}{e^{-t^2}dt}.

func (Builder) Exp

func (b Builder) Exp(x backends.Op) (backends.Op, error)

Exp returns the Op that represents the output of the corresponding operation.

func (Builder) Expm1

func (b Builder) Expm1(x backends.Op) (backends.Op, error)

Expm1 returns the Op that represents the output of the corresponding operation.

func (Builder) FFT

func (b Builder) FFT(operand backends.Op, fftType backends.FFTType, fftLength []int) (backends.Op, 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 (Builder) Floor

func (b Builder) Floor(x backends.Op) (backends.Op, error)

Floor returns the Op that represents the output of the corresponding operation.

func (Builder) Gather

func (b Builder) Gather(operand backends.Op, startIndices backends.Op, indexVectorAxis int, offsetOutputAxes []int, collapsedSliceAxes []int, startIndexMap []int, sliceSizes []int, indicesAreSorted bool) (backends.Op, 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.

TODO: Add batch support: operandBatchingAxes and startIndicesBatchingAxes.

func (Builder) GreaterOrEqual

func (b Builder) GreaterOrEqual(lhs backends.Op, rhs backends.Op) (backends.Op, error)

GreaterOrEqual performs element-wise comparison, returns boolean results with the same dimensions as input.

func (Builder) GreaterOrEqualTotalOrder

func (b Builder) GreaterOrEqualTotalOrder(lhs backends.Op, rhs backends.Op) (backends.Op, 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 (Builder) GreaterThan

func (b Builder) GreaterThan(lhs backends.Op, rhs backends.Op) (backends.Op, error)

GreaterThan performs element-wise comparison, returns boolean results with the same dimensions as input.

func (Builder) GreaterThanTotalOrder

func (b Builder) GreaterThanTotalOrder(lhs backends.Op, rhs backends.Op) (backends.Op, 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 (Builder) Identity

func (b Builder) Identity(x backends.Op) (backends.Op, error)

func (Builder) Imag

func (b Builder) Imag(x backends.Op) (backends.Op, error)

Imag returns the imaginary part of a complex number. It returns 0 if the x is a float number.

func (Builder) Iota

func (b Builder) Iota(shape shapes.Shape, iotaAxis int) (backends.Op, error)

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 (Builder) IsFinite

func (b Builder) IsFinite(x backends.Op) (backends.Op, error)

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 (Builder) IsNaN added in v0.23.0

func (b Builder) IsNaN(x backends.Op) (backends.Op, error)

IsNaN tests whether each element of operand is NaN, i.e., if it is not a finite number.

func (Builder) LessOrEqual

func (b Builder) LessOrEqual(lhs backends.Op, rhs backends.Op) (backends.Op, error)

LessOrEqual performs element-wise comparison, returns boolean results with the same dimensions as input.

func (Builder) LessOrEqualTotalOrder

func (b Builder) LessOrEqualTotalOrder(lhs backends.Op, rhs backends.Op) (backends.Op, 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 (Builder) LessThan

func (b Builder) LessThan(lhs backends.Op, rhs backends.Op) (backends.Op, error)

LessThan performs element-wise comparison, returns boolean results with the same dimensions as input.

func (Builder) LessThanTotalOrder

func (b Builder) LessThanTotalOrder(lhs backends.Op, rhs backends.Op) (backends.Op, 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 (Builder) Log

func (b Builder) Log(x backends.Op) (backends.Op, error)

Log returns the Op that represents the output of the corresponding operation.

func (Builder) Log1p

func (b Builder) Log1p(x backends.Op) (backends.Op, error)

Log1p returns the expression log(x+1).

func (Builder) LogicalAnd

func (b Builder) LogicalAnd(lhs backends.Op, rhs backends.Op) (backends.Op, error)

LogicalAnd returns the element-wise logical AND operation.

func (Builder) LogicalNot

func (b Builder) LogicalNot(x backends.Op) (backends.Op, error)

LogicalNot returns the Op that represents the output of the corresponding operation.

func (Builder) LogicalOr

func (b Builder) LogicalOr(lhs backends.Op, rhs backends.Op) (backends.Op, error)

LogicalOr returns the element-wise logical OR operation.

func (Builder) LogicalXor

func (b Builder) LogicalXor(lhs backends.Op, rhs backends.Op) (backends.Op, error)

LogicalXor returns the element-wise logical XOR operator.

func (Builder) Logistic

func (b Builder) Logistic(x backends.Op) (backends.Op, error)

Logistic returns the element-wise expression 1/(1+exp(-x)). Also known as the Sigmoid function.

func (Builder) Max

func (b Builder) Max(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Max returns the element-wise highest value among the two.

func (Builder) Min

func (b Builder) Min(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Min returns the element-wise smallest value among the two.

func (Builder) Mul

func (b Builder) Mul(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Mul returns the element-wise multiplication of the two values. Standard broadcasting rules apply (see documentation).

func (Builder) Name

func (b Builder) Name() string

func (Builder) Neg

func (b Builder) Neg(x backends.Op) (backends.Op, error)

Neg returns the Op that represents the output of the corresponding operation.

func (Builder) NotEqual

func (b Builder) NotEqual(lhs backends.Op, rhs backends.Op) (backends.Op, error)

NotEqual performs element-wise inequality check, returns boolean results with the same dimensions as input.

func (Builder) NotEqualTotalOrder

func (b Builder) NotEqualTotalOrder(lhs backends.Op, rhs backends.Op) (backends.Op, 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 (Builder) OpShape

func (b Builder) OpShape(op backends.Op) (shapes.Shape, error)

func (Builder) Pad

func (b Builder) Pad(x backends.Op, fillValue backends.Op, axesConfig ...backends.PadAxis) (backends.Op, 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 (Builder) Parameter

func (b Builder) Parameter(name string, shape shapes.Shape) (backends.Op, error)

func (Builder) Pow

func (b Builder) Pow(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Pow returns the Op that represents the output of the corresponding operation.

func (Builder) Real

func (b Builder) Real(x backends.Op) (backends.Op, error)

Real return the real part of a complex number. It returns x if the x is a float number.

func (Builder) ReduceBitwiseAnd

func (b Builder) ReduceBitwiseAnd(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceBitwiseOr

func (b Builder) ReduceBitwiseOr(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceBitwiseXor

func (b Builder) ReduceBitwiseXor(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceLogicalAnd

func (b Builder) ReduceLogicalAnd(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceLogicalOr

func (b Builder) ReduceLogicalOr(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceLogicalXor

func (b Builder) ReduceLogicalXor(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceMax

func (b Builder) ReduceMax(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceMin

func (b Builder) ReduceMin(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceProduct

func (b Builder) ReduceProduct(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceSum

func (b Builder) ReduceSum(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) ReduceWindow

func (b Builder) ReduceWindow(x backends.Op, reductionType backends.ReduceOpType, windowDimensions, strides, baseDilations, windowDilations []int, paddings [][2]int) (backends.Op, error)

func (Builder) Rem

func (b Builder) Rem(lhs backends.Op, rhs backends.Op) (backends.Op, error)

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 (Builder) Reshape

func (b Builder) Reshape(x backends.Op, dimensions ...int) (backends.Op, error)

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 (Builder) Reverse

func (b Builder) Reverse(x backends.Op, axes ...int) (backends.Op, error)

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 (Builder) RngBitGenerator

func (b Builder) RngBitGenerator(state backends.Op, shape shapes.Shape) (newState, values backends.Op, err error)

func (Builder) Round

func (b Builder) Round(x backends.Op) (backends.Op, error)

Round returns the Op that represents the output of the corresponding operation.

func (Builder) Rsqrt

func (b Builder) Rsqrt(x backends.Op) (backends.Op, error)

Rsqrt returns the element-wise reciprocal of square root operation 1/sqrt(x).

func (Builder) ScatterMax

func (b Builder) ScatterMax(operand backends.Op, scatterIndices backends.Op, updates backends.Op, indexVectorAxis int, updateWindowAxes []int, insertedWindowAxes []int, scatterAxesToOperandAxes []int, indicesAreSorted bool, uniqueIndices bool) (backends.Op, error)

ScatterMax scatter values from updates pointed by scatterIndices to operand, by taking the Max.

func (Builder) ScatterMin

func (b Builder) ScatterMin(operand backends.Op, scatterIndices backends.Op, updates backends.Op, indexVectorAxis int, updateWindowAxes []int, insertedWindowAxes []int, scatterAxesToOperandAxes []int, indicesAreSorted bool, uniqueIndices bool) (backends.Op, error)

ScatterMin scatter values from updates pointed by scatterIndices to operand, by taking the Min.

func (Builder) ScatterSum

func (b Builder) ScatterSum(operand backends.Op, scatterIndices backends.Op, updates backends.Op, indexVectorAxis int, updateWindowAxes []int, insertedWindowAxes []int, scatterAxesToOperandAxes []int, indicesAreSorted bool, uniqueIndices bool) (backends.Op, error)

ScatterSum values from updates pointed by scatterIndices to operand.

func (Builder) SelectAndScatterMax

func (b Builder) SelectAndScatterMax(operand backends.Op, source backends.Op, windowDimensions []int, windowStrides []int, paddings [][2]int) (backends.Op, 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 (Builder) SelectAndScatterMin

func (b Builder) SelectAndScatterMin(operand backends.Op, source backends.Op, windowDimensions []int, windowStrides []int, paddings [][2]int) (backends.Op, 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 (Builder) ShiftLeft

func (b Builder) ShiftLeft(lhs backends.Op, rhs backends.Op) (backends.Op, error)

ShiftLeft n bits. It implicitly preserves the sign bit if there is no overflow. So ShiftLeft(-1, 1) = -2.

func (Builder) ShiftRightArithmetic

func (b Builder) ShiftRightArithmetic(lhs backends.Op, rhs backends.Op) (backends.Op, error)

ShiftRightArithmetic shifts right by n bits, preserving the sign bit. So ShiftRight(-2, 1) = -1.

func (Builder) ShiftRightLogical

func (b Builder) ShiftRightLogical(lhs backends.Op, rhs backends.Op) (backends.Op, error)

ShiftRightLogical shifts right by n bits, destroying the sign bit.

func (Builder) Sign

func (b Builder) Sign(x backends.Op) (backends.Op, error)

Sign returns element-wise +1, +/-0 or -1 depending on the sign of x. It returns NaN if the input is NaN.

func (Builder) Sin

func (b Builder) Sin(x backends.Op) (backends.Op, error)

Sin returns the Op that represents the output of the corresponding operation.

func (Builder) Slice

func (b Builder) Slice(x backends.Op, starts []int, limits []int, strides []int) (backends.Op, 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 (Builder) Sqrt

func (b Builder) Sqrt(x backends.Op) (backends.Op, error)

Sqrt returns the Op that represents the output of the corresponding operation.

func (Builder) Sub

func (b Builder) Sub(lhs backends.Op, rhs backends.Op) (backends.Op, error)

Sub returns the element-wise subtraction of the two values. Standard broadcasting rules apply (see documentation).

func (Builder) Tanh

func (b Builder) Tanh(x backends.Op) (backends.Op, error)

Tanh returns the Op that represents the output of the corresponding operation.

func (Builder) Transpose

func (b Builder) Transpose(x backends.Op, permutation ...int) (backends.Op, error)

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 (Builder) Where

func (b Builder) Where(condition backends.Op, onTrue backends.Op, onFalse backends.Op) (backends.Op, 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL