Skip to content

[Optimization] Use int32 instead of int64 for indexing tensor wrappers.#167

Draft
daniellegillai wants to merge 11 commits into
ROCm:developfrom
daniellegillai:int32_optimization
Draft

[Optimization] Use int32 instead of int64 for indexing tensor wrappers.#167
daniellegillai wants to merge 11 commits into
ROCm:developfrom
daniellegillai:int32_optimization

Conversation

@daniellegillai

@daniellegillai daniellegillai commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Motivation

Operators can see a speedup when image indexing and stride calculations are done in int32 rather than int64.

Technical Details

Templatized the ImageWrapper, BorderWrapper, and InterpolationWrapper classes so that the type they use for index/stride calculations can be controlled to be int32_t or int64_t. Currently all operators but CvtColor have a hard limit, checked with validation, that they must fit in int32 (they will not fall back to int64_t otherwise). CvtColor is adaptive: will choose int32 for the wrapper type if it can fit, and otherwise falls back to int64_t.

Tests

Existing ctests all still pass.
Benchmark with batch size 128 on Resize throws an exception because it is too large to fit with int32.

Comment thread include/operator_types.h Outdated
Comment thread include/operator_types.h Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants