Inline helper: add weighted source into target. * Sparse path: ~8 operations, ~48 bytes source memory traffic. * Dense path: 768 mul-adds with int8→float conversion, ~768 bytes traffic. */
| 848 | * Sparse path: ~8 operations, ~48 bytes source memory traffic. |
| 849 | * Dense path: 768 mul-adds with int8→float conversion, ~768 bytes traffic. */ |
| 850 | static inline void sem_vec_add_src_scaled(cbm_sem_vec_t *dst, const cbm_sem_src_entry_t *src, |
| 851 | float scale) { |
| 852 | if (src->is_sparse) { |
| 853 | for (int k = 0; k < src->nnz; k++) { |
| 854 | dst->v[src->indices[k]] += scale * src->values[k]; |
| 855 | } |
| 856 | } else { |
| 857 | const int8_t *s = src->dense_int8; |
| 858 | const float mul = scale * (CBM_SEM_UNIT_POS / CBM_SEM_INT8_MAX); |
| 859 | for (int d = 0; d < CBM_SEM_DIM; d++) { |
| 860 | dst->v[d] += mul * (float)s[d]; |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | /* Pass 1 context: uses sparse/int8 tagged sources (most memory-efficient). */ |
| 866 | typedef struct { |
no outgoing calls
no test coverage detected