29 std::span<const std::byte> storage,
const TensorSpec& spec,
bool read_only =
true);
54 [[nodiscard]] std::span<const std::byte>
storage() const noexcept {
return m_storage; }
56 [[nodiscard]]
const std::byte* element_data() const noexcept;
58 [[nodiscard]] uint64_t element_count() const noexcept;
64 [[nodiscard]]
std::span<const
std::
byte> bytes() const noexcept;
73 [[nodiscard]]
std::span<const T>
as() const noexcept
77 const auto raw =
bytes();
78 if (raw.empty() ||
reinterpret_cast<uintptr_t
>(raw.data()) %
alignof(T) != 0)
80 return { reinterpret_cast<const T*>(raw.data()), raw.size() / sizeof(T) };
94 std::span<const std::byte>,
const TensorSpec&,
bool);
std::span< const T > as() const noexcept
Elements as a typed span.
bool read_only() const noexcept
Whether writers must treat the memory as immutable.
TensorAccess(std::span< const std::byte > storage, TensorSpec spec, bool read_only)
std::span< const std::byte > bytes() const noexcept
Bytes of the elements when they are dense in C order.
std::span< const std::byte > m_storage
const TensorSpec & spec() const noexcept
Layout of the borrowed memory.
std::span< const std::byte > storage() const noexcept
The whole borrowed region.
std::vector< DataDimension > dimensions() const
Dimension descriptors with sizes and strides from the spec.
Validated, non-owning view of tensor memory and its layout.
A C++ scalar or std::complex that maps to a TensorDType.
std::optional< TensorAccess > as_tensor_access(std::span< const std::byte > storage, const TensorSpec &spec, bool read_only)
Validate and borrow tensor memory.
Minimal dimension descriptor focusing on structure only.
std::optional< GpuDataFormat > format
Pointer, byte count and element format for uploading a tensor.
Complete description of a tensor: type, shape, layout, meaning.