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 | REGISTER8(BinaryOp, CPU, "Sub" , functor::sub, float, Eigen::half, double, int32, |
20 | int64_t, bfloat16, complex64, complex128); |
21 | #if !defined(__ANDROID_TYPES_SLIM__) |
22 | // Sub op for int8, uint8, int16, uint16 |
23 | REGISTER6(BinaryOp, CPU, "Sub" , functor::sub, int8, uint8, int16, uint16, |
24 | uint32, uint64); |
25 | #else |
26 | // We only register the first type when we have multi-argument calls in the |
27 | // case where we're trying to reduce executable size, but it turns out that the |
28 | // int32 version of this op is needed, so explicitly include it. |
29 | REGISTER(BinaryOp, CPU, "Sub" , functor::sub, int32); |
30 | #endif // __ANDROID_TYPES_SLIM__ |
31 | |
32 | #if GOOGLE_CUDA || TENSORFLOW_USE_ROCM |
33 | #if !defined(MLIR_GENERATED_GPU_KERNELS_ENABLED) |
34 | REGISTER8(BinaryOp, GPU, "Sub" , functor::sub, float, Eigen::half, double, int64, |
35 | complex64, complex128, uint32, uint64); |
36 | #endif |
37 | |
38 | // A special GPU kernel for int32. |
39 | // TODO(b/25387198): Also enable int32 in device memory. This kernel |
40 | // registration requires all int32 inputs and outputs to be in host memory. |
41 | REGISTER_KERNEL_BUILDER(Name("Sub" ) |
42 | .Device(DEVICE_GPU) |
43 | .HostMemory("x" ) |
44 | .HostMemory("y" ) |
45 | .HostMemory("z" ) |
46 | .TypeConstraint<int32>("T" ), |
47 | BinaryOp<CPUDevice, functor::sub<int32>>); |
48 | #endif |
49 | REGISTER_KERNEL_BUILDER(Name("Sub" ) |
50 | .Device(DEVICE_DEFAULT) |
51 | .HostMemory("x" ) |
52 | .HostMemory("y" ) |
53 | .HostMemory("z" ) |
54 | .TypeConstraint<int32>("T" ), |
55 | BinaryOp<CPUDevice, functor::sub<int32>>); |
56 | |
57 | } // namespace tensorflow |
58 | |