MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ as()

template<TensorElement T>
std::span< const T > MayaFlux::Kakshya::TensorAccess::as ( ) const
inlinenodiscardnoexcept

Elements as a typed span.

Template Parameters
TElement type that equals the tensor dtype exactly.
Returns
Span over the elements, or empty on a dtype mismatch, a strided layout or a misaligned address.

Definition at line 73 of file TensorAccess.hpp.

74 {
75 if (!m_spec.dtype.is<T>())
76 return {};
77 const auto raw = bytes();
78 if (raw.empty() || reinterpret_cast<uintptr_t>(raw.data()) % alignof(T) != 0)
79 return {};
80 return { reinterpret_cast<const T*>(raw.data()), raw.size() / sizeof(T) };
81 }
std::span< const std::byte > bytes() const noexcept
Bytes of the elements when they are dense in C order.

References as(), bytes(), and m_spec.

Referenced by as().

Here is the call graph for this function:
Here is the caller graph for this function: