Validate and borrow tensor memory.
9{
10 if (
const auto reason =
spec.diagnose(); !reason.empty()) {
12 "as_tensor_access: {}", reason);
13 return std::nullopt;
14 }
15 if (!
spec.device.is_host_accessible()) {
17 "as_tensor_access: tensor '{}' lives on a device the host cannot read",
spec.name);
18 return std::nullopt;
19 }
20
24 "as_tensor_access: tensor '{}' needs {} bytes but {} are available",
26 return std::nullopt;
27 }
28
30}
#define MF_ERROR(comp, ctx,...)
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)
const TensorSpec & spec() const noexcept
Layout of the borrowed memory.
std::span< const std::byte > storage() const noexcept
The whole borrowed region.
@ 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.