{"id":15647836,"url":"https://github.com/fatescript/nnprof","last_synced_at":"2025-04-30T13:33:38.652Z","repository":{"id":57446493,"uuid":"326383758","full_name":"FateScript/nnprof","owner":"FateScript","description":"profile tools for pytorch nn models","archived":false,"fork":false,"pushed_at":"2021-01-11T11:10:22.000Z","size":14,"stargazers_count":42,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-24T15:44:43.706Z","etag":null,"topics":[],"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/FateScript.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}},"created_at":"2021-01-03T10:48:46.000Z","updated_at":"2024-08-15T07:32:28.000Z","dependencies_parsed_at":"2022-09-02T23:40:58.842Z","dependency_job_id":null,"html_url":"https://github.com/FateScript/nnprof","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FateScript%2Fnnprof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FateScript%2Fnnprof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FateScript%2Fnnprof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FateScript%2Fnnprof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FateScript","download_url":"https://codeload.github.com/FateScript/nnprof/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242661652,"owners_count":20165329,"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":[],"created_at":"2024-10-03T12:21:28.986Z","updated_at":"2025-03-09T07:32:01.523Z","avatar_url":"https://github.com/FateScript.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nnprof \n\n## Introduction\n\nnnprof is a profile tool for pytorch neural networks. \n\n### Features\n\n* **multi profile mode**: nnprof support 4 profile mode: Layer level, Operation level, Mixed level, Layer Tree level. Please check below for detail usage. \n* **time and memory profile**: nnprof support both time and memory profile now. But since memory profile is first supported in pytorch 1.6, please use torch version \u003e= 1.6 for memory profile.\n* **support sorted by given key and show profile percent**: user could print table with percentage and sorted profile info using a given key,  which is really helpful for optimiziing neural network.\n\n## Requirements\n\n* Python \u003e= 3.6\n* PyTorch\n* Numpy\n\n## Get Started\n\n### install nnprof\n* pip install: \n```shell\npip install nnprof\n```\n* from source: \n```shell\npython -m pip install 'git+https://github.com/FateScript/nnprof.git'\n\n# or install after clone this repo\ngit clone https://github.com/FateScript/nnprof.git\npip install -e nnprof\n```\n\n### use nnprf\n\n```python3\nfrom nnprof import profile, ProfileMode\nimport torch\nimport torchvision\n\nmodel = torchvision.models.alexnet(pretrained=False)\nx = torch.rand([1, 3, 224, 224])\n\n# mode could be anyone in LAYER, OP, MIXED, LAYER_TREE\nmode = ProfileMode.LAYER\n\nwith profile(model, mode=mode) as prof:\n    y = model(x)\n\nprint(prof.table(average=False, sorted_by=\"cpu_time\"))\n# table could be sorted by presented header.\n```\n\nPart of presented table looks like table below, Note that they are sorted by cpu_time.\n```\n╒══════════════════════╤═══════════════════╤═══════════════════╤════════╕\n│ name                 │ self_cpu_time     │ cpu_time          │   hits │\n╞══════════════════════╪═══════════════════╪═══════════════════╪════════╡\n│ AlexNet.features.0   │ 19.114ms (34.77%) │ 76.383ms (45.65%) │      1 │\n├──────────────────────┼───────────────────┼───────────────────┼────────┤\n│ AlexNet.features.3   │ 5.148ms (9.37%)   │ 20.576ms (12.30%) │      1 │\n├──────────────────────┼───────────────────┼───────────────────┼────────┤\n│ AlexNet.features.8   │ 4.839ms (8.80%)   │ 19.336ms (11.56%) │      1 │\n├──────────────────────┼───────────────────┼───────────────────┼────────┤\n│ AlexNet.features.6   │ 4.162ms (7.57%)   │ 16.632ms (9.94%)  │      1 │\n├──────────────────────┼───────────────────┼───────────────────┼────────┤\n│ AlexNet.features.10  │ 2.705ms (4.92%)   │ 10.713ms (6.40%)  │      1 │\n├──────────────────────┼───────────────────┼───────────────────┼────────┤\n```\n\nYou are welcomed to try diffierent profile mode and more table format.\n\n## Contribution\n\nAny issues and pull requests are welcomed.\n\n## Acknowledgement\n\nSome thoughts of nnprof are inspired by  [torchprof](https://github.com/awwong1/torchprof) and [torch.autograd.profile](https://github.com/pytorch/pytorch/blob/749f8b78508c43f9e6331f2395a4202785068442/torch/autograd/profiler.py) .\nMany thanks to the authors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatescript%2Fnnprof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffatescript%2Fnnprof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatescript%2Fnnprof/lists"}