315 const std::vector<uint64_t>& shape,
316 T default_value = T {},
320 auto dims = create_dimensions(modality, shape, layout);
321 auto variants = create_variants(modality, shape, default_value, strategy);
323 return { std::move(variants), std::move(dims) };
416 const std::vector<uint64_t>& shape,
420 std::vector<DataVariant> variants;
422 if (org == OrganizationStrategy::INTERLEAVED) {
423 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
424 variants.emplace_back(std::vector<T>(total, default_value));
429 case DataModality::AUDIO_1D:
430 variants.emplace_back(std::vector<T>(shape[0], default_value));
433 case DataModality::AUDIO_MULTICHANNEL: {
434 uint64_t samples = shape[0];
435 uint64_t channels = shape[1];
436 variants.reserve(channels);
437 for (uint64_t ch = 0; ch < channels; ++ch) {
438 variants.emplace_back(std::vector<T>(samples, default_value));
443 case DataModality::IMAGE_2D:
444 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
447 case DataModality::IMAGE_COLOR: {
448 uint64_t height = shape[0];
449 uint64_t width = shape[1];
450 uint64_t channels = shape[2];
451 uint64_t pixels = height * width;
452 variants.reserve(channels);
453 for (uint64_t ch = 0; ch < channels; ++ch) {
454 variants.emplace_back(std::vector<T>(pixels, default_value));
459 case DataModality::SPECTRAL_2D:
460 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
463 case DataModality::VOLUMETRIC_3D:
464 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
467 case DataModality::VIDEO_GRAYSCALE: {
468 uint64_t frames = shape[0];
469 uint64_t height = shape[1];
470 uint64_t width = shape[2];
471 uint64_t frame_size = height * width;
472 variants.reserve(frames);
473 for (uint64_t f = 0; f < frames; ++f) {
474 variants.emplace_back(std::vector<T>(frame_size, default_value));
479 case DataModality::VIDEO_COLOR: {
480 uint64_t frames = shape[0];
481 uint64_t height = shape[1];
482 uint64_t width = shape[2];
483 uint64_t channels = shape[3];
484 uint64_t frame_size = height * width;
485 variants.reserve(frames * channels);
486 for (uint64_t f = 0; f < frames; ++f) {
487 for (uint64_t ch = 0; ch < channels; ++ch) {
488 variants.emplace_back(std::vector<T>(frame_size, default_value));
495 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
496 variants.emplace_back(std::vector<T>(total, default_value));