Inline helper: initialize a target vector from a sparse/dense source. */
| 830 | |
| 831 | /* Inline helper: initialize a target vector from a sparse/dense source. */ |
| 832 | static inline void sem_target_init_from_src(cbm_sem_vec_t *dst, const cbm_sem_src_entry_t *src) { |
| 833 | memset(dst, 0, sizeof(*dst)); |
| 834 | if (src->is_sparse) { |
| 835 | for (int k = 0; k < src->nnz; k++) { |
| 836 | dst->v[src->indices[k]] = src->values[k]; |
| 837 | } |
| 838 | } else { |
| 839 | const int8_t *s = src->dense_int8; |
| 840 | const float inv127 = CBM_SEM_UNIT_POS / CBM_SEM_INT8_MAX; |
| 841 | for (int d = 0; d < CBM_SEM_DIM; d++) { |
| 842 | dst->v[d] = inv127 * (float)s[d]; |
| 843 | } |
| 844 | } |
| 845 | } |
| 846 | |
| 847 | /* Inline helper: add weighted source into target. |
| 848 | * Sparse path: ~8 operations, ~48 bytes source memory traffic. |
no outgoing calls
no test coverage detected