-
Notifications
You must be signed in to change notification settings - Fork 74k
/
segment_reduction_ops_gpu_2.cu.cc
61 lines (46 loc) · 2.39 KB
/
segment_reduction_ops_gpu_2.cu.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Copyright 2021 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 || TENSORFLOW_USE_ROCM
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/segment_reduction_ops_gpu.cu.h"
namespace tensorflow {
namespace functor {
#define DEFINE_REAL_UNSORTED_GPU_SPECS_INDEX(T, Index) \
template struct UnsortedSegmentFunctor<GPUDevice, T, Index, \
functor::Lowest<T>, functor::Max>; \
template struct UnsortedSegmentFunctor<GPUDevice, T, Index, \
functor::Highest<T>, functor::Min>; \
template struct UnsortedSegmentFunctor<GPUDevice, T, Index, functor::One<T>, \
functor::Prod>;
// Sum is the only op that supports all input types currently.
#define DEFINE_SUM_UNSORTED_GPU_SPECS_INDEX(T, Index) \
template struct UnsortedSegmentFunctor<GPUDevice, T, Index, \
functor::Zero<T>, functor::Sum>;
#define DEFINE_REAL_GPU_SPECS(T) \
DEFINE_REAL_UNSORTED_GPU_SPECS_INDEX(T, int32); \
DEFINE_REAL_UNSORTED_GPU_SPECS_INDEX(T, int64_t);
#define DEFINE_SUM_GPU_SPECS(T) \
DEFINE_SUM_UNSORTED_GPU_SPECS_INDEX(T, int32); \
DEFINE_SUM_UNSORTED_GPU_SPECS_INDEX(T, int64_t);
TF_CALL_int32(DEFINE_REAL_GPU_SPECS);
TF_CALL_int32(DEFINE_SUM_GPU_SPECS);
// TODO(rocm): support atomicAdd for complex numbers on ROCm
#if GOOGLE_CUDA
TF_CALL_COMPLEX_TYPES(DEFINE_SUM_GPU_SPECS);
#endif
#undef DEFINE_REAL_UNSORTED_GPU_SPECS_INDEX
#undef DEFINE_SUM_UNSORTED_GPU_SPECS_INDEX
#undef DEFINE_REAL_GPU_SPECS
#undef DEFINE_SUM_GPU_SPECS
} // namespace functor
} // namespace tensorflow
#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM