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

◆ allocate()

std::optional< TensorData > MayaFlux::Kakshya::TensorData::allocate ( TensorSpec spec)
staticnodiscard

Zero-filled tensor for a spec.

Returns
Tensor, or std::nullopt when the spec is inconsistent or not host memory.

Definition at line 72 of file Tensor.cpp.

73{
74 if (const auto reason = spec.diagnose(); !reason.empty()) {
76 "TensorData::allocate: {}", reason);
77 return std::nullopt;
78 }
79 if (!spec.device.is_host_accessible()) {
81 "TensorData::allocate: tensor '{}' is not host memory", spec.name);
82 return std::nullopt;
83 }
84
85 const auto range = spec.byte_range();
86 TensorData result;
87 result.m_size = static_cast<size_t>(range->second);
88 result.m_data = allocate_block(result.m_size);
89 result.m_spec = std::move(spec);
90 return result;
91}
#define MF_ERROR(comp, ctx,...)
const TensorSpec & spec() const noexcept
Layout of the stored bytes.
Definition Tensor.hpp:105
@ Runtime
General runtime operations (default fallback).
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::vector< double > range(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Value range (max - min) per window.
Definition Analysis.cpp:473

References MayaFlux::Journal::Kakshya, m_data, m_size, m_spec, MF_ERROR, MayaFlux::Journal::Runtime, spec(), and TensorData().

Referenced by MayaFlux::Kakshya::TensorContainer::clear(), MayaFlux::Kakshya::convert_tensor(), copy_of(), from_bytes(), MayaFlux::IO::NpyReader::read(), MayaFlux::IO::NpzReader::read(), MayaFlux::IO::RawTensorReader::read(), MayaFlux::IO::SafetensorsReader::read(), MayaFlux::Kakshya::TensorInsertion::resize(), MayaFlux::Kakshya::TensorContainer::TensorContainer(), and ~TensorData().

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