Skip to content

[Feature] rocCV + MIGraphX classification sample#149

Open
zacharyvincze wants to merge 21 commits intoROCm:developfrom
zacharyvincze:zv/feature/migraphx-classification
Open

[Feature] rocCV + MIGraphX classification sample#149
zacharyvincze wants to merge 21 commits intoROCm:developfrom
zacharyvincze:zv/feature/migraphx-classification

Conversation

@zacharyvincze
Copy link
Copy Markdown
Contributor

Description

This PR adds an MIGraphX image classification sample to demonstrate interoperability between rocCV (as the image preprocessor) and MIGraphX as the inference engine. Also in this PR are some quality of life improvements to the Python bindings.

Technical Details

Sample Application

  • Added rocCV + MIGraphX Python image classification sample.

Changes to Python Bindings

  • Swapped dtype and layout in rocpycv.Tensor constructors to match existing computer vision libraries.
  • dtype parameters now accept numpy scalar types (e.g. np.uint8).
  • layout parameters now accept string representations (e.g. "NHWC").
  • Underlying tensor address can now be exposed using rocpycv.Tensor.data_ptr() to facilitate interoperability with other ROCm libraries such as MIGraphX.
  • Underlying hipStream_t reference can now be exposed using rocpycv.Stream.handle().
  • General improvements to documentation and the python stubs.

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

Adds a GPU image-classification sample demonstrating rocCV preprocessing feeding directly into MIGraphX (zero-copy via raw GPU pointer + shared HIP stream), alongside Python-binding ergonomics improvements (dtype/layout flexibility, interop helpers) and corresponding Python test updates.

Changes:

  • Added new Python classification samples: MIGraphX (ONNX) and PyTorch (ResNet50).
  • Updated Python bindings to accept NumPy dtypes and layout strings, reordered Tensor ctor args, and exposed Tensor.data_ptr() + Stream.handle().
  • Updated existing Python operator tests to use the new Tensor constructor argument order.

Reviewed changes

Copilot reviewed 34 out of 36 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/roccv/python/test_op_warp_perspective.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_warp_affine.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_thresholding.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_rotate.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_resize.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_remap.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_reformat.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_normalize.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_non_max_suppression.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_histogram.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_gamma_contrast.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_flip.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_cvt_color.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_custom_crop.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_copy_make_border.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_convert_to.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_composite.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_center_crop.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_bnd_box.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_bilateral_filter.py Update Tensor(...) ctor arg order in test.
tests/roccv/python/test_op_adv_cvt_color.py Update Tensor(...) ctor arg order in test.
samples/pytorch-classification/pytorch_classification.py New sample: rocCV preprocessing + PyTorch inference.
samples/pytorch-classification/README.md Docs for the PyTorch sample.
samples/migraphx-classification/migraphx_classification.py New sample: rocCV preprocessing + MIGraphX inference, zero-copy buffer + shared stream.
samples/migraphx-classification/README.md Docs for MIGraphX sample usage + interop details.
python/src/rocpycv.pyi Updated stubs/docs, new interop methods, relaxed dtype/layout typing.
python/src/py_tensor.cpp Reordered ctor args; accept NumPy dtype/layout strings; add data_ptr; update reshape/from_dlpack to accept layout strings.
python/src/py_stream.cpp Add Stream.handle() returning hipStream_t as integer.
python/src/py_helpers.cpp Add LayoutFromPyObject / DataTypeFromPyObject parsing helpers.
python/src/py_enums.cpp Adjust exported Python enums (notably eDataType).
python/src/operators/py_op_reformat.cpp Allow reformat(..., out_layout) to accept layout strings.
python/src/operators/py_op_convert_to.cpp Allow convert_to(..., dtype) to accept NumPy dtype/scalar types.
python/src/main.cpp Expanded module docstring/quick-start documentation.
python/include/py_tensor.hpp Match ctor arg reorder; declare getDataPtr.
python/include/py_stream.hpp Declare getHandle.
python/include/py_helpers.hpp Declare new dtype/layout parsing helpers.

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

Comment thread python/src/py_tensor.cpp
Comment thread tests/roccv/python/test_op_bnd_box.py Outdated
Comment thread python/src/py_enums.cpp
Comment thread python/src/py_tensor.cpp
Comment thread python/src/py_stream.cpp
Comment thread python/src/rocpycv.pyi
@zacharyvincze
Copy link
Copy Markdown
Contributor Author

Added additional tests for PyStream/PyTensor since they've added functionality.

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