Skip to content

Conversation

@angelzzzzz
Copy link

@angelzzzzz angelzzzzz commented Oct 20, 2025

According to the ONNX spec, in the CRD mode, elements along the depth dimension from the input tensor are rearranged in the following order: column, row, and the depth. The output y is computed from the input x as below:

b, c, h, w = x.shape
tmp = np.reshape(x, [b, c // (blocksize ** 2), blocksize, blocksize, h, w])
tmp = np.transpose(tmp, [0, 1, 4, 2, 5, 3])
y = np.reshape(tmp, [b, c // (blocksize ** 2), h * blocksize, w * blocksize])

So, the input should be reshaped to [b, c / (blocksize^2), blocksize, blocksize, h, w] instead of [b, blocksize, blocksize, c / (blocksize^2), h, w].

According to the ONNX spec, in CRD mode the input should be reshaped to
[b, c / (blocksize^2), blocksize, blocksize, h, w] instead of
[b, blocksize, blocksize, c / (blocksize^2), h, w].
@angelzzzzz
Copy link
Author

@sahas3 Could you please review this PR and share feedback or suggestions when you have time? Thanks a lot!

Value transposedInput;
Value reshapeSizesList;
if (mode == "DCR") {
reshapeSizesList = rewriter.create<Torch::PrimListConstructOp>(
Copy link
Member

@sahas3 sahas3 Oct 29, 2025

Choose a reason for hiding this comment

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

I am not familiar with the ONNX part of the codebase. Are there e2e tests that will lock down the numeric for DCR/CRD mode? If not, can you add some please?

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