1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #if GOOGLE_CUDA 17 18 #include "tensorflow/core/kernels/scatter_functor.h" 19 #include "tensorflow/core/framework/register_types.h" 20 21 namespace tensorflow { 22 23 class OpKernelContext; 24 typedef Eigen::GpuDevice GPUDevice; 25 26 namespace functor { 27 28 // Forward declarations of the functor specializations for GPU. 29 #define DECLARE_GPU_SPECS_OP(T, Index, op) \ 30 template <> \ 31 Index ScatterFunctor<GPUDevice, T, Index, op>::operator()( \ 32 OpKernelContext* c, const GPUDevice& d, \ 33 typename TTypes<T>::Matrix params, \ 34 typename TTypes<T>::ConstMatrix updates, \ 35 typename TTypes<Index>::ConstFlat indices); \ 36 extern template struct ScatterFunctor<GPUDevice, T, Index, op>; 37 38 #define DECLARE_GPU_SPECS_INDEX(T, Index) \ 39 DECLARE_GPU_SPECS_OP(T, Index, scatter_op::UpdateOp::ASSIGN); \ 40 DECLARE_GPU_SPECS_OP(T, Index, scatter_op::UpdateOp::ADD); \ 41 DECLARE_GPU_SPECS_OP(T, Index, scatter_op::UpdateOp::SUB); \ 42 DECLARE_GPU_SPECS_OP(T, Index, scatter_op::UpdateOp::MUL); \ 43 DECLARE_GPU_SPECS_OP(T, Index, scatter_op::UpdateOp::DIV); 44 45 #define DECLARE_GPU_SPECS(T) \ 46 DECLARE_GPU_SPECS_INDEX(T, int32); \ 47 DECLARE_GPU_SPECS_INDEX(T, int64); 48 49 TF_CALL_GPU_NUMBER_TYPES_NO_HALF(DECLARE_GPU_SPECS); 50 51 #undef DECLARE_GPU_SPECS 52 #undef DECLARE_GPU_SPECS_INDEX 53 #undef DECLARE_GPU_SPECS_OP 54 55 } // namespace functor 56 } // namespace tensorflow 57 58 #else 59 60 #include "tensorflow/core/kernels/scatter_functor.h" 61 62 #endif // GOOGLE_CUDA 63