From 3cf519a53e214dae77ba5eac60d2c7901da75140 Mon Sep 17 00:00:00 2001 From: Daniel Keysers Date: Thu, 10 Oct 2024 11:30:38 -0700 Subject: [PATCH] Remove unused "two-sizes" version of MulByConstAndAdd. PiperOrigin-RevId: 684515900 --- ops/ops-inl.h | 16 ++++------------ ops/ops_test.cc | 9 ++++----- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/ops/ops-inl.h b/ops/ops-inl.h index 79f77bb..846ecc5 100644 --- a/ops/ops-inl.h +++ b/ops/ops-inl.h @@ -488,26 +488,18 @@ static HWY_INLINE HWY_MAYBE_UNUSED void MulByConst(const float c, MulByConst(c, x, size, size); } -static HWY_NOINLINE void MulByConstAndAdd(const float c, - const float* HWY_RESTRICT x, - float* HWY_RESTRICT out, - const size_t size, - const size_t max_pos) { +static HWY_NOINLINE HWY_MAYBE_UNUSED void MulByConstAndAdd( + float c, const float* HWY_RESTRICT x, float* HWY_RESTRICT out, + size_t size) { namespace hn = hwy::HWY_NAMESPACE; using D = hn::ScalableTag; using V = hn::Vec; - hn::Transform1(D(), out, max_pos, x, + hn::Transform1(D(), out, size, x, [c](const auto d, const V v_out, const V v_x) HWY_ATTR { return hn::MulAdd(v_x, hn::Set(d, c), v_out); }); } -static HWY_INLINE HWY_MAYBE_UNUSED void MulByConstAndAdd( - float c, const float* HWY_RESTRICT x, float* HWY_RESTRICT out, - size_t size) { - MulByConstAndAdd(c, x, out, size, size); -} - // See below for a specialized version for top-1 sampling. static HWY_NOINLINE void Softmax(float* HWY_RESTRICT x, const size_t size, const size_t mask_pos) { diff --git a/ops/ops_test.cc b/ops/ops_test.cc index ddce780..6ac5115 100644 --- a/ops/ops_test.cc +++ b/ops/ops_test.cc @@ -106,9 +106,8 @@ HWY_NOINLINE void SourceMulByConst(float c, float* HWY_RESTRICT x, size_t size, } HWY_NOINLINE void SourceMulByConstAndAdd(float c, const float* HWY_RESTRICT x, - float* HWY_RESTRICT out, size_t size, - size_t max_pos) { - for (size_t i = 0; i < max_pos; ++i) { + float* HWY_RESTRICT out, size_t size) { + for (size_t i = 0; i < size; ++i) { out[i] += x[i] * c; } } @@ -234,8 +233,8 @@ struct TestMulByConstAndAdd { } T constant = Random(rng); - SourceMulByConstAndAdd(constant, o, e, count, count); - MulByConstAndAdd(constant, o, x, count, count); + SourceMulByConstAndAdd(constant, o, e, count); + MulByConstAndAdd(constant, o, x, count); hwy::AssertArraySimilar(e, x, count, hwy::TargetName(HWY_TARGET), __FILE__, __LINE__);