# Causal depthwise conv1d in CUDA with a PyTorch interface
Features:
- Support fp32, fp16, bf16.
- Kernel size 2, 3, 4.
## How to use
```python
from causal_conv1d import causal_conv1d_fn
```
```python
def causal_conv1d_fn(x, weight, bias=None, activation=None):
"""
x: (batch, dim, seqlen)
weight: (dim, width)
bias: (dim,)
activation: either None or "silu" or "swish"
out: (batch, dim, seqlen)
"""
```
Equivalent to:
```python
import torch.nn.functional as F
F.conv1d(x, weight.unsqueeze(1), bias, padding=width - 1, groups=dim)[..., :seqlen]
```
## Additional Prerequisites for AMD cards
### Patching ROCm
If you are on ROCm 6.0, run the following steps to avoid errors during compilation. This is not required for ROCm 6.1 onwards.
1. Locate your ROCm installation directory. This is typically found at `/opt/rocm/`, but may vary depending on your installation.
2. Apply the Patch. Run with `sudo` in case you encounter permission issues.
```bash
patch /opt/rocm/include/hip/amd_detail/amd_hip_bf16.h < rocm_patch/rocm6_0.patch
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Dao-AILab/causal-conv1d",
"name": "causal-conv1d",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Tri Dao",
"author_email": "tri@tridao.me",
"download_url": "https://files.pythonhosted.org/packages/51/2a/5d5ce2bbc1dd20ed98c57a7e3456aaab2f5a25088aaf1fbb74142450054f/causal_conv1d-1.5.0.post8.tar.gz",
"platform": null,
"description": "# Causal depthwise conv1d in CUDA with a PyTorch interface\n\nFeatures:\n- Support fp32, fp16, bf16.\n- Kernel size 2, 3, 4.\n\n## How to use\n\n```python\nfrom causal_conv1d import causal_conv1d_fn\n```\n\n```python\ndef causal_conv1d_fn(x, weight, bias=None, activation=None):\n \"\"\"\n x: (batch, dim, seqlen)\n weight: (dim, width)\n bias: (dim,)\n activation: either None or \"silu\" or \"swish\"\n\n out: (batch, dim, seqlen)\n \"\"\"\n```\n\nEquivalent to:\n```python\nimport torch.nn.functional as F\n\nF.conv1d(x, weight.unsqueeze(1), bias, padding=width - 1, groups=dim)[..., :seqlen]\n```\n\n## Additional Prerequisites for AMD cards\n\n### Patching ROCm\n\nIf you are on ROCm 6.0, run the following steps to avoid errors during compilation. This is not required for ROCm 6.1 onwards.\n\n1. Locate your ROCm installation directory. This is typically found at `/opt/rocm/`, but may vary depending on your installation.\n\n2. Apply the Patch. Run with `sudo` in case you encounter permission issues.\n ```bash\n patch /opt/rocm/include/hip/amd_detail/amd_hip_bf16.h < rocm_patch/rocm6_0.patch \n ```\n",
"bugtrack_url": null,
"license": null,
"summary": "Causal depthwise conv1d in CUDA, with a PyTorch interface",
"version": "1.5.0.post8",
"project_urls": {
"Homepage": "https://github.com/Dao-AILab/causal-conv1d"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "512a5d5ce2bbc1dd20ed98c57a7e3456aaab2f5a25088aaf1fbb74142450054f",
"md5": "40cdfa95a4853efb2cbf4a4bc1ebecfd",
"sha256": "b3dc31fac0278da281b3f24ab164b01bd4518ac744e9fdd8d5d65adbf45b7136"
},
"downloads": -1,
"filename": "causal_conv1d-1.5.0.post8.tar.gz",
"has_sig": false,
"md5_digest": "40cdfa95a4853efb2cbf4a4bc1ebecfd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 9401,
"upload_time": "2024-12-06T09:48:49",
"upload_time_iso_8601": "2024-12-06T09:48:49.687560Z",
"url": "https://files.pythonhosted.org/packages/51/2a/5d5ce2bbc1dd20ed98c57a7e3456aaab2f5a25088aaf1fbb74142450054f/causal_conv1d-1.5.0.post8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-06 09:48:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Dao-AILab",
"github_project": "causal-conv1d",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "causal-conv1d"
}