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_t, bfloat16); |
21 | |
22 | REGISTER6(BinaryOp, CPU, "AddV2" , functor::add, float, Eigen::half, double, |
23 | int32, int64_t, bfloat16); |
24 | |
25 | #if GOOGLE_CUDA || TENSORFLOW_USE_ROCM |
26 | |
27 | #if !defined(MLIR_GENERATED_GPU_KERNELS_ENABLED) |
28 | REGISTER3(BinaryOp, GPU, "Add" , functor::add, float, Eigen::half, double); |
29 | REGISTER3(BinaryOp, GPU, "AddV2" , functor::add, float, Eigen::half, double); |
30 | #endif |
31 | |
32 | // A special GPU kernel for int32. |
33 | // TODO(b/25387198): Also enable int32 in device memory. This kernel |
34 | // registration requires all int32 inputs and outputs to be in host memory. |
35 | REGISTER_KERNEL_BUILDER(Name("Add" ) |
36 | .Device(DEVICE_GPU) |
37 | .HostMemory("x" ) |
38 | .HostMemory("y" ) |
39 | .HostMemory("z" ) |
40 | .TypeConstraint<int32>("T" ), |
41 | BinaryOp<CPUDevice, functor::add<int32>>); |
42 | REGISTER_KERNEL_BUILDER(Name("AddV2" ) |
43 | .Device(DEVICE_GPU) |
44 | .HostMemory("x" ) |
45 | .HostMemory("y" ) |
46 | .HostMemory("z" ) |
47 | .TypeConstraint<int32>("T" ), |
48 | BinaryOp<CPUDevice, functor::add<int32>>); |
49 | #endif |
50 | REGISTER_KERNEL_BUILDER(Name("Add" ) |
51 | .Device(DEVICE_DEFAULT) |
52 | .HostMemory("x" ) |
53 | .HostMemory("y" ) |
54 | .HostMemory("z" ) |
55 | .TypeConstraint<int32>("T" ), |
56 | BinaryOp<CPUDevice, functor::add<int32>>); |
57 | REGISTER_KERNEL_BUILDER(Name("AddV2" ) |
58 | .Device(DEVICE_DEFAULT) |
59 | .HostMemory("x" ) |
60 | .HostMemory("y" ) |
61 | .HostMemory("z" ) |
62 | .TypeConstraint<int32>("T" ), |
63 | BinaryOp<CPUDevice, functor::add<int32>>); |
64 | |
65 | } // namespace tensorflow |
66 | |