319 const std::vector<uint64_t>& shape,
320 T default_value = T {},
324 auto dims = create_dimensions(modality, shape, layout);
325 auto variants = create_variants(modality, shape, default_value, strategy);
327 return { std::move(variants), std::move(dims) };
420 const std::vector<uint64_t>& shape,
424 std::vector<DataVariant> variants;
426 if (org == OrganizationStrategy::INTERLEAVED) {
427 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
428 variants.emplace_back(std::vector<T>(total, default_value));
433 case DataModality::AUDIO_1D:
434 variants.emplace_back(std::vector<T>(shape[0], default_value));
437 case DataModality::AUDIO_MULTICHANNEL: {
438 uint64_t samples = shape[0];
439 uint64_t channels = shape[1];
440 variants.reserve(channels);
441 for (uint64_t ch = 0; ch < channels; ++ch) {
442 variants.emplace_back(std::vector<T>(samples, default_value));
447 case DataModality::IMAGE_2D:
448 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
451 case DataModality::IMAGE_COLOR: {
452 uint64_t height = shape[0];
453 uint64_t
width = shape[1];
454 uint64_t channels = shape[2];
456 variants.reserve(channels);
457 for (uint64_t ch = 0; ch < channels; ++ch) {
458 variants.emplace_back(std::vector<T>(
pixels, default_value));
463 case DataModality::SPECTRAL_2D:
464 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
467 case DataModality::VOLUMETRIC_3D:
468 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
471 case DataModality::VIDEO_GRAYSCALE: {
472 uint64_t frames = shape[0];
473 uint64_t height = shape[1];
474 uint64_t
width = shape[2];
475 uint64_t frame_size = height *
width;
476 variants.reserve(frames);
477 for (uint64_t f = 0; f < frames; ++f) {
478 variants.emplace_back(std::vector<T>(frame_size, default_value));
483 case DataModality::VIDEO_COLOR: {
484 uint64_t frames = shape[0];
485 uint64_t height = shape[1];
486 uint64_t
width = shape[2];
487 uint64_t channels = shape[3];
488 uint64_t frame_size = height *
width;
489 variants.reserve(frames * channels);
490 for (uint64_t f = 0; f < frames; ++f) {
491 for (uint64_t ch = 0; ch < channels; ++ch) {
492 variants.emplace_back(std::vector<T>(frame_size, default_value));
499 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
500 variants.emplace_back(std::vector<T>(total, default_value));