Contents

namespace

SushiAI

Declared in
include/SushiAI/autograd/backward.hpp

Contains

Typedefs

using SushiAI::DType = SushiBLAS::Core::DataType

The element type of a tensor.

An alias, not a parallel enum: SushiAI performs no arithmetic of its own, so the set of types it can express is exactly the set SushiBLAS can compute on.

using SushiAI::Layout = SushiBLAS::Core::Layout

The memory layout of a tensor, aliased from SushiBLAS for the same reason.

using SushiAI::OpID = SushiRuntime::Graph::OpID

The runtime's operation-identity type, aliased for brevity.

Variables

constexpr int32_t MAX_RANK = static_cast<int32_t>(SushiBLAS::Core::MAX_TENSOR_RANK)

Maximum tensor rank, fixed by SushiBLAS's own storage of shape and strides.

Functions

SushiBLAS::Tensor allocate_tensor(SushiBLAS::Engine &engine, SushiRuntime::span< const int64_t > dims, DType dtype=DType::FLOAT32)

Allocates a tensor of dims with its own Storage.

Parameters

engine

The engine whose context owns the allocator.

dims

The extents, outermost first.

dtype

The element type.

Returns

The new tensor with standalone storage.

Exceptions

Error

If an extent is invalid or allocation fails.

SushiBLAS::Tensor allocate_tensor(SushiBLAS::Engine &engine, const Shape &shape, DType dtype=DType::FLOAT32)

Allocates a tensor of shape with its own Storage.

Parameters

engine

The engine whose context owns the allocator.

shape

The extents.

dtype

The element type.

Returns

The new tensor; nothing else references its Storage.

Exceptions

Error

As the span overload does.

SushiBLAS::Tensor allocate_like(SushiBLAS::Engine &engine, const SushiBLAS::Tensor &like)

Allocates a tensor with like's extents, dtype, and layout.

Parameters

engine

The engine whose context owns the allocator.

like

The tensor to copy the description from.

Returns

The new tensor; it shares nothing with like.

Exceptions

Error

If like holds no elements, or the allocation fails.

SushiRuntime::sushi_ptr< SushiBLAS::Storage > allocate_arena(SushiBLAS::Engine &engine, std::size_t bytes)

Allocates one arena buffer for memory planning.

Parameters

engine

The engine whose context owns the allocator.

bytes

Number of bytes the arena holds; must be positive.

Returns

The newly allocated storage.

Exceptions

Error

If bytes is zero or allocation fails.

SushiBLAS::Tensor view_tensor(SushiBLAS::Engine &engine, const SushiRuntime::sushi_ptr< SushiBLAS::Storage > &arena, std::size_t byte_offset, const Shape &shape, DType dtype)

Returns a tensor view into arena at byte_offset.

Parameters

engine

The engine whose default layout the view takes.

arena

Storage to carve from; must outlive the view.

byte_offset

Offset in bytes; must be aligned to element width.

Exceptions

Error

If offset is misaligned or out of bounds.

constexpr std::size_t dtype_size(DType dtype) noexcept

Returns the size in bytes occupied by one element of dtype.

Parameters

dtype

The element type to size.

Returns

The element's size in bytes; never zero.

constexpr const char * dtype_name(DType dtype) noexcept

A human-readable name for dtype, for diagnostics and error text.

Parameters

dtype

The element type to name.

Returns

A null-terminated literal owned by the library; never null.

constexpr bool is_real_float(DType dtype) noexcept

Reports whether dtype is a real floating-point type.

Parameters

dtype

The element type to test.

Returns

True for HALF, FLOAT32, and FLOAT64; false otherwise.

const char * version_string() noexcept

Returns the library version string.

Returns

A null-terminated literal owned by the library; never null.