{"id":24765923,"url":"https://github.com/infinitensor/ninetoothed","last_synced_at":"2025-10-11T14:31:32.541Z","repository":{"id":250815484,"uuid":"833483612","full_name":"InfiniTensor/ninetoothed","owner":"InfiniTensor","description":"A domain-specific language (DSL) based on Triton but providing higher-level abstractions.","archived":false,"fork":false,"pushed_at":"2024-10-22T09:24:26.000Z","size":74,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-23T09:59:56.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/InfiniTensor.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":"2024-07-25T06:36:57.000Z","updated_at":"2024-10-22T09:23:15.000Z","dependencies_parsed_at":"2024-09-09T04:42:37.979Z","dependency_job_id":"649a0dc3-0561-47d5-acbe-750b8f19718a","html_url":"https://github.com/InfiniTensor/ninetoothed","commit_stats":null,"previous_names":["infinitensor/ninetoothed"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fninetoothed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fninetoothed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fninetoothed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fninetoothed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InfiniTensor","download_url":"https://codeload.github.com/InfiniTensor/ninetoothed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236102622,"owners_count":19095208,"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":"2025-01-28T23:17:42.383Z","updated_at":"2025-10-11T14:31:32.536Z","avatar_url":"https://github.com/InfiniTensor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NineToothed\n\n![NineToothed Logo](https://github.com/InfiniTensor/ninetoothed/raw/master/docs/source/_static/ninetoothed-logo.png)\n\n[![Document](https://img.shields.io/badge/Document-ready-blue)](https://ninetoothed.org/)\n[![PyPI Version](https://img.shields.io/pypi/v/ninetoothed?color=cyan)](https://pypi.org/project/ninetoothed/)\n[![License](https://img.shields.io/badge/license-Apache--2.0-green)](LICENSE)\n\nNineToothed is a Triton-based domain-specific language (DSL). By introducing **tensor-oriented meta-programming (TOM)**, it makes writing high-performance GPU kernels easier.\n\n## Installation\n\nWe can use `pip` to install `ninetoothed`.\n\n```shell\npip install ninetoothed\n```\n\nAfter successfully running the above command, `ninetoothed` will be installed. However, to fully utilize its capabilities, you also need to install a deep learning framework supported by `ninetoothed`. For trial purposes, we recommend installing `torch`.\n\n## Usage\n\nThanks to tensor-oriented meta-programming, NineToothed can be written using the **arrange-and-apply** paradigm, which involves separately defining `arrangement`, `application`, and `tensors`, and then integrating them using `ninetoothed.make` to generate the kernel.\n\n### Matrix Multiplication\n\nHere is the code we need for matrix multiplication:\n\n```python\nimport ninetoothed\nimport ninetoothed.language as ntl\nfrom ninetoothed import Tensor, block_size\n\nBLOCK_SIZE_M = block_size()\nBLOCK_SIZE_N = block_size()\nBLOCK_SIZE_K = block_size()\n\n\ndef arrangement(input, other, output):\n    output_arranged = output.tile((BLOCK_SIZE_M, BLOCK_SIZE_N))\n\n    input_arranged = input.tile((BLOCK_SIZE_M, BLOCK_SIZE_K))\n    input_arranged = input_arranged.tile((1, -1))\n    input_arranged = input_arranged.expand((-1, output_arranged.shape[1]))\n    input_arranged.dtype = input_arranged.dtype.squeeze(0)\n\n    other_arranged = other.tile((BLOCK_SIZE_K, BLOCK_SIZE_N))\n    other_arranged = other_arranged.tile((-1, 1))\n    other_arranged = other_arranged.expand((output_arranged.shape[0], -1))\n    other_arranged.dtype = other_arranged.dtype.squeeze(1)\n\n    return input_arranged, other_arranged, output_arranged\n\n\ndef application(input, other, output):\n    accumulator = ntl.zeros(output.shape, dtype=ntl.float32)\n\n    for k in range(input.shape[0]):\n        accumulator += ntl.dot(input[k], other[k])\n\n    output = accumulator\n\n\ntensors = (Tensor(2), Tensor(2), Tensor(2))\n\nkernel = ninetoothed.make(arrangement, application, tensors)\n```\n\n## Useful Links\n\n- [NineToothed Documentation](https://ninetoothed.org/)\n- [NineToothed Operators](https://github.com/InfiniTensor/ntops)\n- [NineToothed Examples](https://github.com/InfiniTensor/ninetoothed-examples)\n\n## License\n\nThis project is distributed under the Apache-2.0 license. See the included [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitensor%2Fninetoothed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfinitensor%2Fninetoothed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitensor%2Fninetoothed/lists"}