Spaces:
Sleeping
Sleeping
Download spac/sparse/linear.py from Jack04810/SPAC-4B-ZeroGPU: direct link, hf CLI and curl.
- Browser
- Download file 303 Bytes
-
https://huggingface.co/spaces/Jack04810/SPAC-4B-ZeroGPU/resolve/main/spac/sparse/linear.py
- Command line
-
hf download hf://spaces/Jack04810/SPAC-4B-ZeroGPU/spac/sparse/linear.py
-
curl -L -o linear.py https://huggingface.co/spaces/Jack04810/SPAC-4B-ZeroGPU/resolve/main/spac/sparse/linear.py
303 Bytes
| """Apply a linear layer to sparse feature rows.""" | |
| import torch.nn as nn | |
| from . import SparseTensor | |
| class SparseLinear(nn.Linear): | |
| def forward(self, value: SparseTensor) -> SparseTensor: | |
| features = value.feats.to(self.weight.dtype) | |
| return value.replace(super().forward(features)) | |