char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
856c3adac
char/aliceai-t5-moe
1#ifndef HVX_REPL_H 2#define HVX_REPL_H 3 4#include <assert.h> 5#include <stddef.h> 6#include <stdint.h> 7 8#include "hvx-base.h" 9 10static inline HVX_Vector hvx_vec_repl (HVX_Vector v ,const uint8_t * ctrl ) { 11return Q6_V_vdelta_VV (v ,hvx_vmem (ctrl )); 12} 13 14static inline HVX_Vector hvx_vec_repl_u32 (HVX_Vector v ) { 15// vdelta control to replicate first 4 bytes across all lanes 16static const uint8_t __attribute__((aligned (128 )))repl [128 ]= { 170x00 ,0x00 ,0x00 ,0x00 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 180x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 190x20 ,0x20 ,0x20 ,0x20 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 200x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 210x40 ,0x40 ,0x40 ,0x40 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 220x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 230x20 ,0x20 ,0x20 ,0x20 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 240x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 25 }; 26return hvx_vec_repl (v ,repl ); 27} 28 29static inline HVX_Vector hvx_vec_repl_f32 (HVX_Vector v ) { 30// vdelta control to replicate first 4 bytes across all lanes 31static const uint8_t __attribute__((aligned (128 )))repl [128 ]= { 320x00 ,0x00 ,0x00 ,0x00 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 330x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 340x20 ,0x20 ,0x20 ,0x20 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 350x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 360x40 ,0x40 ,0x40 ,0x40 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 370x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 380x20 ,0x20 ,0x20 ,0x20 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 390x10 ,0x10 ,0x10 ,0x10 ,0x04 ,0x04 ,0x04 ,0x04 ,0x08 ,0x08 ,0x08 ,0x08 ,0x04 ,0x04 ,0x04 ,0x04 , 40 }; 41return hvx_vec_repl (v ,repl ); 42} 43 44static inline HVX_Vector hvx_vec_repl_f16 (HVX_Vector v ) { 45// vdelta control to replicate first two bytes across all lanes 46static const uint8_t __attribute__((aligned (128 )))repl [128 ]= { 470x00 ,0x00 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 480x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 490x20 ,0x20 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 500x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 510x40 ,0x40 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 520x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 530x20 ,0x20 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 540x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 55 }; 56return hvx_vec_repl (v ,repl ); 57} 58 59static inline HVX_Vector hvx_vec_repl_2x_f16 (HVX_Vector v ) { 60// vdelta control to splat a pair of f16s: first half = f16[0], second half = f16[1] 61static const uint8_t __attribute__((aligned (128 )))repl [128 ]= { 620x00 ,0x00 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 630x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 640x20 ,0x20 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 650x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 , 660x02 ,0x02 ,0x40 ,0x40 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 , 670x02 ,0x02 ,0x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 , 680x02 ,0x02 ,0x20 ,0x20 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 , 690x02 ,0x02 ,0x10 ,0x10 ,0x02 ,0x02 ,0x04 ,0x04 ,0x02 ,0x02 ,0x08 ,0x08 ,0x02 ,0x02 ,0x04 ,0x04 , 70 }; 71return hvx_vec_repl (v ,repl ); 72} 73 74#endif // HVX_REPL_H