Dynamic Batching with PyTorch
Project description
TorchFold
Blog post: http://near.ai/articles/2017-09-06-PyTorch-Dynamic-Batching/
Analogous to TensorFlow Fold, implements dynamic batching with super simple interface.
Replace every direct call in your computation to nn module with f.add('function name', arguments)
.
It will construct an optimized version of computation and on f.apply
will dynamically batch and execute the computation on given nn module.
Installation
We recommend using pip package manager:
pip install torchfold
Example
f = torchfold.Fold()
def dfs(node):
if is_leaf(node):
return f.add('leaf', node)
else:
prev = f.add('init')
for child in children(node):
prev = f.add('child', prev, child)
return prev
class Model(nn.Module):
def __init__(self, ...):
...
def leaf(self, leaf):
...
def child(self, prev, child):
...
res = dfs(my_tree)
model = Model(...)
f.apply(model, [[res]])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
torchfold-0.1.0.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file torchfold-0.1.0.tar.gz
.
File metadata
- Download URL: torchfold-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73605bdbbaa627735bb28c3f90d654896de248fa1a988e730182b68ddf4660a6 |
|
MD5 | 3ec270cac4e5f7b5219a5495d07b9a83 |
|
BLAKE2b-256 | 12804c88fea850af25cb66e5d07eff3b38411eaa09f94c5a3c4370a7316a9234 |
File details
Details for the file torchfold-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: torchfold-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53721bbf32b61119f596b23d44061503497d5eb6fa67a3c1c82ba008842b3c26 |
|
MD5 | 7777910c57b940a96f0c591a90c1ca71 |
|
BLAKE2b-256 | c0fb2ff01af27b6fbe147a16be0e3f78007a3d03224d89ebcfa2441d838398bc |