MayaFlux 0.5.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 507 of file GpuDispatchCore.cpp.

510{
512
513 if (variants.empty() || Kakshya::is_structured_modality(structure_info.modality))
514 return;
515
516 size_t total_bytes = 0;
517 for (const auto& v : variants) {
518 std::visit([&](const auto& vec) {
519 total_bytes += vec.size() * sizeof(typename std::decay_t<decltype(vec)>::value_type);
520 },
521 v);
522 }
523
524 m_native_staging_bytes.reserve(total_bytes);
525
526 for (const auto& v : variants) {
527 std::visit([&](const auto& vec) {
528 using T = typename std::decay_t<decltype(vec)>::value_type;
529 const auto* bytes = reinterpret_cast<const uint8_t*>(vec.data());
532 bytes,
533 bytes + vec.size() * sizeof(T));
534 },
535 v);
536 }
537}
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:200

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: