• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "tensorflow/core/kernels/cwise_ops_common.h"
17 
18 namespace tensorflow {
19 REGISTER6(BinaryOp, CPU, "Add", functor::add, float, Eigen::half, double, int32,
20           int64, bfloat16);
21 REGISTER6(BinaryOp, CPU, "AddV2", functor::add, float, Eigen::half, double,
22           int32, int64, bfloat16);
23 
24 #if GOOGLE_CUDA
25 REGISTER3(BinaryOp, GPU, "Add", functor::add, float, Eigen::half, double);
26 REGISTER3(BinaryOp, GPU, "AddV2", functor::add, float, Eigen::half, double);
27 
28 // A special GPU kernel for int32.
29 // TODO(b/25387198): Also enable int32 in device memory. This kernel
30 // registration requires all int32 inputs and outputs to be in host memory.
31 REGISTER_KERNEL_BUILDER(Name("Add")
32                             .Device(DEVICE_GPU)
33                             .HostMemory("x")
34                             .HostMemory("y")
35                             .HostMemory("z")
36                             .TypeConstraint<int32>("T"),
37                         BinaryOp<CPUDevice, functor::add<int32>>);
38 REGISTER_KERNEL_BUILDER(Name("AddV2")
39                             .Device(DEVICE_GPU)
40                             .HostMemory("x")
41                             .HostMemory("y")
42                             .HostMemory("z")
43                             .TypeConstraint<int32>("T"),
44                         BinaryOp<CPUDevice, functor::add<int32>>);
45 #endif
46 
47 #if TENSORFLOW_USE_SYCL
48 #define REGISTER_KERNEL(type)                          \
49   REGISTER(BinaryOp, SYCL, "Add", functor::add, type); \
50   REEGISTER(BinaryOp, SYCL, "AddV2", functor::add, type);
51 
52 TF_CALL_SYCL_NUMBER_TYPES(REGISTER_KERNEL);
53 
54 REGISTER_KERNEL_BUILDER(Name("Add")
55                             .Device(DEVICE_SYCL)
56                             .HostMemory("x")
57                             .HostMemory("y")
58                             .HostMemory("z")
59                             .TypeConstraint<int32>("T"),
60                         BinaryOp<CPUDevice, functor::add<int32>>);
61 REGISTER_KERNEL_BUILDER(Name("AddV2")
62                             .Device(DEVICE_SYCL)
63                             .HostMemory("x")
64                             .HostMemory("y")
65                             .HostMemory("z")
66                             .TypeConstraint<int32>("T"),
67                         BinaryOp<CPUDevice, functor::add<int32>>);
68 #endif  // TENSORFLOW_USE_SYCL
69 }  // namespace tensorflow
70