Overview
PixelShuffle/PixelUnshuffle in PyTorch and depth_to_space/space_to_depth in TensorFlow are very similar, but they are not numerically identical unless the upsampled image contains a single channel. This can be easyly verified by hand: while the tensor dimensions match between the PyTorch and TensorFlow worlds, the output channels do not follow the same order.
However, in some deployment setups, there might be performance benefits to using the space-to-depth/depth-to-space variant. For example, at the moment of writing, Android NN API only supports depth-to-space and space-to-depth.
This repository provides a unit-tested space-to-depth/depth-to-space implementation for PyTorch, supporting conversion to SpaceToDepth/DepthToSpace ONNX ops when exporting the model as an ONNX graph for further deployment.
The provided implementation follows channels-first PyTorch standard, allowing for arbitrary number of outer dimensions, i.e. it supports tensors of [..., C, H, W] layouts.
Installation
python3 -m pip install s2d2s
Usage
Both functional implementations and nn.Modules are available and can be used as follows:
from s2d2s import space_to_depth, depth_to_space
y = space_to_depth(x, 2)
from s2d2s import SpaceToDepth, DepthToSpace
module = SpaceToDepth(2)
y = module(x)
Metadata
Release files for s2d2s 1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| s2d2s-1.tar.gz | 3.7 kB | Without provenance | Details for s2d2s-1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| s2d2s-1-py3-none-any.whl | Python 3 | none | any | Details for s2d2s-1-py3-none-any.whl |
Total release size: 8.1 kB
Release files / s2d2s-1.tar.gz
| Download URL | s2d2s-1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c6dc146567bd6476948f4673adb8d6fc08eae3c978542677ecc4629d9b56767
|
|
BLAKE2b-256 checksum How to use checksums |
c8b6aa4344775de942571be7273f31e1a9156435ab28ff8e7726771c1aff12b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / s2d2s-1-py3-none-any.whl
| Download URL | s2d2s-1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e692e0d4810e525333d81f1cea8983b8d0dbc8877aa44072bf319c6198a20eb9
|
|
BLAKE2b-256 checksum How to use checksums |
dfb7a3737794ef4b35893b92f26e4bbba48eceec17298f72ee84bd6944d097c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for s2d2s 1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.