Skip to content

Commit

Permalink
Remove unused "two-sizes" version of MulByConstAndAdd.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 684515900
  • Loading branch information
danielkeysers authored and copybara-github committed Oct 10, 2024
1 parent 1eb9ce1 commit 3cf519a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
16 changes: 4 additions & 12 deletions ops/ops-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>;
using V = hn::Vec<D>;
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) {
Expand Down
9 changes: 4 additions & 5 deletions ops/ops_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -234,8 +233,8 @@ struct TestMulByConstAndAdd {
}
T constant = Random<T>(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__);
Expand Down

0 comments on commit 3cf519a

Please sign in to comment.