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
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.
@ 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.
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().