Create dimension descriptors for a data modality.
159{
160 std::vector<DataDimension> dims;
162
163 switch (modality) {
165 if (shape.size() != 1) {
166 error<std::invalid_argument>(
169 std::source_location::current(),
170 "AUDIO_1D requires 1D shape");
171 }
173 break;
174
176 if (shape.size() != 2) {
177 error<std::invalid_argument>(
180 std::source_location::current(),
181 "AUDIO_MULTICHANNEL requires 2D shape [samples, channels]");
182 }
185 break;
186
188 if (shape.size() != 2) {
189 error<std::invalid_argument>(
192 std::source_location::current(),
193 "IMAGE_2D requires 2D shape [height, width]");
194 }
197 break;
198
200 if (shape.size() != 3) {
201 error<std::invalid_argument>(
204 std::source_location::current(),
205 "IMAGE_COLOR requires 3D shape [height, width, channels]");
206 }
210 break;
211
213 if (shape.size() != 4) {
214 error<std::invalid_argument>(
217 std::source_location::current(),
218 "IMAGE_COLOR_ARRAY requires 4D shape [frames, height, width, channels]");
219 }
224 break;
225
227 if (shape.size() != 3) {
228 error<std::invalid_argument>(
231 std::source_location::current(),
232 "DEPTH_MAP requires 3D shape [height, width, components]");
233 }
237 break;
238
240 if (shape.size() != 2) {
241 error<std::invalid_argument>(
244 std::source_location::current(),
245 "SPECTRAL_2D requires 2D shape [time_windows, frequency_bins]");
246 }
249 dims[1].stride = strides[1];
250 break;
251
253 if (shape.size() != 3) {
254 error<std::invalid_argument>(
257 std::source_location::current(),
258 "VOLUMETRIC_3D requires 3D shape [x, y, z]");
259 }
263 break;
264
266 if (shape.size() != 3) {
267 error<std::invalid_argument>(
270 std::source_location::current(),
271 "VIDEO_GRAYSCALE requires 3D shape [frames, height, width]");
272 }
276 break;
277
279 if (shape.size() != 4) {
280 error<std::invalid_argument>(
283 std::source_location::current(),
284 "VIDEO_COLOR requires 4D shape [frames, height, width, channels]");
285 }
290 break;
291
293 if (shape.size() != 4) {
294 error<std::invalid_argument>(
297 std::source_location::current(),
298 "VIDEO_DEPTH requires 4D shape [frames, height, width, components]");
299 }
304 break;
305
306 default:
307 error<std::invalid_argument>(
310 std::source_location::current(),
312 }
313
314 return dims;
315}
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
@ DEPTH_MAP
[height, width, components] - range/disparity image
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ AUDIO_1D
1D audio signal
@ VIDEO_DEPTH
[frames, height, width, components] - streaming range data
@ IMAGE_COLOR_ARRAY
4D (idx + 2D + color)
@ VOLUMETRIC_3D
3D volumetric data
@ VIDEO_GRAYSCALE
3D video (time + 2D grayscale)
@ VIDEO_COLOR
4D video (time + 2D + color)
@ IMAGE_COLOR
2D RGB/RGBA image
@ IMAGE_2D
2D image (grayscale or single channel)
std::string_view modality_to_string(DataModality modality)
Convert DataModality enum to string representation.
static DataDimension spatial(uint64_t size, char axis, uint64_t stride=1, std::string name="spatial")
Convenience constructor for a spatial dimension.
static DataDimension frequency(uint64_t bins, std::string name="frequency")
Convenience constructor for a frequency dimension.
static DataDimension time(uint64_t samples, std::string name="time")
Convenience constructor for a temporal (time) dimension.
static std::vector< uint64_t > calculate_strides(const std::vector< uint64_t > &shape, MemoryLayout layout)
Calculate memory strides based on shape and layout.
static DataDimension depth(uint64_t count=1, uint64_t stride=1)
Convenience constructor for a depth dimension.
static DataDimension channel(uint64_t count, uint64_t stride=1)
Convenience constructor for a channel dimension.