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

◆ assign()

bool MayaFlux::Kakshya::TensorInsertion::assign ( const TensorAccess & view)

Overwrite the tensor with a copy of a view of the same dtype and shape.

Strided views are gathered into the tensor's own layout.

Definition at line 45 of file TensorInsertion.cpp.

46{
47 const auto& spec = m_tensor->m_spec;
48 if (view.spec().dtype != spec.dtype || view.spec().shape != spec.shape || !m_tensor->is_valid())
49 return false;
50
51 const auto copy = TensorData::copy_of(view);
52 if (!copy)
53 return false;
54
55 const auto source = copy->access();
56 if (!source)
57 return false;
58
59 if (spec.is_contiguous())
60 return write_bytes(source->bytes());
61
62 scatter(m_tensor->m_data.get() + spec.byte_offset, spec, source->element_data());
63 return true;
64}
static std::optional< TensorData > copy_of(const TensorAccess &view)
Dense C-ordered copy of any tensor view.
Definition Tensor.cpp:126
bool write_bytes(std::span< const std::byte > bytes, uint64_t byte_offset=0)
Write raw bytes into the elements of a dense tensor.
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 MayaFlux::Kakshya::TensorData::copy_of(), MayaFlux::Kakshya::TensorSpec::dtype, m_tensor, MayaFlux::Kakshya::TensorSpec::shape, MayaFlux::Kakshya::TensorAccess::spec(), and write_bytes().

Referenced by assign_window().

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