{"id":13443274,"url":"https://github.com/rusty1s/pytorch_scatter","last_synced_at":"2025-05-14T00:07:26.044Z","repository":{"id":37686471,"uuid":"114475042","full_name":"rusty1s/pytorch_scatter","owner":"rusty1s","description":"PyTorch Extension Library of Optimized Scatter Operations","archived":false,"fork":false,"pushed_at":"2025-04-20T07:21:04.000Z","size":794,"stargazers_count":1631,"open_issues_count":19,"forks_count":186,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-20T08:29:18.767Z","etag":null,"topics":["gather","pytorch","scatter","segment"],"latest_commit_sha":null,"homepage":"https://pytorch-scatter.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rusty1s.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,"zenodo":null}},"created_at":"2017-12-16T16:34:23.000Z","updated_at":"2025-04-20T07:21:08.000Z","dependencies_parsed_at":"2024-01-07T06:01:45.225Z","dependency_job_id":"6a4f1888-b61c-46e0-b817-c3cf783a2c54","html_url":"https://github.com/rusty1s/pytorch_scatter","commit_stats":{"total_commits":1007,"total_committers":30,"mean_commits":33.56666666666667,"dds":0.0446871896722939,"last_synced_commit":"8ec9364b0bdcd99149952a25749ad211c2d0567b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_scatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_scatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_scatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_scatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rusty1s","download_url":"https://codeload.github.com/rusty1s/pytorch_scatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043753,"owners_count":22005012,"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":["gather","pytorch","scatter","segment"],"created_at":"2024-07-31T03:01:58.475Z","updated_at":"2025-05-14T00:07:26.037Z","avatar_url":"https://github.com/rusty1s.png","language":"Python","funding_links":[],"categories":["Python","Deep Learning Framework","Pytorch实用程序","其他_机器学习与深度学习"],"sub_categories":["High-Level DL APIs"],"readme":"[pypi-image]: https://badge.fury.io/py/torch-scatter.svg\n[pypi-url]: https://pypi.python.org/pypi/torch-scatter\n[testing-image]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/testing.yml/badge.svg\n[testing-url]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/testing.yml\n[linting-image]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/linting.yml/badge.svg\n[linting-url]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/linting.yml\n[docs-image]: https://readthedocs.org/projects/pytorch-scatter/badge/?version=latest\n[docs-url]: https://pytorch-scatter.readthedocs.io/en/latest/?badge=latest\n[coverage-image]: https://codecov.io/gh/rusty1s/pytorch_scatter/branch/master/graph/badge.svg\n[coverage-url]: https://codecov.io/github/rusty1s/pytorch_scatter?branch=master\n\n# PyTorch Scatter\n\n[![PyPI Version][pypi-image]][pypi-url]\n[![Testing Status][testing-image]][testing-url]\n[![Linting Status][linting-image]][linting-url]\n[![Docs Status][docs-image]][docs-url]\n[![Code Coverage][coverage-image]][coverage-url]\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"50%\" src=\"https://raw.githubusercontent.com/rusty1s/pytorch_scatter/master/docs/source/_figures/add.svg?sanitize=true\" /\u003e\n\u003c/p\u003e\n\n--------------------------------------------------------------------------------\n\n**[Documentation](https://pytorch-scatter.readthedocs.io)**\n\nThis package consists of a small extension library of highly optimized sparse update (scatter and segment) operations for the use in [PyTorch](http://pytorch.org/), which are missing in the main package.\nScatter and segment operations can be roughly described as reduce operations based on a given \"group-index\" tensor.\nSegment operations require the \"group-index\" tensor to be sorted, whereas scatter operations are not subject to these requirements.\n\nThe package consists of the following operations with reduction types `\"sum\"|\"mean\"|\"min\"|\"max\"`:\n\n* [**scatter**](https://pytorch-scatter.readthedocs.io/en/latest/functions/scatter.html) based on arbitrary indices\n* [**segment_coo**](https://pytorch-scatter.readthedocs.io/en/latest/functions/segment_coo.html) based on sorted indices\n* [**segment_csr**](https://pytorch-scatter.readthedocs.io/en/latest/functions/segment_csr.html) based on compressed indices via pointers\n\nIn addition, we provide the following **composite functions** which make use of `scatter_*` operations under the hood: `scatter_std`, `scatter_logsumexp`, `scatter_softmax` and `scatter_log_softmax`.\n\nAll included operations are broadcastable, work on varying data types, are implemented both for CPU and GPU with corresponding backward implementations, and are fully traceable.\n\n## Installation\n\n### Binaries\n\nWe provide pip wheels for all major OS/PyTorch/CUDA combinations, see [here](https://data.pyg.org/whl).\n\n#### PyTorch 2.6\n\nTo install the binaries for PyTorch 2.6.0, simply run\n\n```\npip install torch-scatter -f https://data.pyg.org/whl/torch-2.6.0+${CUDA}.html\n```\n\nwhere `${CUDA}` should be replaced by either `cpu`, `cu118`, `cu124`, or `cu126` depending on your PyTorch installation.\n\n|             | `cpu` | `cu118` | `cu124` | `cu126` |\n|-------------|-------|---------|---------|---------|\n| **Linux**   | ✅    | ✅      | ✅      | ✅      |\n| **Windows** | ✅    | ✅      | ✅      | ✅      |\n| **macOS**   | ✅    |         |         |         |\n\n\n#### PyTorch 2.5\n\nTo install the binaries for PyTorch 2.5.0/2.5.1, simply run\n\n```\npip install torch-scatter -f https://data.pyg.org/whl/torch-2.5.0+${CUDA}.html\n```\n\nwhere `${CUDA}` should be replaced by either `cpu`, `cu118`, `cu121`, or `cu124` depending on your PyTorch installation.\n\n|             | `cpu` | `cu118` | `cu121` | `cu124` |\n|-------------|-------|---------|---------|---------|\n| **Linux**   | ✅    | ✅      | ✅      | ✅      |\n| **Windows** | ✅    | ✅      | ✅      | ✅      |\n| **macOS**   | ✅    |         |         |         |\n\n**Note:** Binaries of older versions are also provided for PyTorch 1.4.0, PyTorch 1.5.0, PyTorch 1.6.0, PyTorch 1.7.0/1.7.1, PyTorch 1.8.0/1.8.1, PyTorch 1.9.0, PyTorch 1.10.0/1.10.1/1.10.2, PyTorch 1.11.0, PyTorch 1.12.0/1.12.1, PyTorch 1.13.0/1.13.1, PyTorch 2.0.0/2.0.1, PyTorch 2.1.0/2.1.1/2.1.2, PyTorch 2.2.0/2.2.1/2.2.2, PyTorch 2.3.0/2.3.1, and PyTorch 2.4.0/2.4.1 (following the same procedure).\nFor older versions, you need to explicitly specify the latest supported version number or install via `pip install --no-index` in order to prevent a manual installation from source.\nYou can look up the latest supported version number [here](https://data.pyg.org/whl).\n\n### From source\n\nEnsure that at least PyTorch 1.4.0 is installed and verify that `cuda/bin` and `cuda/include` are in your `$PATH` and `$CPATH` respectively, *e.g.*:\n\n```\n$ python -c \"import torch; print(torch.__version__)\"\n\u003e\u003e\u003e 1.4.0\n\n$ echo $PATH\n\u003e\u003e\u003e /usr/local/cuda/bin:...\n\n$ echo $CPATH\n\u003e\u003e\u003e /usr/local/cuda/include:...\n```\n\nThen run:\n\n```\npip install torch-scatter\n```\n\nWhen running in a docker container without NVIDIA driver, PyTorch needs to evaluate the compute capabilities and may fail.\nIn this case, ensure that the compute capabilities are set via `TORCH_CUDA_ARCH_LIST`, *e.g.*:\n\n```\nexport TORCH_CUDA_ARCH_LIST = \"6.0 6.1 7.2+PTX 7.5+PTX\"\n```\n\n## Example\n\n```py\nimport torch\nfrom torch_scatter import scatter_max\n\nsrc = torch.tensor([[2, 0, 1, 4, 3], [0, 2, 1, 3, 4]])\nindex = torch.tensor([[4, 5, 4, 2, 3], [0, 0, 2, 2, 1]])\n\nout, argmax = scatter_max(src, index, dim=-1)\n```\n\n```\nprint(out)\ntensor([[0, 0, 4, 3, 2, 0],\n        [2, 4, 3, 0, 0, 0]])\n\nprint(argmax)\ntensor([[5, 5, 3, 4, 0, 1]\n        [1, 4, 3, 5, 5, 5]])\n```\n\n## Running tests\n\n```\npytest\n```\n\n## C++ API\n\n`torch-scatter` also offers a C++ API that contains C++ equivalent of python models.\nFor this, we need to add `TorchLib` to the `-DCMAKE_PREFIX_PATH` (run `import torch; print(torch.utils.cmake_prefix_path)` to obtain it).\n\n```\nmkdir build\ncd build\n# Add -DWITH_CUDA=on support for CUDA support\ncmake -DCMAKE_PREFIX_PATH=\"...\" ..\nmake\nmake install\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusty1s%2Fpytorch_scatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusty1s%2Fpytorch_scatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusty1s%2Fpytorch_scatter/lists"}