Add int8/uint8 CPU support for SpaceToDepth and int8 for DepthToSpace#29154
Open
ArsalanShakil wants to merge 1 commit into
Open
Add int8/uint8 CPU support for SpaceToDepth and int8 for DepthToSpace#29154ArsalanShakil wants to merge 1 commit into
ArsalanShakil wants to merge 1 commit into
Conversation
SpaceToDepth previously supported only float/double on CPU, and DepthToSpace supported float/double/uint8. Extend the CPU kernels so both ops also accept 8-bit integer tensors, which is needed for running quantized models. uint8_t and int8_t are routed through a single template instantiation: the ops only shuffle 8-bit elements, so the signedness of the data is irrelevant and we avoid the binary-size cost of a second instantiation. SpaceDepthOpCpuImpl now takes raw pointers so the shared branch can feed it via DataRaw(). Adds typed unit tests covering uint8/int8 for SpaceToDepth and int8 for DepthToSpace, and updates docs/OperatorKernels.md. Fixes microsoft#21287
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add CPU support for 8-bit integer tensor types to the
SpaceToDepthandDepthToSpaceoperators:SpaceToDepth(opsets 1–12 and 13): previously supported onlyfloat/double; now also acceptsuint8andint8.DepthToSpace(opsets 11–12 and 13): previously supportedfloat/double/uint8; now also acceptsint8.uint8_tandint8_tare routed through a single template instantiation. These ops only shuffle 8-bit elements around, so the signedness of the data is irrelevant — handling both in one branch avoids the binary-size cost of a second instantiation (per the guidance in #21287).SpaceDepthOpCpuImplnow takes raw pointers so the shared branch can feed it viaDataRaw()/MutableDataRaw().Also adds typed unit tests covering
uint8/int8forSpaceToDepthandint8forDepthToSpace, and updatesdocs/OperatorKernels.md.Motivation and Context
Fixes #21287. The
DepthToSpace/SpaceToDepthONNX operators support integer types, but the ORT CPU kernels did not fully implement them, which is needed for running quantized models. This completes the integer support on CPU (SpaceToDepthhad none;DepthToSpacewas missingint8).The CUDA kernels are already generic and could be extended similarly in a follow-up; this PR focuses on the CPU EP.