Further tweaks to test logic enabling bias and clamping.

We actually want to benchmark with these features when comparing against other libraries where these might have nontrivial overhead.

PiperOrigin-RevId: 289891302
Change-Id: I25e66b00ff5c97782d2de11131824047b4d8a829
This commit is contained in:
Benoit Jacob 2020-01-15 10:49:28 -08:00 committed by TensorFlower Gardener
parent 1a68fde6fa
commit fd53378b27
1 changed files with 13 additions and 8 deletions

View File

@ -1460,12 +1460,6 @@ void MakeSpecClampFields(Spec* spec) {
using AccumScalar = typename Spec::AccumScalar;
using DstScalar = typename Spec::DstScalar;
if (getenv("BENCHMARK_ONLY_MATMUL")) {
spec->clamp_min = -std::numeric_limits<DstScalar>::infinity();
spec->clamp_max = std::numeric_limits<DstScalar>::infinity();
return;
}
if (std::is_same<AccumScalar, std::int32_t>::value) {
// Returning raw accumulators, clamping is not supported.
spec->clamp_min = std::numeric_limits<DstScalar>::lowest();
@ -1473,6 +1467,17 @@ void MakeSpecClampFields(Spec* spec) {
return;
}
if (getenv("BENCHMARK_ONLY_MATMUL")) {
if (std::is_floating_point<DstScalar>::value) {
spec->clamp_min = -std::numeric_limits<DstScalar>::infinity();
spec->clamp_max = std::numeric_limits<DstScalar>::infinity();
} else {
spec->clamp_min = std::numeric_limits<DstScalar>::lowest();
spec->clamp_max = std::numeric_limits<DstScalar>::max();
}
return;
}
spec->clamp_min = std::numeric_limits<DstScalar>::lowest() + 1;
spec->clamp_max = std::numeric_limits<DstScalar>::max() - 1;
}
@ -1507,8 +1512,8 @@ template <typename LhsScalar, typename RhsScalar, typename SpecType>
void TestSet<LhsScalar, RhsScalar, SpecType>::MakeSpec() {
RUY_CHECK_EQ(life_stage, LifeStage::kHasLhsRhs);
if (!getenv("BENCHMARK_ONLY_MATMUL") && !benchmark &&
(global_random_engine()() & 1)) {
if (!getenv("BENCHMARK_ONLY_MATMUL") &&
(benchmark || (global_random_engine()() & 1))) {
MakeRandomVector(RandomRange::kBias, rows, &bias_data);
spec.bias = bias_data.data();
}