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

◆ flatten_native_variants_to_staging()

void MayaFlux::Yantra::GpuDispatchCore::flatten_native_variants_to_staging ( const std::vector< Kakshya::DataVariant > &  variants,
const DataStructureInfo &  structure_info 
)
protected

Flatten native-typed DataVariant channels into m_native_staging_bytes without any conversion.

Called by prepare_gpu_inputs when structure_info.original_type indicates a non-double native type and no explicit stage_native_bytes call has been made. Visits the variant's active alternative and memcpys bytes directly.

No-ops when channels is empty or the modality is structured.

Parameters
variantsPer-channel DataVariants from the container.
structure_infoDimension/modality metadata.

Definition at line 534 of file GpuDispatchCore.cpp.

537{
539
540 if (variants.empty() || Kakshya::is_structured_modality(structure_info.modality))
541 return;
542
543 size_t total_bytes = 0;
544 for (const auto& v : variants) {
545 std::visit([&](const auto& vec) {
546 total_bytes += vec.size() * sizeof(typename std::decay_t<decltype(vec)>::value_type);
547 },
548 v);
549 }
550
551 m_native_staging_bytes.reserve(total_bytes);
552
553 for (const auto& v : variants) {
554 std::visit([&](const auto& vec) {
555 using T = typename std::decay_t<decltype(vec)>::value_type;
556 const auto* bytes = reinterpret_cast<const uint8_t*>(vec.data());
559 bytes,
560 bytes + vec.size() * sizeof(T));
561 },
562 v);
563 }
564}
std::vector< uint8_t > m_native_staging_bytes
Native-typed staging buffer.
bool is_structured_modality(DataModality modality)
Check if a modality represents structured data (vectors, matrices).
Definition NDData.hpp:170

References MayaFlux::Kakshya::is_structured_modality(), m_native_staging_bytes, and MayaFlux::Yantra::DataStructureInfo::modality.

Referenced by MayaFlux::Yantra::GpuExecutionContext< InputType, OutputType >::extract_inputs().

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