diff options
author | 2017-07-13 13:06:10 -0700 | |
---|---|---|
committer | 2017-07-13 13:10:50 -0700 | |
commit | 3ed1893512c73a1878f3a5d6b846a03ed7174cbb (patch) | |
tree | 92f6dfcbc9831af392f9ec7e5e394cab95976e0e /tensorflow/core/kernels/dense_update_functor_gpu.cu.cc | |
parent | 93826fac842e370a3a4689a93fd4dac02cd8cb41 (diff) |
Automated g4 rollback of changelist 161781962
PiperOrigin-RevId: 161851851
Diffstat (limited to 'tensorflow/core/kernels/dense_update_functor_gpu.cu.cc')
-rw-r--r-- | tensorflow/core/kernels/dense_update_functor_gpu.cu.cc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/dense_update_functor_gpu.cu.cc b/tensorflow/core/kernels/dense_update_functor_gpu.cu.cc new file mode 100644 index 0000000000..208401cb24 --- /dev/null +++ b/tensorflow/core/kernels/dense_update_functor_gpu.cu.cc @@ -0,0 +1,69 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#if GOOGLE_CUDA + +#define EIGEN_USE_GPU + +#include "tensorflow/core/kernels/dense_update_functor.h" + +#include "tensorflow/core/framework/register_types.h" + +namespace tensorflow { + +typedef Eigen::GpuDevice GPUDevice; + +namespace functor { + +template <typename T> +struct DenseUpdate<GPUDevice, T, ASSIGN> { + void operator()(const GPUDevice& d, typename TTypes<T>::Flat params, + typename TTypes<T>::ConstFlat update) { + params.device(d) = update; + } +}; + +template <typename T> +struct DenseUpdate<GPUDevice, T, ADD> { + void operator()(const GPUDevice& d, typename TTypes<T>::Flat params, + typename TTypes<T>::ConstFlat update) { + params.device(d) += update; + } +}; + +template <typename T> +struct DenseUpdate<GPUDevice, T, SUB> { + void operator()(const GPUDevice& d, typename TTypes<T>::Flat params, + typename TTypes<T>::ConstFlat update) { + params.device(d) -= update; + } +}; + +} // namespace functor + +#define DEFINE_GPU_KERNELS(T) \ + template struct functor::DenseUpdate<GPUDevice, T, ADD>; \ + template struct functor::DenseUpdate<GPUDevice, T, SUB>; +TF_CALL_GPU_NUMBER_TYPES(DEFINE_GPU_KERNELS); +#undef DEFINE_GPU_KERNELS + +#define DEFINE_GPU_KERNELS(T) \ + template struct functor::DenseUpdate<GPUDevice, T, ASSIGN>; +TF_CALL_GPU_ALL_TYPES(DEFINE_GPU_KERNELS); +#undef DEFINE_GPU_KERNELS + +} // end namespace tensorflow + +#endif // GOOGLE_CUDA |