Contents

class

SushiAI::Shape

Represents tensor extents as a fixed-capacity value type.

Declared in
include/SushiAI/core/shape.hpp

Public member functions

constexpr Shape() noexcept=default

Constructs the rank-0 (scalar) shape.

Shape(std::initializer_list< int64_t > dims)

Constructs from an extent list, e.g.

Shape{batch, features}.

Parameters

dims

The extent of each dimension, outermost first.

Exceptions

Error

If the rank exceeds MAX_RANK or any extent is not positive.

explicit Shape(SushiRuntime::span< const int64_t > dims)

Constructs extents from a runtime span.

Parameters

dims

The extent of each dimension, outermost first.

Exceptions

Error

If the rank exceeds MAX_RANK or any extent is not positive.

constexpr int32_t rank() const noexcept

The number of dimensions; 0 for a scalar.

int64_t dim(int32_t index) const

The extent of one dimension.

Parameters

index

Dimension index; negative counts from the innermost.

Returns

The extent at index.

Exceptions

Error

If index does not name a dimension of this shape.

constexpr int64_t operator[](int32_t index) const noexcept

Unchecked extent access, for hot paths that have already validated.

constexpr int64_t num_elements() const noexcept

The total element count; 1 for a scalar, never zero.

constexpr const int64_t * data() const noexcept

The extents as a contiguous span, for handing to SushiBLAS.

std::string to_string() const

A bracketed rendering such as "[64, 784]", for error messages.

Returns

A freshly built string; not cached.

constexpr std::uint64_t hash() const noexcept

Computes an FNV-1a hash over rank and extents.

Returns

The 64-bit hash value.