Create dimension descriptors for a data modality.
140{
141 std::vector<DataDimension> dims;
143
144 switch (modality) {
146 if (shape.size() != 1) {
147 error<std::invalid_argument>(
150 std::source_location::current(),
151 "AUDIO_1D requires 1D shape");
152 }
154 break;
155
157 if (shape.size() != 2) {
158 error<std::invalid_argument>(
161 std::source_location::current(),
162 "AUDIO_MULTICHANNEL requires 2D shape [samples, channels]");
163 }
166 break;
167
169 if (shape.size() != 2) {
170 error<std::invalid_argument>(
173 std::source_location::current(),
174 "IMAGE_2D requires 2D shape [height, width]");
175 }
178 break;
179
181 if (shape.size() != 3) {
182 error<std::invalid_argument>(
185 std::source_location::current(),
186 "IMAGE_COLOR requires 3D shape [height, width, channels]");
187 }
191 break;
192
194 if (shape.size() != 4) {
195 error<std::invalid_argument>(
198 std::source_location::current(),
199 "IMAGE_COLOR_ARRAY requires 4D shape [frames, height, width, channels]");
200 }
205 break;
206
208 if (shape.size() != 2) {
209 error<std::invalid_argument>(
212 std::source_location::current(),
213 "SPECTRAL_2D requires 2D shape [time_windows, frequency_bins]");
214 }
217 dims[1].stride = strides[1];
218 break;
219
221 if (shape.size() != 3) {
222 error<std::invalid_argument>(
225 std::source_location::current(),
226 "VOLUMETRIC_3D requires 3D shape [x, y, z]");
227 }
231 break;
232
234 if (shape.size() != 3) {
235 error<std::invalid_argument>(
238 std::source_location::current(),
239 "VIDEO_GRAYSCALE requires 3D shape [frames, height, width]");
240 }
244 break;
245
247 if (shape.size() != 4) {
248 error<std::invalid_argument>(
251 std::source_location::current(),
252 "VIDEO_COLOR requires 4D shape [frames, height, width, channels]");
253 }
258 break;
259
260 default:
261 error<std::invalid_argument>(
264 std::source_location::current(),
266 }
267
268 return dims;
269}
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ AUDIO_1D
1D audio signal
@ 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 channel(uint64_t count, uint64_t stride=1)
Convenience constructor for a channel dimension.