xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/xla/service/gpu/cublas_lt_matmul_thunk.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1 /* Copyright 2022 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_CUBLAS_LT_MATMUL_THUNK_H_
17 #define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CUBLAS_LT_MATMUL_THUNK_H_
18 
19 #include <optional>
20 #include <utility>
21 
22 #include "tensorflow/compiler/xla/service/buffer_assignment.h"
23 #include "tensorflow/compiler/xla/service/gpu/matmul_utils.h"
24 #include "tensorflow/compiler/xla/service/gpu/thunk.h"
25 #include "tensorflow/compiler/xla/status.h"
26 #include "tensorflow/stream_executor/cuda/cuda_blas_lt.h"
27 
28 namespace xla {
29 namespace gpu {
30 
31 class CublasLtMatmulThunk : public Thunk {
32  public:
33   CublasLtMatmulThunk(ThunkInfo thunk_info, cublas_lt::MatmulPlan plan,
34                       int64_t algorithm_idx, BufferAllocation::Slice a_buffer,
35                       BufferAllocation::Slice b_buffer,
36                       BufferAllocation::Slice c_buffer,
37                       BufferAllocation::Slice d_buffer,
38                       BufferAllocation::Slice bias_buffer /* may be null */);
39 
40   Status ExecuteOnStream(const ExecuteParams& params) override;
41 
42  private:
43   cublas_lt::MatmulPlan plan_;
44   int64_t algorithm_idx_;
45   BufferAllocation::Slice a_buffer_;
46   BufferAllocation::Slice b_buffer_;
47   BufferAllocation::Slice c_buffer_;
48   BufferAllocation::Slice d_buffer_;
49   BufferAllocation::Slice bias_buffer_;
50   std::optional<se::cuda::BlasLt::MatmulAlgorithm> algorithm_;
51 };
52 
53 }  // namespace gpu
54 }  // namespace xla
55 
56 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CUBLAS_LT_MATMUL_THUNK_H_
57