| EinopsBackend | R Documentation |
Abstract base class that defines the interface for tensor operations across different frameworks. All backend implementations must inherit from this class and implement the required methods.
new()Initialize the backend and check for required packages. It is assumed that the constructor will fully load and setup all dependencies and error otherwise.
EinopsBackend$new()
A new EinopsBackend instance.
print()The print method for EinopsBackend instances
EinopsBackend$print(...)
...arguments passed to pprint()
This object, invisibly
repr()Get a string representation of this backend.
EinopsBackend$repr()
A character string describing the backend.
tensor_type()Get the type of tensor this backend supports. This method should be overridden in subclasses to return the specific tensor type (e.g., "torch_tensor", "array").
EinopsBackend$tensor_type()
A string representing the tensor type.
preprocess()Do any relevant preprocessing of a tensor before any operations are done on it. This should always be called before running any backend operations on a tensor
EinopsBackend$preprocess(x)
xThe input raw tensor-like object
A preprocessed version of the input, may or may not have changed classes
create_tensor()Create a tensor of the specified type with given values and dimensions.
EinopsBackend$create_tensor(values, dims, ...)
valuesA vector of values to initialize the tensor.
dimsA numeric vector specifying the dimensions of the tensor.
...Additional arguments for specific backend implementations.
A tensor of the specified type.
as_array()Convert a tensor to a standard base::array()
EinopsBackend$as_array(x)
xThe input tensor/array.
A standard array representation of the tensor.
flatten()Return a flattened version of the tensor. Note that the order of calling as_array and flatten does matter because different frameworks may store data differently.
EinopsBackend$flatten(x)
xThe input tensor/array
A 1 dimensional tensor
arange()EinopsBackend$arange(start, stop)
startinteger, inclusive
stopinteger, inclusive
a sequence from start to stop
shape()Get the shape of a tensor. Shape should return a tuple with integers or "shape symbols" (which will evaluate to actual size).
EinopsBackend$shape(x)
xThe input tensor/array.
A numeric vector representing the tensor shape.
reshape()Reshape a tensor to the specified dimensions.
EinopsBackend$reshape(x, shape)
xThe input tensor/array.
shapeA numeric vector specifying the new shape.
The reshaped tensor/array.
transpose()Transpose a tensor along the specified axes.
EinopsBackend$transpose(x, axes)
xThe input tensor/array.
axesA numeric vector specifying the new axis order.
The transposed tensor/array.
reduce()Reduce a tensor along specified axes using the given operation.
EinopsBackend$reduce(x, operation, axes)
xThe input tensor/array.
operationA character string specifying the reduction operation (e.g., "sum", "mean", "max", "min", "prod", "all", "any"), OR a two argument function, with the first argument being the tensor to modify, and the second argument being an integer list of axes to perform the reduction over.
axesA numeric vector specifying which axes to reduce over.
The reduced tensor/array.
stack_on_zeroth_dimension()Stack multiple tensors along a new zeroth dimension.
EinopsBackend$stack_on_zeroth_dimension(tensors)
tensorsA list of tensors/arrays to stack.
A tensor/array with the input tensors stacked along dimension 1.
add_axis()Add a new axis to a tensor at the specified position.
EinopsBackend$add_axis(x, new_position)
xThe input tensor/array.
new_positionThe position (1-based) where to insert the new axis.
The tensor/array with a new axis added.
add_axes()Add multiple axes to a tensor and tile along specified axes.
This function adds new axes to the input tensor at the specified positions and tiles the tensor along those axes according to the provided lengths.
EinopsBackend$add_axes(x, n_axes, pos2len)
xThe input tensor/array.
n_axesThe total number of axes after addition.
pos2lenint->int r2r::hashmap() mapping positions to lengths.
The tensor/array with new axes added and tiled as specified.
tile()Tile (repeat) a tensor along each axis according to the repeat counts. The repeats vector should have the same length as the tensor's shape.
EinopsBackend$tile(x, repeats)
xThe input tensor/array.
repeatsA numeric vector specifying how many times to repeat along each axis. Must have same length as x.shape.
The tiled tensor/array.
concat()Concatenate tensors along the specified axis. Assumes identical devices, dtypes and shapes except for the selected axis.
EinopsBackend$concat(tensors, axis)
tensorsA list of tensors/arrays to concatenate.
axisThe axis along which to concatenate (1-based).
The concatenated tensor/array.
is_float_type()Check if the tensor has a floating point data type.
EinopsBackend$is_float_type(x)
xThe input tensor/array.
A logical value indicating if the tensor is of float type.
layers()Get neural network layers specific to this backend.
EinopsBackend$layers()
Backend-specific layer implementations.
einsum()Perform Einstein summation on tensors.
EinopsBackend$einsum(pattern, ...)
patternA character string specifying the einsum pattern.
...Additional tensors to operate on.
The result of the einsum operation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.