Download cstack/include/l1_tensor.h from Snapkitty/flash-attention-rtl: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/Snapkitty/flash-attention-rtl/resolve/main/cstack/include/l1_tensor.h
- Command line
-
hf download hf://Snapkitty/flash-attention-rtl/cstack/include/l1_tensor.h
-
curl -L -o l1_tensor.h https://huggingface.co/Snapkitty/flash-attention-rtl/resolve/main/cstack/include/l1_tensor.h
1.25 kB
| /* Layer 1 - UAC: dense tensors over F_p, rank 1..CS_TENSOR_MAX_RANK, row-major. */ | |
| typedef struct tensor { | |
| size_t rank; | |
| size_t shape[CS_TENSOR_MAX_RANK]; | |
| gl_t *d; | |
| size_t size; | |
| } tensor; | |
| cs_status tensor_new(tensor *t, size_t rank, const size_t *shape); /* zero-filled */ | |
| void tensor_free(tensor *t); | |
| cs_status tensor_get(const tensor *t, const size_t *idx, gl_t *out); | |
| cs_status tensor_set(tensor *t, const size_t *idx, gl_t v); | |
| cs_status tensor_add(const tensor *a, const tensor *b, tensor *out); | |
| cs_status tensor_hadamard(const tensor *a, const tensor *b, tensor *out); | |
| /* out[i..., j...] = a[i...] * b[j...]; rank(a) + rank(b) <= CS_TENSOR_MAX_RANK */ | |
| cs_status tensor_outer(const tensor *a, const tensor *b, tensor *out); | |
| /* Sum over a's axis_a and b's axis_b (extents must match). Result rank = ra + rb - 2 (>= 1). */ | |
| cs_status tensor_contract(const tensor *a, size_t axis_a, const tensor *b, size_t axis_b, tensor *out); | |
| cs_status tensor_from_pmat(const pmat *m, tensor *t); | |
| cs_status tensor_to_pmat(const tensor *t, pmat *m); /* rank 2 only */ | |