mirror of https://github.com/google/gemma.cpp.git
Update to Highway 1.2 for topology/VQSelect
Also fix unused-warning in compress-inl. PiperOrigin-RevId: 639116915
This commit is contained in:
parent
5feacf120c
commit
a44cbdadc2
|
|
@ -22,7 +22,7 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG da250571a45826b21eebbddc1e50d0c1137dee5f EXCLUDE_FROM_ALL)
|
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 457c891775a7397bdb0376bb1031e6e027af1c48 EXCLUDE_FROM_ALL)
|
||||||
FetchContent_MakeAvailable(highway)
|
FetchContent_MakeAvailable(highway)
|
||||||
|
|
||||||
## Note: absl needs to be installed by sentencepiece. This will only happen if
|
## Note: absl needs to be installed by sentencepiece. This will only happen if
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,8 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "hwy",
|
name = "hwy",
|
||||||
urls = ["https://github.com/google/highway/archive/refs/tags/1.1.0.zip"],
|
urls = ["https://github.com/google/highway/archive/refs/tags/1.2.0.zip"],
|
||||||
integrity = "sha256-zkJX2SwL4wQ0nHMsURW7MDLEf43vFSnqhSUsUM6eQmY=",
|
integrity = "sha256-fbtKAGj5hhhBr5Bggtsrj4aIodC2OHb1njB8LGfom8A=", strip_prefix = "highway-1.2.0",
|
||||||
strip_prefix = "highway-1.1.0",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
|
|
|
||||||
|
|
@ -244,10 +244,6 @@ struct CompressTraits<hwy::bfloat16_t> {
|
||||||
VF32 sum2 = Zero(df32);
|
VF32 sum2 = Zero(df32);
|
||||||
VF32 sum3 = Zero(df32);
|
VF32 sum3 = Zero(df32);
|
||||||
|
|
||||||
const hn::RebindToUnsigned<decltype(df32)> du32;
|
|
||||||
using VU32 = hn::VFromD<decltype(du32)>;
|
|
||||||
const VU32 odd = Set(du32, 0xFFFF0000u);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < num; /* i += 2 * N */) {
|
for (size_t i = 0; i < num; /* i += 2 * N */) {
|
||||||
const auto interleaved0 = hn::LoadU(dbf16, in + in_ofs + i);
|
const auto interleaved0 = hn::LoadU(dbf16, in + in_ofs + i);
|
||||||
const VF32 ae0 = Load(df32, vec_aligned + i);
|
const VF32 ae0 = Load(df32, vec_aligned + i);
|
||||||
|
|
|
||||||
|
|
@ -161,12 +161,8 @@ class DistortionStats {
|
||||||
std::vector<float> weights(l1_); // copy so we can modify
|
std::vector<float> weights(l1_); // copy so we can modify
|
||||||
const float median = [&weights]() {
|
const float median = [&weights]() {
|
||||||
const size_t mid = weights.size() / 2;
|
const size_t mid = weights.size() / 2;
|
||||||
// We just want the median; partial sort is faster if available (v1.2).
|
// We just want the median; partial sort is faster.
|
||||||
#if HWY_MAJOR > 1 || HWY_MINOR >= 2
|
|
||||||
hwy::VQSelect(weights.data(), weights.size(), mid, hwy::SortAscending());
|
hwy::VQSelect(weights.data(), weights.size(), mid, hwy::SortAscending());
|
||||||
#else
|
|
||||||
hwy::VQSort(weights.data(), weights.size(), hwy::SortAscending());
|
|
||||||
#endif
|
|
||||||
return weights[mid];
|
return weights[mid];
|
||||||
}();
|
}();
|
||||||
weights = l1_; // restore original order
|
weights = l1_; // restore original order
|
||||||
|
|
|
||||||
|
|
@ -637,13 +637,9 @@ class SfpCodec {
|
||||||
const hn::Repartition<uint8_t, DBF> d8;
|
const hn::Repartition<uint8_t, DBF> d8;
|
||||||
V8 lo, hi;
|
V8 lo, hi;
|
||||||
DecBytes(d8, packed, lo, hi);
|
DecBytes(d8, packed, lo, hi);
|
||||||
#if HWY_MAJOR > 1 || HWY_MINOR >= 2
|
// (Supported since Highway 1.2)
|
||||||
even = hn::BitCast(dbf, hn::InterleaveEven(d8, lo, hi));
|
even = hn::BitCast(dbf, hn::InterleaveEven(d8, lo, hi));
|
||||||
odd = hn::BitCast(dbf, hn::InterleaveOdd(d8, lo, hi));
|
odd = hn::BitCast(dbf, hn::InterleaveOdd(d8, lo, hi));
|
||||||
#else
|
|
||||||
even = hn::BitCast(dbf, hn::OddEven(hn::DupEven(hi), lo));
|
|
||||||
odd = hn::BitCast(dbf, hn::OddEven(hi, hn::DupOdd(lo)));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class DF, HWY_IF_F32_D(DF),
|
template <class DF, HWY_IF_F32_D(DF),
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,10 @@
|
||||||
#include "hwy/highway.h"
|
#include "hwy/highway.h"
|
||||||
#include "hwy/per_target.h"
|
#include "hwy/per_target.h"
|
||||||
#include "hwy/profiler.h"
|
#include "hwy/profiler.h"
|
||||||
#include "hwy/timer.h"
|
|
||||||
|
#if (!defined(HWY_VERSION_LT) || HWY_VERSION_LT(1, 2)) && !HWY_IDE
|
||||||
|
#error "Please update to version 1.2 of github.com/google/highway."
|
||||||
|
#endif
|
||||||
|
|
||||||
static constexpr bool kVerboseLogTokens = false;
|
static constexpr bool kVerboseLogTokens = false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue