Flag to disable Variable

Summary:
using `buck build mode/opt mode/no-gpu //experimental/ngimel/benchmark_framework_overheads:cpp_benchmark`

```
devvm497.prn3.facebook.com:/data/users/bwasti/fbsource/fbcode $ ./cpp_benchmark --niter 10000
creating inputs, number of dimensions 1
starting op
benchmarking 10000 iterations
using cpp frontend
elapsed time per iteration 0.90638 us
```

```
devvm497.prn3.facebook.com:/data/users/bwasti/fbsource/fbcode $ ./cpp_benchmark --niter 10000 --disable_variable_dispatch
creating inputs, number of dimensions 1
starting op
benchmarking 10000 iterations
using cpp frontend
elapsed time per iteration 0.775436 us
```

Test Plan: let all tests run

Reviewed By: smessmer

Differential Revision: D18654276

fbshipit-source-id: 362812b2c87ec428448b2ac65baac45f492fdce4
This commit is contained in:
Bram Wasti 2019-11-26 14:29:26 -08:00 committed by Facebook Github Bot
parent 4eff2f2007
commit 92e27c5e89
3 changed files with 13 additions and 2 deletions

View file

@ -57,7 +57,7 @@ bool cudnn_is_acceptable(const Tensor& self) {
Tensor detach(const Tensor& self) {
#ifndef USE_STATIC_DISPATCH
// this just exists to give us a hook in VariableType and an entry in Declarations.yaml
AT_ERROR("detach is not implemented for Tensor");
//AT_ERROR("detach is not implemented for Tensor");
#endif
// this is no-op for USE_STATIC_DISPATCH mode
return self;
@ -66,7 +66,7 @@ Tensor detach(const Tensor& self) {
Tensor & detach_(Tensor & self) {
#ifndef USE_STATIC_DISPATCH
// this just exists to give us a hook in VariableType and an entry in Declarations.yaml
AT_ERROR("detach_ is not implemented for Tensor");
//AT_ERROR("detach_ is not implemented for Tensor");
#endif
// this is no-op for USE_STATIC_DISPATCH mode
return self;

View file

@ -5,6 +5,8 @@
namespace c10 {
namespace impl {
C10_DEFINE_bool(disable_variable_dispatch, false, "This flag forcibly disables the Variable code paths from executing, which currently breaks profiling in the process.");
namespace {
/// In the CAFFE2_FB_LIMITED_MOBILE_CAPABILITY build setting,
@ -23,6 +25,12 @@ static PODLocalTensorTypeSet raw_local_tensor_type_set;
} // anonymous namespace
LocalTensorTypeSet tls_local_tensor_type_set() {
// Hack until variable performance is fixed
if (FLAGS_disable_variable_dispatch) {
raw_local_tensor_type_set.set_excluded(
raw_local_tensor_type_set.excluded().add(
TensorTypeId::VariableTensorId));
}
return raw_local_tensor_type_set;
}

View file

@ -1,6 +1,7 @@
#pragma once
#include <c10/core/TensorTypeSet.h>
#include <c10/util/Flags.h>
// TLS management for TensorTypeSet (the "local" TensorTypeSet(s))
//
@ -22,6 +23,8 @@
namespace c10 {
namespace impl {
C10_DECLARE_bool(disable_variable_dispatch);
// POD version of LocalTensorTypeSet. Declared here just so that
// we can put it in the guards.
struct C10_API PODLocalTensorTypeSet {