From fd53378b276b4f7b0bbeafa2dceb3d6d3bbfb684 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 15 Jan 2020 10:49:28 -0800 Subject: [PATCH] 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 --- tensorflow/lite/experimental/ruy/test.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tensorflow/lite/experimental/ruy/test.h b/tensorflow/lite/experimental/ruy/test.h index 4ba0920dfe8..54101b308bb 100644 --- a/tensorflow/lite/experimental/ruy/test.h +++ b/tensorflow/lite/experimental/ruy/test.h @@ -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::infinity(); - spec->clamp_max = std::numeric_limits::infinity(); - return; - } - if (std::is_same::value) { // Returning raw accumulators, clamping is not supported. spec->clamp_min = std::numeric_limits::lowest(); @@ -1473,6 +1467,17 @@ void MakeSpecClampFields(Spec* spec) { return; } + if (getenv("BENCHMARK_ONLY_MATMUL")) { + if (std::is_floating_point::value) { + spec->clamp_min = -std::numeric_limits::infinity(); + spec->clamp_max = std::numeric_limits::infinity(); + } else { + spec->clamp_min = std::numeric_limits::lowest(); + spec->clamp_max = std::numeric_limits::max(); + } + return; + } + spec->clamp_min = std::numeric_limits::lowest() + 1; spec->clamp_max = std::numeric_limits::max() - 1; } @@ -1507,8 +1512,8 @@ template void TestSet::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(); }