{"id":13717035,"url":"https://github.com/nearai/torchfold","last_synced_at":"2025-04-06T15:13:33.502Z","repository":{"id":104644971,"uuid":"101112896","full_name":"nearai/torchfold","owner":"nearai","description":"Tools for PyTorch","archived":false,"fork":false,"pushed_at":"2022-08-10T20:26:14.000Z","size":75,"stargazers_count":221,"open_issues_count":7,"forks_count":28,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-05-23T06:48:01.224Z","etag":null,"topics":["deep-learning","deep-neural-networks","machine-learning","pytorch"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nearai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-22T22:28:18.000Z","updated_at":"2024-08-03T00:39:17.072Z","dependencies_parsed_at":null,"dependency_job_id":"c52c8be7-f61e-482a-abd9-530d3d8f4ee6","html_url":"https://github.com/nearai/torchfold","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nearai%2Ftorchfold","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nearai%2Ftorchfold/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nearai%2Ftorchfold/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nearai%2Ftorchfold/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nearai","download_url":"https://codeload.github.com/nearai/torchfold/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294514,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","deep-neural-networks","machine-learning","pytorch"],"created_at":"2024-08-03T00:01:17.165Z","updated_at":"2025-04-06T15:13:33.470Z","avatar_url":"https://github.com/nearai.png","language":"Python","funding_links":[],"categories":["Pytorch \u0026 related libraries｜Pytorch \u0026 相关库"],"sub_categories":["Other libraries｜其他库:"],"readme":"\u003cimg src=\"logo.jpg\" width=30% align=\"right\" /\u003e\n\n[![PyPi version](https://pypip.in/v/torchfold/badge.png)](https://pypi.org/project/torchfold/) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1299387.svg)](https://doi.org/10.5281/zenodo.1299387)\n# TorchFold\n\nBlog post: http://near.ai/articles/2017-09-06-PyTorch-Dynamic-Batching/\n\nAnalogous to [TensorFlow Fold](https://github.com/tensorflow/fold), implements dynamic batching with super simple interface.\nReplace every direct call in your computation to nn module with `f.add('function name', arguments)`.\nIt will construct an optimized version of computation and on `f.apply` will dynamically batch and execute the computation on given nn module.\n\n## Installation\nWe recommend using pip package manager:\n```\npip install torchfold\n```\n\n## Example\n\n```\n    f = torchfold.Fold()\n   \n    def dfs(node):\n        if is_leaf(node):\n            return f.add('leaf', node)\n        else:\n            prev = f.add('init')\n            for child in children(node):\n                prev = f.add('child', prev, child)\n            return prev\n\n    class Model(nn.Module):\n        def __init__(self, ...):\n            ...\n\n        def leaf(self, leaf):\n            ...\n\n        def child(self, prev, child):\n            ...\n\n    res = dfs(my_tree)\n    model = Model(...)\n    f.apply(model, [[res]])\n```\n\n\nTo cite this repository in publications:\n\n    @misc{illia_polosukhin_2018_1299387,\n      author       = {Illia Polosukhin and\n                      Maksym Zavershynskyi},\n      title        = {nearai/torchfold: v0.1.0},\n      month        = jun,\n      year         = 2018,\n      doi          = {10.5281/zenodo.1299387},\n      url          = {https://doi.org/10.5281/zenodo.1299387}\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnearai%2Ftorchfold","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnearai%2Ftorchfold","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnearai%2Ftorchfold/lists"}