Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for DepthToSpace operator #927

Closed
etiotto opened this issue Oct 19, 2021 · 0 comments · Fixed by #903, #915 or #942
Closed

Support for DepthToSpace operator #927

etiotto opened this issue Oct 19, 2021 · 0 comments · Fixed by #903, #915 or #942
Assignees

Comments

@etiotto
Copy link
Collaborator

etiotto commented Oct 19, 2021

DepthToSpace rearranges data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. The output tensor is a copy of the input tensor where blocks of size blocksize * blocksize from the depth dimension are moved in spatial blocks to the height and width dimensions. By default, mode = DCR. In the DCR mode, elements along the depth dimension from the input tensor are rearranged in the following order: depth, column, and then row.

Given input tensor [N,C,H,W] by default (mode = DCR] the output tensor has shape [N, C / (blocksize * blocksize), H*blocksize, W*blocksize]. The transformation can be seen as a sequence of a reshape + transpose + reshape operations:

  tmp1 = reshape(input, [N, blocksize, blocksize, C // (blocksize**2), H, W])
  tmp2 = transpose(tmp1, [0, 3, 4, 1, 5, 2])
  out = reshape(tmp2, [N, C / (blocksize**2), H * blocksize, W * blocksize])

When mode = CRD:

  tmp1 = reshape(input, [N, C / (blocksize ** 2), blocksize, blocksize, H, W])
  tmp2 = transpose(tmp1, [0, 1, 4, 2, 5, 3])
  out = reshape(tmp2, [N, C / (blocksize ** 2), H * blocksize, W * blocksize])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment