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

◆ collect_gpu_outputs()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
virtual output_type MayaFlux::Yantra::GpuExecutionContext< InputType, OutputType >::collect_gpu_outputs ( const GpuChannelResult raw,
const std::vector< std::vector< double > > &  channels,
const DataStructureInfo structure_info 
)
inlineprotectedvirtual

Reconstruct Datum<OutputType> from a GpuChannelResult.

Reads the primary float readback into per-channel doubles and delegates to OperationHelper::reconstruct_from_double. Aux entries are forwarded into result.metadata keyed as "gpu_output_N".

Override to perform custom readback interpretation, e.g. when the output buffer layout does not match the input channel structure.

Parameters
rawReadback produced by dispatch_core or dispatch_core_chained.
channelsDouble channels extracted from the input Datum.
structure_infoDimension/modality metadata.

Reimplemented in MayaFlux::Yantra::TextureExecutionContext.

Definition at line 116 of file GpuExecutionContext.hpp.

120 {
121 output_type result;
122
123 const size_t total_ch_elements = std::accumulate(
124 channels.begin(), channels.end(), size_t { 0 },
125 [](size_t s, const auto& ch) { return s + ch.size(); });
126
127 if (!raw.primary.empty() && !channels.empty()
128 && raw.primary.size() >= total_ch_elements) {
129 size_t offset = 0;
130 std::vector<std::vector<double>> result_ch(channels.size());
131 for (size_t c = 0; c < channels.size(); ++c) {
132 result_ch[c].resize(channels[c].size());
133 for (size_t i = 0; i < channels[c].size(); ++i)
134 result_ch[c][i] = static_cast<double>(raw.primary[offset++]);
135 }
136 result = Datum<OutputType>(
137 OperationHelper::reconstruct_from_double<OutputType>(result_ch, structure_info));
138 }
139
140 for (const auto& [idx, bytes] : raw.aux)
141 result.metadata["gpu_output_" + std::to_string(idx)] = bytes;
142
143 return result;
144 }
Range size
constexpr std::string_view to_string(EventType type)
Converts an EventType to its string representation.
Definition EventBus.hpp:28

References MayaFlux::Yantra::GpuChannelResult::aux, MayaFlux::Yantra::Datum< T >::metadata, MayaFlux::Yantra::GpuChannelResult::primary, and size.