1 /* Copyright 2020 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 // Register XlaXXX operations on regular CPU/GPU devices using 17 // `XlaCompileOnDemandOp`. 18 #include "tensorflow/compiler/jit/xla_compile_on_demand_op.h" 19 #include "tensorflow/core/framework/op_kernel.h" 20 21 namespace tensorflow { 22 23 #define REGISTER_XLA_OPS_ON_DEVICE(DEVICE) \ 24 REGISTER_KERNEL_BUILDER(Name("XlaConv") \ 25 .HostMemory("window_strides") \ 26 .HostMemory("padding") \ 27 .HostMemory("lhs_dilation") \ 28 .HostMemory("rhs_dilation") \ 29 .HostMemory("feature_group_count") \ 30 .Device(DEVICE), \ 31 XlaCompileOnDemandOp); \ 32 REGISTER_KERNEL_BUILDER(Name("XlaConvV2") \ 33 .HostMemory("window_strides") \ 34 .HostMemory("padding") \ 35 .HostMemory("lhs_dilation") \ 36 .HostMemory("rhs_dilation") \ 37 .HostMemory("feature_group_count") \ 38 .Device(DEVICE), \ 39 XlaCompileOnDemandOp); \ 40 REGISTER_KERNEL_BUILDER( \ 41 Name("XlaBroadcastHelper").HostMemory("broadcast_dims").Device(DEVICE), \ 42 XlaCompileOnDemandOp); \ 43 REGISTER_KERNEL_BUILDER(Name("XlaSelfAdjointEig").Device(DEVICE), \ 44 XlaCompileOnDemandOp); \ 45 REGISTER_KERNEL_BUILDER(Name("XlaSvd").Device(DEVICE), \ 46 XlaCompileOnDemandOp); \ 47 REGISTER_KERNEL_BUILDER(Name("XlaDot").Device(DEVICE), \ 48 XlaCompileOnDemandOp); \ 49 REGISTER_KERNEL_BUILDER(Name("XlaDotV2").Device(DEVICE), \ 50 XlaCompileOnDemandOp); \ 51 REGISTER_KERNEL_BUILDER( \ 52 Name("XlaDynamicSlice").HostMemory("size_indices").Device(DEVICE), \ 53 XlaCompileOnDemandOp); \ 54 REGISTER_KERNEL_BUILDER(Name("XlaDynamicUpdateSlice").Device(DEVICE), \ 55 XlaCompileOnDemandOp); \ 56 REGISTER_KERNEL_BUILDER(Name("XlaIf").Device(DEVICE), XlaCompileOnDemandOp); \ 57 REGISTER_KERNEL_BUILDER(Name("XlaOptimizationBarrier").Device(DEVICE), \ 58 XlaCompileOnDemandOp); \ 59 REGISTER_KERNEL_BUILDER(Name("XlaPad") \ 60 .HostMemory("padding_low") \ 61 .HostMemory("padding_high") \ 62 .HostMemory("padding_interior") \ 63 .Device(DEVICE), \ 64 XlaCompileOnDemandOp); \ 65 REGISTER_KERNEL_BUILDER(Name("XlaRecv").Device(DEVICE), \ 66 XlaCompileOnDemandOp); \ 67 REGISTER_KERNEL_BUILDER(Name("XlaReduce").Device(DEVICE), \ 68 XlaCompileOnDemandOp); \ 69 REGISTER_KERNEL_BUILDER(Name("XlaVariadicReduce").Device(DEVICE), \ 70 XlaCompileOnDemandOp); \ 71 REGISTER_KERNEL_BUILDER(Name("XlaVariadicReduceV2").Device(DEVICE), \ 72 XlaCompileOnDemandOp); \ 73 REGISTER_KERNEL_BUILDER(Name("XlaReducePrecision").Device(DEVICE), \ 74 XlaCompileOnDemandOp); \ 75 REGISTER_KERNEL_BUILDER(Name("XlaReduceWindow") \ 76 .HostMemory("window_dimensions") \ 77 .HostMemory("window_strides") \ 78 .HostMemory("base_dilations") \ 79 .HostMemory("window_dilations") \ 80 .HostMemory("padding") \ 81 .Device(DEVICE), \ 82 XlaCompileOnDemandOp); \ 83 REGISTER_KERNEL_BUILDER(Name("XlaSelectAndScatter") \ 84 .HostMemory("window_dimensions") \ 85 .HostMemory("window_strides") \ 86 .HostMemory("padding") \ 87 .Device(DEVICE), \ 88 XlaCompileOnDemandOp); \ 89 REGISTER_KERNEL_BUILDER(Name("XlaSend").Device(DEVICE), \ 90 XlaCompileOnDemandOp); \ 91 REGISTER_KERNEL_BUILDER(Name("XlaSort").Device(DEVICE), \ 92 XlaCompileOnDemandOp); \ 93 REGISTER_KERNEL_BUILDER(Name("XlaKeyValueSort").Device(DEVICE), \ 94 XlaCompileOnDemandOp); \ 95 REGISTER_KERNEL_BUILDER( \ 96 Name("XlaVariadicSort").HostMemory("dimension").Device(DEVICE), \ 97 XlaCompileOnDemandOp); \ 98 REGISTER_KERNEL_BUILDER(Name("XlaWhile").Device(DEVICE), \ 99 XlaCompileOnDemandOp); \ 100 REGISTER_KERNEL_BUILDER(Name("XlaDequantize").Device(DEVICE), \ 101 XlaCompileOnDemandOp); \ 102 REGISTER_KERNEL_BUILDER(Name("XlaEinsum").Device(DEVICE), \ 103 XlaCompileOnDemandOp); \ 104 REGISTER_KERNEL_BUILDER(Name("XlaRngBitGenerator") \ 105 .HostMemory("algorithm") \ 106 .HostMemory("shape") \ 107 .Device(DEVICE), \ 108 XlaCompileOnDemandOp); \ 109 REGISTER_KERNEL_BUILDER(Name("XlaSpmdShardToFullShape").Device(DEVICE), \ 110 XlaCompileOnDemandOp); \ 111 REGISTER_KERNEL_BUILDER(Name("XlaSharding").Device(DEVICE), \ 112 XlaCompileOnDemandOp); \ 113 REGISTER_KERNEL_BUILDER(Name("XlaReplicaId").Device(DEVICE), \ 114 XlaCompileOnDemandOp); \ 115 REGISTER_KERNEL_BUILDER( \ 116 Name("XlaGather").HostMemory("slice_sizes").Device(DEVICE), \ 117 XlaCompileOnDemandOp); \ 118 REGISTER_KERNEL_BUILDER(Name("XlaScatter").Device(DEVICE), \ 119 XlaCompileOnDemandOp); \ 120 REGISTER_KERNEL_BUILDER(Name("XlaCallModule").Device(DEVICE), \ 121 XlaCompileOnDemandOp); 122 REGISTER_XLA_OPS_ON_DEVICE(DEVICE_CPU); 123 REGISTER_XLA_OPS_ON_DEVICE(DEVICE_GPU); 124 125 } // namespace tensorflow 126