Fix non simd f16 build (#3097)
This commit is contained in:
@@ -29,6 +29,14 @@ struct Simd<T, 1> {
|
||||
Simd(Simd<U, 1> v) : value(v.value) {}
|
||||
template <typename U>
|
||||
Simd(U v) : value(v) {}
|
||||
|
||||
T operator[](int) const {
|
||||
return value;
|
||||
}
|
||||
|
||||
T& operator[](int) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, int N>
|
||||
|
||||
@@ -155,11 +155,18 @@ struct FromFP8 {
|
||||
template <int N>
|
||||
Simd<float, N> operator()(Simd<uint8_t, N> x) {
|
||||
auto v = Simd<uint16_t, N>(x & 127) << 7;
|
||||
auto converted = *(Simd<float16_t, N>*)(&v);
|
||||
converted = converted * 256.0;
|
||||
Simd<float, N> out;
|
||||
if constexpr (simd::max_size<float16_t> >= N) {
|
||||
auto converted = *(Simd<float16_t, N>*)(&v);
|
||||
out = converted * 256.0;
|
||||
} else {
|
||||
for (int i = 0; i < N; ++i) {
|
||||
auto converted = *(float16_t*)(&v[i]);
|
||||
out[i] = converted * 256.0;
|
||||
}
|
||||
}
|
||||
auto sign = Simd<bool, N>(x & 128);
|
||||
Simd<float, N> out = select(sign, -converted, converted);
|
||||
return out;
|
||||
return select(sign, -out, out);
|
||||
}
|
||||
float operator()(uint8_t x) {
|
||||
return (*this)(Simd<uint8_t, 1>(x)).value;
|
||||
|
||||
Reference in New Issue
Block a user