Skip to content

[Feature] Add Image and variable-shape ImageBatch core types#151

Open
zacharyvincze wants to merge 13 commits into
ROCm:developfrom
zacharyvincze:zv/feature/imagebatchvarshape
Open

[Feature] Add Image and variable-shape ImageBatch core types#151
zacharyvincze wants to merge 13 commits into
ROCm:developfrom
zacharyvincze:zv/feature/imagebatchvarshape

Conversation

@zacharyvincze
Copy link
Copy Markdown
Contributor

This PR introduces foundational types for variable-shape image batches.

New core types (include/core/, src/core/):

  • Image / ImageStorage — single-image handle and backing storage
  • ImageData / ImageBuffer — descriptor + raw buffer for a single image
  • ImageBatchData / ImageBatchBuffer — descriptors for batches of heterogeneous images
  • ImageBatchVarShape — user-facing variable-shape batch container

Supporting changes:

  • Minor ImageFormat tweaks
  • New test helpers in image_test_helpers.hpp and a small addition to test_helpers.hpp

Tests (tests/roccv/cpp/src/tests/core/image/): ~1,250 lines covering Image, ImageData, ImageBatchData, and ImageBatchVarShape.

Next Steps:

  • Update kernel visible wrappers to support per-image metadata indexing, as this will be required when dealing with batches of variable-sized images.
  • Implement Resize operator with variable-sized image batch support. This is the lowest cost, highest usage operator since it allows the user to work with variable sized images -> resize to constant sized tensor -> perform remaining operators while existing operators lack variable-sized image batch support.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds foundational C++ core types for representing single images and variable-shape (heterogeneous) image batches, along with a comprehensive new test suite to validate ownership, casting, and export/snapshot behavior.

Changes:

  • Introduces new core runtime types: Image/ImageStorage, ImageData*, ImageBatchData*, and producer container ImageBatchVarShape.
  • Extends ImageFormat to have a constexpr default representing FMT_NONE and adds equality operators.
  • Adds new C++ tests and test helpers for image and variable-shape batch behavior.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/roccv/cpp/src/tests/core/image/test_image.cpp New unit tests for Image requirements, allocation, lifecycle, export, and wrapping.
tests/roccv/cpp/src/tests/core/image/test_image_data.cpp New unit tests for ImageData strided variants and runtime cast behavior.
tests/roccv/cpp/src/tests/core/image/test_image_batch_var_shape.cpp New unit tests for ImageBatchVarShape push/pop/clear/export/move/iteration behavior.
tests/roccv/cpp/src/tests/core/image/test_image_batch_data.cpp New unit tests for ImageBatchData varshape descriptors and cast behavior.
tests/roccv/cpp/include/test_helpers.hpp Adds AsInt/AsAddr/AsSize helpers for safer EXPECT_EQ comparisons.
tests/roccv/cpp/include/image_test_helpers.hpp Adds fake image/buffer builders and a counting allocator for tests.
src/core/image.cpp Implements Image allocation, requirements calculation, export, and wrapping.
src/core/image_data.cpp Implements ImageData/ImageDataStrided* accessors and buffer-kind tagging.
src/core/image_batch_var_shape.cpp Implements ImageBatchVarShape storage, lazy sync, caching, and export.
src/core/image_batch_data.cpp Implements ImageBatchData/varshape accessors and buffer-kind tagging.
include/core/image.hpp Declares the Image handle type, requirements, and ImageWrapData.
include/core/image_storage.hpp Declares refcounted storage holder for Image buffers.
include/core/image_format.hpp Makes default ImageFormat represent FMT_NONE; adds ==/!=.
include/core/image_data.hpp Declares ImageData hierarchy, buffer-kind enum, and cast mechanism.
include/core/image_buffer.hpp Declares plane/strided buffer descriptors and ImageBuffer aggregate.
include/core/image_batch_var_shape.hpp Declares producer-side variable-shape batch container and export APIs.
include/core/image_batch_data.hpp Declares ImageBatchData hierarchy, buffer-kind enum, and accessors.
include/core/image_batch_buffer.hpp Declares varshape batch descriptor buffer layout (ImageBatchVarShapeBufferStrided).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/image.cpp
Comment thread src/core/image.cpp
Comment thread src/core/image.cpp
Comment thread src/core/image_batch_var_shape.cpp
Comment thread include/core/image_batch_var_shape.hpp
Comment thread include/core/image_batch_var_shape.hpp
Comment thread tests/roccv/cpp/include/image_test_helpers.hpp
Comment thread tests/roccv/cpp/src/tests/core/image/test_image.cpp
Comment thread tests/roccv/cpp/include/test_helpers.hpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:precheckin enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants