1 /* Copyright 2017 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 #ifndef TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CONVOLUTION_THUNK_H_ 17 #define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CONVOLUTION_THUNK_H_ 18 19 #include "absl/types/optional.h" 20 #include "tensorflow/compiler/xla/service/buffer_assignment.h" 21 #include "tensorflow/compiler/xla/service/gpu/buffer_allocations.h" 22 #include "tensorflow/compiler/xla/service/gpu/gpu_conv_runner.h" 23 #include "tensorflow/compiler/xla/service/gpu/gpu_executable.h" 24 #include "tensorflow/compiler/xla/service/gpu/hlo_execution_profiler.h" 25 #include "tensorflow/compiler/xla/service/gpu/thunk.h" 26 #include "tensorflow/compiler/xla/service/hlo_instruction.h" 27 #include "tensorflow/compiler/xla/service/hlo_instructions.h" 28 #include "tensorflow/compiler/xla/types.h" 29 #include "tensorflow/compiler/xla/xla_data.pb.h" 30 #include "tensorflow/core/lib/core/status.h" 31 #include "tensorflow/core/platform/stream_executor_no_cuda.h" 32 33 namespace xla { 34 namespace gpu { 35 36 // This class stores everything that StreamExecutor needs to launch a DNN 37 // convolution. It is generated by IrEmitter. 38 // 39 // This is thread-compatible. 40 class ConvolutionThunk : public Thunk { 41 public: 42 // Constructs a thunk for launching a DNN convolution. 43 // 44 // operand_slices should be in the same order as cudnn_call->operands(). 45 ConvolutionThunk(ThunkInfo thunk_info, GpuConvConfig config, 46 std::vector<BufferAllocation::Slice> operand_slices, 47 BufferAllocation::Slice result_slice, 48 BufferAllocation::Slice scratch_slice); 49 50 ConvolutionThunk(const ConvolutionThunk&) = delete; 51 ConvolutionThunk& operator=(const ConvolutionThunk&) = delete; 52 53 Status ExecuteOnStream(const ExecuteParams& params) override; 54 55 private: 56 std::vector<BufferAllocation::Slice> operand_buffers_; 57 BufferAllocation::Slice result_buffer_; 58 BufferAllocation::Slice scratch_buffer_; 59 60 // Convolution config 61 const GpuConvConfig config_; 62 }; 63 64 } // namespace gpu 65 } // namespace xla 66 67 #endif // TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CONVOLUTION_THUNK_H_ 68