Mocks pytorch modules so that test run faster
Project description
torchmocks
Test pytorch code with minimal computational overhead.
Problem
The computational overhead of neural networks discourages thorough testing during development and within CI/CD pipelines.
Solution
Torchmocks replaces common building blocks (such as torch.nn.Conv2d) with replicas that only keep track of tensor shapes and device location. This is often the only information that we need to check to ensure proper function of pytorch code.
Example
import torch
import torchmocks
from torchvision.models import resnet152
def test_mock_resnet():
net = resnet152()
torchmocks.mock(net)
image_batch = torch.zeros(4, 3, 255, 255)
output = net(image_batch)
assert output.shape == (4, 1000)
Status
This is a work in progress and only a handful of torch modules have been mocked. Modules that have not been mocked will run their normal computation during the forward and backward pass.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for torchmocks-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da45fa0536e357c6a05a1e2dfd87ec4384b5b63a5576a9efdf2f1612c2512c3f |
|
MD5 | 70846b9bc70fa3ced83239c7a658d114 |
|
BLAKE2b-256 | bf71f93bf0f934d5bdab812c3a1cb84b5d4616d1480a9077e420c1837d3c9f0b |