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 // See docs in ../ops/array_ops.cc. 17 #include "tensorflow/core/kernels/debug_ops.h" 18 19 #include "tensorflow/core/framework/op_kernel.h" 20 #include "tensorflow/core/framework/register_types.h" 21 #include "tensorflow/core/framework/tensor.h" 22 #include "tensorflow/core/framework/types.h" 23 24 namespace tensorflow { 25 26 // Register Copy ops. 27 REGISTER_KERNEL_BUILDER(Name("Copy").Device(DEVICE_CPU), CopyOp); 28 29 REGISTER_KERNEL_BUILDER(Name("CopyHost").Device(DEVICE_CPU), CopyOp); 30 31 #if GOOGLE_CUDA 32 REGISTER_KERNEL_BUILDER(Name("Copy").Device(DEVICE_GPU), CopyOp); 33 34 REGISTER_KERNEL_BUILDER(Name("CopyHost") 35 .Device(DEVICE_GPU) 36 .HostMemory("input") 37 .HostMemory("output"), 38 CopyOp); 39 #endif // GOOGLE_CUDA 40 41 #ifdef TENSORFLOW_USE_SYCL 42 REGISTER_KERNEL_BUILDER(Name("Copy").Device(DEVICE_SYCL), CopyOp); 43 44 REGISTER_KERNEL_BUILDER(Name("CopyHost") 45 .Device(DEVICE_SYCL) 46 .HostMemory("input") 47 .HostMemory("output"), 48 CopyOp); 49 #endif // TENSORFLOW_USE_SYCL 50 51 // Register debug identity (non-ref and ref) ops. 52 REGISTER_KERNEL_BUILDER(Name("DebugIdentity").Device(DEVICE_CPU), 53 DebugIdentityOp); 54 55 #if GOOGLE_CUDA 56 REGISTER_KERNEL_BUILDER(Name("DebugIdentity") 57 .Device(DEVICE_GPU) 58 .HostMemory("input") 59 .HostMemory("output"), 60 DebugIdentityOp); 61 #endif 62 63 #ifdef TENSORFLOW_USE_SYCL 64 REGISTER_KERNEL_BUILDER(Name("DebugIdentity") 65 .Device(DEVICE_SYCL) 66 .HostMemory("input") 67 .HostMemory("output"), 68 DebugIdentityOp); 69 #endif // TENSORFLOW_USE_SYCL 70 71 // Register debug NaN-counter (non-ref and ref) ops. 72 #define REGISTER_DEBUG_NAN_COUNT(type) \ 73 REGISTER_KERNEL_BUILDER( \ 74 Name("DebugNanCount").Device(DEVICE_CPU).TypeConstraint<type>("T"), \ 75 DebugNanCountOp<type>); 76 TF_CALL_REAL_NUMBER_TYPES(REGISTER_DEBUG_NAN_COUNT); 77 78 #if GOOGLE_CUDA 79 #define REGISTER_GPU_DEBUG_NAN_COUNT(type) \ 80 REGISTER_KERNEL_BUILDER(Name("DebugNanCount") \ 81 .Device(DEVICE_GPU) \ 82 .HostMemory("input") \ 83 .HostMemory("output") \ 84 .TypeConstraint<type>("T"), \ 85 DebugNanCountOp<type>); 86 REGISTER_GPU_DEBUG_NAN_COUNT(Eigen::half); 87 REGISTER_GPU_DEBUG_NAN_COUNT(float); 88 REGISTER_GPU_DEBUG_NAN_COUNT(double); 89 #endif 90 91 #ifdef TENSORFLOW_USE_SYCL 92 #define REGISTER_GPU_DEBUG_NAN_COUNT(type) \ 93 REGISTER_KERNEL_BUILDER(Name("DebugNanCount") \ 94 .Device(DEVICE_SYCL) \ 95 .HostMemory("input") \ 96 .HostMemory("output") \ 97 .TypeConstraint<type>("T"), \ 98 DebugNanCountOp<type>); 99 REGISTER_GPU_DEBUG_NAN_COUNT(float); 100 REGISTER_GPU_DEBUG_NAN_COUNT(double); 101 #endif // TENSORFLOW_USE_SYCL 102 103 // Register debug numeric summary ops. 104 #define REGISTER_DEBUG_NUMERIC_SUMMARY_COUNT(type) \ 105 REGISTER_KERNEL_BUILDER(Name("DebugNumericSummary") \ 106 .Device(DEVICE_CPU) \ 107 .TypeConstraint<type>("T"), \ 108 DebugNumericSummaryOp<type>); 109 TF_CALL_bool(REGISTER_DEBUG_NUMERIC_SUMMARY_COUNT); 110 TF_CALL_INTEGRAL_TYPES(REGISTER_DEBUG_NUMERIC_SUMMARY_COUNT); 111 TF_CALL_float(REGISTER_DEBUG_NUMERIC_SUMMARY_COUNT); 112 TF_CALL_double(REGISTER_DEBUG_NUMERIC_SUMMARY_COUNT); 113 114 #if GOOGLE_CUDA 115 #define REGISTER_GPU_DEBUG_NUMERIC_SUMMARY_COUNT(type) \ 116 REGISTER_KERNEL_BUILDER(Name("DebugNumericSummary") \ 117 .Device(DEVICE_GPU) \ 118 .HostMemory("input") \ 119 .HostMemory("output") \ 120 .TypeConstraint<type>("T"), \ 121 DebugNumericSummaryOp<type>); 122 TF_CALL_bool(REGISTER_GPU_DEBUG_NUMERIC_SUMMARY_COUNT); 123 TF_CALL_INTEGRAL_TYPES(REGISTER_GPU_DEBUG_NUMERIC_SUMMARY_COUNT); 124 TF_CALL_float(REGISTER_GPU_DEBUG_NUMERIC_SUMMARY_COUNT); 125 TF_CALL_double(REGISTER_GPU_DEBUG_NUMERIC_SUMMARY_COUNT); 126 #endif // GOOGLE_CUDA 127 128 #if TENSORFLOW_USE_SYCL 129 #define REGISTER_SYCL_DEBUG_NUMERIC_SUMMARY_COUNT(type) \ 130 REGISTER_KERNEL_BUILDER(Name("DebugNumericSummary") \ 131 .Device(DEVICE_SYCL) \ 132 .HostMemory("input") \ 133 .HostMemory("output") \ 134 .TypeConstraint<type>("T"), \ 135 DebugNumericSummaryOp<type>); 136 TF_CALL_bool(REGISTER_SYCL_DEBUG_NUMERIC_SUMMARY_COUNT); 137 TF_CALL_INTEGRAL_TYPES(REGISTER_SYCL_DEBUG_NUMERIC_SUMMARY_COUNT); 138 TF_CALL_float(REGISTER_SYCL_DEBUG_NUMERIC_SUMMARY_COUNT); 139 TF_CALL_double(REGISTER_SYCL_DEBUG_NUMERIC_SUMMARY_COUNT); 140 #endif // TENSORFLOW_USE_SYCL 141 } // namespace tensorflow 142