Skip to content

Tensor-Tensor Broadcasting in 1/2/3/ND for Bitwise operations#682

Merged
kiritigowda merged 99 commits intoROCm:developfrom
r-abishek:ar/broadcasting_tensor_bitwise
Mar 27, 2026
Merged

Tensor-Tensor Broadcasting in 1/2/3/ND for Bitwise operations#682
kiritigowda merged 99 commits intoROCm:developfrom
r-abishek:ar/broadcasting_tensor_bitwise

Conversation

@r-abishek
Copy link
Copy Markdown
Member

@r-abishek r-abishek commented Feb 27, 2026

This PR adds Tensor-Tensor Broadcasting functionality support for Bitwise operations HIP/HOST backend.

  • This function can compute bitwise operations (AND/OR/XOR) between two 2D, 3D or upto ND tensors with broadcasting support.
    • tensor_and_tensor()
    • tensor_or_tensor()
    • tensor_xor_tensor()
  • Broadcasting is permitted when, for each axis, the corresponding dimensions of the input tensors are either equal or one of them is 1.
  • Support is available for bitwise operations for all nDims with specific optimized kernels for nDim = 1, 2, and 3 on HOST and HIP Backends
  • Contains support for various new integer bit depths (I8, U8, I16, U16, I32, U32)
  • Adds relevant QA and perf tests.

Srihari-mcw and others added 30 commits July 15, 2025 11:59
Copy link
Copy Markdown
Contributor

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 tensor–tensor bitwise operations (AND/OR/XOR) with broadcasting support across 1D/2D/3D/ND for both HOST and HIP backends, and wires them into the test-suite (QA + perf).

Changes:

  • Introduces new public APIs: rppt_tensor_and_tensor, rppt_tensor_or_tensor, rppt_tensor_xor_tensor with RpptBroadcastMode.
  • Adds new HOST and HIP kernel/executor implementations for tensor–tensor bitwise ops with broadcasting.
  • Extends the test suite (cases, bit-depth modes, CLI args) and adds reference outputs.

Reviewed changes

Copilot reviewed 21 out of 29 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
api/rppt_tensor_bitwise_operations.h Declares new tensor–tensor bitwise APIs w/ broadcasting.
api/rppdefs.h Adds RpptBitwiseOp, RpptBroadcastMode, new RpptDataType values, and RPPT_MAX_DIMS_SAMPLE.
src/modules/tensor/rppt_tensor_bitwise_operations.cpp Implements new APIs and dispatches to HOST/HIP executors.
src/modules/tensor/cpu/kernel/tensor_bitwise_binary_operations.cpp Adds HOST implementation for tensor–tensor bitwise ops incl. broadcasting.
src/modules/tensor/hip/kernel/tensor_bitwise_binary_operations.cpp Adds HIP implementation for tensor–tensor bitwise ops incl. broadcasting.
src/include/common/hip/rpp_hip_math.hpp Refactors bitwise math to generic templated ops (AND/OR/XOR).
src/include/common/hip/rpp_hip_load_store.hpp Adds ushort/uint vector load/store helpers.
utilities/test_suite/* files Adds new misc cases, broadcast flag plumbing, new bit-depth modes, and updates host/hip runners.

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

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 83.18662% with 191 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...or/cpu/kernel/tensor_bitwise_binary_operations.cpp 79.03% 95 Missing ⚠️
.../modules/tensor/rppt_tensor_bitwise_operations.cpp 86.61% 51 Missing ⚠️
...or/hip/kernel/tensor_bitwise_binary_operations.cpp 85.05% 45 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #682      +/-   ##
===========================================
- Coverage    92.55%   92.42%   -0.13%     
===========================================
  Files          206      208       +2     
  Lines        92763    93900    +1137     
===========================================
+ Hits         85851    86783     +932     
- Misses        6912     7117     +205     
Files with missing lines Coverage Δ
api/rppdefs.h 70.91% <100.00%> (+0.54%) ⬆️
src/include/common/hip/rpp_hip_load_store.hpp 100.00% <ø> (ø)
src/modules/tensor/hip/kernel/bitwise_and.cpp 98.63% <ø> (ø)
src/modules/tensor/hip/kernel/bitwise_or.cpp 98.63% <ø> (ø)
src/modules/tensor/hip/kernel/bitwise_xor.cpp 98.61% <ø> (ø)
src/modules/tensor/hip/kernel/posterize.cpp 98.61% <ø> (ø)
...or/hip/kernel/tensor_bitwise_binary_operations.cpp 85.05% <85.05%> (ø)
.../modules/tensor/rppt_tensor_bitwise_operations.cpp 89.29% <86.61%> (-6.00%) ⬇️
...or/cpu/kernel/tensor_bitwise_binary_operations.cpp 79.03% <79.03%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LakshmiKumar23 LakshmiKumar23 requested a review from rrawther March 17, 2026 22:35
Copy link
Copy Markdown
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

please address the review comments

@kiritigowda kiritigowda self-assigned this Mar 18, 2026
@kiritigowda kiritigowda merged commit 96bc3fb into ROCm:develop Mar 27, 2026
1 check passed
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.

9 participants