From 36e4ce080e77aa1126a3d26f22a4e7bd656a7c91 Mon Sep 17 00:00:00 2001 From: Alex Stark <starka@google.com> Date: Fri, 6 Sep 2019 07:19:33 -0700 Subject: [PATCH] Ruy: Add mechanism to mask out paths. For example, a "superior" path like AVX-512 can be disabled so that an "inferior" path like AVX2 is executed on a more capable machine. PiperOrigin-RevId: 267592238 --- tensorflow/lite/experimental/ruy/context.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tensorflow/lite/experimental/ruy/context.cc b/tensorflow/lite/experimental/ruy/context.cc index aea42cdf501..f85a5cc5fa7 100644 --- a/tensorflow/lite/experimental/ruy/context.cc +++ b/tensorflow/lite/experimental/ruy/context.cc @@ -40,6 +40,13 @@ Path Context::GetRuntimeEnabledPaths() { // Need to resolve now. Start by considering all paths enabled. runtime_enabled_paths_ = kAllPaths; + // This mechanism is intended to be used for testing and benchmarking. For + // example, one can set RUY_FORCE_DISABLE_PATHS to Path::kAvx512 in order to + // evaluate AVX2 performance on an AVX-512 machine. +#ifdef RUY_FORCE_DISABLE_PATHS + runtime_enabled_paths_ = runtime_enabled_paths_ & ~(RUY_FORCE_DISABLE_PATHS); +#endif + #if RUY_PLATFORM(ARM) // Now selectively disable paths that aren't supported on this machine. if ((runtime_enabled_paths_ & Path::kNeonDotprod) != Path::kNone) {