{ "info": { "author": "Adrian Bulat", "author_email": "adrian@adrianbulat.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![Build Status](https://travis-ci.com/1adrianb/pytorch-estimate-flops.svg?branch=master)](https://travis-ci.com/1adrianb/pytorch-estimate-flops)\n[![PyPI](https://img.shields.io/pypi/v/pthflops.svg?style=flat)](https://pypi.org/project/pthflops/)\n\n# pytorch-estimate-flops\n\nSimple pytorch utility that estimates the number of FLOPs for a given network. For now only some basic operations are supported (basically the ones I needed for my models). More will be added soon.\n\nAll contributions are welcomed.\n\n## Installation\n\nYou can install the model using pip:\n\n```bash\npip install pthflops\n```\nor directly from the github repository:\n```bash\ngit clone https://github.com/1adrianb/pytorch-estimate-flops && pytorch-estimate-flops\npython setup.py install\n```\n\n## Example\n\n```python\nimport torch\nfrom torchvision.models import resnet18\n\nfrom pthflops import count_ops\n\n# Create a network and a corresponding input\ndevice = 'cuda:0'\nmodel = resnet18().to(device)\ninp = torch.rand(1,3,224,224).to(device)\n\n# Count the number of FLOPs\ncount_ops(model, inp)\n```\n\nIgnoring certain layers:\n\n```python\nimport torch\nfrom torch import nn\nfrom pthflops import count_ops\n\nclass CustomLayer(nn.Module):\n def __init__(self):\n super(CustomLayer, self).__init__()\n self.conv1 = nn.Conv2d(5, 5, 1, 1, 0)\n # ... other layers present inside will also be ignored\n\n def forward(self, x):\n return self.conv1(x)\n\n# Create a network and a corresponding input\ninp = torch.rand(1,5,7,7)\nnet = nn.Sequential(\n nn.Conv2d(5, 5, 1, 1, 0),\n nn.ReLU(inplace=True),\n CustomLayer()\n)\n\n# Count the number of FLOPs\ncount_ops(net, inp, ignore_layers=['CustomLayer'])\n\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/1adrianb/pytorch-estimate-flops", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pthflops", "package_url": "https://pypi.org/project/pthflops/", "platform": "", "project_url": "https://pypi.org/project/pthflops/", "project_urls": { "Homepage": "https://github.com/1adrianb/pytorch-estimate-flops" }, "release_url": "https://pypi.org/project/pthflops/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Estimate FLOPs of neural networks", "version": "0.2.1" }, "last_serial": 5842333, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a377c90a19e37762adb882a0714ed531", "sha256": "7010ce81ccb3be5dd04ab4865023617a71d685414962f784efeed96158e4e97e" }, "downloads": -1, "filename": "pthflops-0.1.0-py3.6.egg", "has_sig": false, "md5_digest": "a377c90a19e37762adb882a0714ed531", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 6286, "upload_time": "2019-02-09T02:28:01", "url": "https://files.pythonhosted.org/packages/54/b0/56d492e0c9b26dad4e3b5757665e753d0d5e63ebd8ac41ea0c86a4642177/pthflops-0.1.0-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "bfa896139dad96a3bc490a8f65a92440", "sha256": "d71c69532c3161178289d7ca7875559a7bdbdbffc7d5a3c5b7d293151e77cdc1" }, "downloads": -1, "filename": "pthflops-0.1.0.tar.gz", "has_sig": false, "md5_digest": "bfa896139dad96a3bc490a8f65a92440", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3734, "upload_time": "2019-02-09T02:28:03", "url": "https://files.pythonhosted.org/packages/25/c4/362b67b262ee1c848297d6caff57765f09984c64111919495bf3f663f117/pthflops-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "819cbeb515bca7a3da5991ccdaabafc4", "sha256": "4f1d64315e309ebeb9638e0d25b33dad78cabfe51f552f388f2521b2f52eeeb3" }, "downloads": -1, "filename": "pthflops-0.2.0-py3.6.egg", "has_sig": false, "md5_digest": "819cbeb515bca7a3da5991ccdaabafc4", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 8958, "upload_time": "2019-08-16T22:40:19", "url": "https://files.pythonhosted.org/packages/27/03/a2bc2debc95b83212065a1e0a4aa860913f14bdd3c957bf3160e399e70d2/pthflops-0.2.0-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "783fee2668999a06fd17262ef5cabf3a", "sha256": "827cbc167bf1610bba29d0b95d4c30f4d243bd9f2867f8299fd6d9e5d7104cc0" }, "downloads": -1, "filename": "pthflops-0.2.0.tar.gz", "has_sig": false, "md5_digest": "783fee2668999a06fd17262ef5cabf3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4890, "upload_time": "2019-08-16T22:39:35", "url": "https://files.pythonhosted.org/packages/45/2c/ca4d2f439a28503be50328978d7da1982b87efd9c13685d1eb9979ddb912/pthflops-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "70e570b28c84f9813dce7b67ed0f4d2a", "sha256": "cefac14cc434ab2648615a010355e615d8d63140ab0d50dcd4bb401d58aa263a" }, "downloads": -1, "filename": "pthflops-0.2.1-py3.6.egg", "has_sig": false, "md5_digest": "70e570b28c84f9813dce7b67ed0f4d2a", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 9291, "upload_time": "2019-09-17T15:35:03", "url": "https://files.pythonhosted.org/packages/86/54/3f290aefcd6bce52289d2cf23cb67dd446d1d7508a908273e10f705432b7/pthflops-0.2.1-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "56a9a0cbc63c8fedf6c4c51a428a4144", "sha256": "d9a7189430c2912a2721feaa0e3a3aa57072f9ad31323e80ab3323df723359c9" }, "downloads": -1, "filename": "pthflops-0.2.1.tar.gz", "has_sig": false, "md5_digest": "56a9a0cbc63c8fedf6c4c51a428a4144", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5012, "upload_time": "2019-09-17T15:33:38", "url": "https://files.pythonhosted.org/packages/46/4b/ee7edab191751c0b9f47acd76c244676237042784b5f163253e33c5c89e8/pthflops-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "70e570b28c84f9813dce7b67ed0f4d2a", "sha256": "cefac14cc434ab2648615a010355e615d8d63140ab0d50dcd4bb401d58aa263a" }, "downloads": -1, "filename": "pthflops-0.2.1-py3.6.egg", "has_sig": false, "md5_digest": "70e570b28c84f9813dce7b67ed0f4d2a", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 9291, "upload_time": "2019-09-17T15:35:03", "url": "https://files.pythonhosted.org/packages/86/54/3f290aefcd6bce52289d2cf23cb67dd446d1d7508a908273e10f705432b7/pthflops-0.2.1-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "56a9a0cbc63c8fedf6c4c51a428a4144", "sha256": "d9a7189430c2912a2721feaa0e3a3aa57072f9ad31323e80ab3323df723359c9" }, "downloads": -1, "filename": "pthflops-0.2.1.tar.gz", "has_sig": false, "md5_digest": "56a9a0cbc63c8fedf6c4c51a428a4144", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5012, "upload_time": "2019-09-17T15:33:38", "url": "https://files.pythonhosted.org/packages/46/4b/ee7edab191751c0b9f47acd76c244676237042784b5f163253e33c5c89e8/pthflops-0.2.1.tar.gz" } ] }