Skip to content

Commit

Permalink
Adding an environment variable to control whether to use Cudnn with A…
Browse files Browse the repository at this point in the history
…vgPool:

TF_AVGPOOL_USE_CUDNN. The default is false for now.
Change: 127123594
  • Loading branch information
zheng-xq authored and tensorflower-gardener committed Jul 11, 2016
1 parent fe436f7 commit 7f37ded
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tensorflow/core/kernels/avgpooling_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ limitations under the License.
#if GOOGLE_CUDA
#include "tensorflow/core/kernels/maxpooling_op_gpu.h"
#include "tensorflow/core/kernels/pooling_ops_common_gpu.h"
#include "tensorflow/core/util/use_cudnn.h"
#endif // GOOGLE_CUDA

namespace tensorflow {
Expand Down Expand Up @@ -150,7 +151,7 @@ class AvgPoolingOp<GPUDevice, T> : public UnaryOp<T> {

TensorShape output_shape = params.forward_output_shape();

if (data_format_ == FORMAT_NCHW) {
if (internal::AvgPoolUseCudnn() || data_format_ == FORMAT_NCHW) {
DnnPoolingOp<T>::Compute(
context, perftools::gputools::dnn::PoolingMode::kAverage, ksize_,
stride_, padding_, data_format_, tensor_in, output_shape);
Expand Down
7 changes: 7 additions & 0 deletions tensorflow/core/util/use_cudnn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ bool CudnnUseAutotune() {
return ReadBoolFromEnvVar("TF_CUDNN_USE_AUTOTUNE", true);
}

namespace internal {

bool AvgPoolUseCudnn() {
return ReadBoolFromEnvVar("TF_AVGPOOL_USE_CUDNN", false);
}

} // namespace internal
} // namespace tensorflow
6 changes: 6 additions & 0 deletions tensorflow/core/util/use_cudnn.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ namespace tensorflow {
bool CanUseCudnn();
bool CudnnUseAutotune();

namespace internal {

// This function is for transition only. And it may go away at any time.
bool AvgPoolUseCudnn();

} // namespace internal
} // namespace tensorflow

#endif // TENSORFLOW_UTIL_USE_CUDNN_H_

1 comment on commit 7f37ded

@cancan101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zheng-xq Why is TF_AVGPOOL_USE_CUDNN defaulted to false?

Please sign in to comment.