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

◆ assign_window()

bool MayaFlux::Kakshya::TensorInsertion::assign_window ( const Region & region,
const TensorAccess & view )

Overwrite the box a Region selects with a view of the box's shape.

Strided views are gathered first, so the source may alias this tensor.

Returns
False for a dtype mismatch, a shape that differs from the box, an invalid region, or a sub-byte type unless the region covers the whole tensor.

Definition at line 66 of file TensorInsertion.cpp.

67{
68 const auto& spec = m_tensor->m_spec;
69 if (view.spec().dtype != spec.dtype || !m_tensor->is_valid())
70 return false;
71
72 const auto target = spec.window(region);
73 if (!target || target->shape != view.spec().shape)
74 return false;
75 if (spec.dtype.is_sub_byte())
76 return assign(view);
77
78 const auto range = target->byte_range();
79 if (!range || range->second > m_tensor->m_size)
80 return false;
81
82 const auto copy = TensorData::copy_of(view);
83 if (!copy)
84 return false;
85 const auto source = copy->access();
86 if (!source)
87 return false;
88
89 scatter(m_tensor->m_data.get() + target->byte_offset, *target, source->element_data());
90 return true;
91}
static std::optional< TensorData > copy_of(const TensorAccess &view)
Dense C-ordered copy of any tensor view.
Definition Tensor.cpp:126
bool assign(const TensorAccess &view)
Overwrite the tensor with a copy of a view of the same dtype and shape.
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
Source source()
Begin a Source chain.
Definition Plot.hpp:127
CopiedText copy(std::string_view text, const LayoutResult &layout, size_t a, size_t b)
Copy a byte range: the text it spans, and the quads that render it.

References assign(), MayaFlux::Kakshya::TensorData::copy_of(), MayaFlux::Kakshya::TensorSpec::dtype, m_tensor, MayaFlux::Kakshya::TensorSpec::shape, and MayaFlux::Kakshya::TensorAccess::spec().

Referenced by MayaFlux::Kakshya::TensorContainer::set_region_data().

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