Module aegir::buffers

source ·
Expand description

Module for tensor abstractions and their implementations.

aegir is designed to be generic over the concrete Buffer types used by the operators. This has the advantage of flexibility, but also exposes performance advantages; fixed-length arrays, for example, can be optmised much more aggressively in the LLVM compared with arbitrary-length vectors. This does, however, add some complexity.

Type Hierarchy

The type hierarchy exposed by aegir::buffers can broadly be split into three parts: classes, buffers and scalars. Each buffer is a homogeneous collection of numerical values with a given shape and underlying scalar field. A scalar type is a special case of a buffer in which the field is equal to the implementing type itself. For example, Scalar is automatically derived for the f64 primitive since it supports base numerical operations (addition, subtraction, etc…), but also implements Buffer with Buffer::Field assigned to f64. In other words, the Scalar trait defines a fixed point of the type hierarchy. Indeed, since the associated type Buffer::Field has a Scalar constraint, we get a uniqueness property and a unilateral support of Buffer at all levels. Now we understand the relationship between Buffer and Scalar, it remains only to explain the purpose of Class.

Buffer Classes

Types that implement the Class trait are generally used to form a semantic grouping over buffers. For example, Arrays groups together all fixed-length arrays under the same natural umbrella. A given implementation of Class then asserts a unique mapping between a shape-field pair, and a concrete Buffer type (with compatible associated types) within the context of a particular grouping. In other words, there can be only one type associated with Arrays that has said shape and field, and this type can be reached via Class<S, F>::Buffer.

Advantages

Classes afford us the ability to construct new buffers with a particular shape and field without knowing the concrete Buffer type. This yields much greater flexibility and allows us to implement many of the core “source” types with much greater generality. For more information, see e.g. Class::build.

Modules

Module for compile-time and runtime tensor shapes.

Structs

Array buffer class.
Scalar buffer class.
Tuple buffer class.
Vec buffer class.

Enums

A “lifted” buffer representation.

Traits

Trait for container types that have a fixed shape and scalar field.
Marker trait for class subscriptions of Buffer types.
Trait for performing contractions over a pair of tensor buffers.
Trait for types that can be converted into a Spec.
Trait for numeric types implementing basic scalar operations.
Trait for performing a zip and fold over a pair of buffers.
Trait for combining a pair of buffers in an elementwise fashion.
Trait for combining two buffers elementwise and in-place.
Union trait for types implementing ZipFold, ZipMap and ZipMut.

Functions

Return the contraction of two buffers.
Return the shape of the contraction over two buffers.
Return the contraction of two buffers specifications.

Type Definitions

Type alias for Class::Buffer.
Type alias for Buffer::Class.
Type alias for Buffer::Field.