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
Structs
Enums
Traits
ZipFold
, ZipMap
and ZipMut
.