jasonfan commited on
Commit
cd2df55
·
verified ·
1 Parent(s): 94ee59d

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/epilogue_predicated_tile_iterator.h +757 -0
  2. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/make_residual_last.h +79 -0
  3. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/predicated_tile_access_iterator_residual_last.h +2120 -0
  4. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/predicated_tile_iterator_residual_last.h +2125 -0
  5. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/transpose_warp_iterator.h +36 -0
  6. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/warp_iterator_from_smem.h +289 -0
  7. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/kernels/cutlassB.h +919 -0
  8. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/kernels/cutlassF.h +318 -0
  9. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/transform/tile_smem_loader.h +71 -0
  10. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/aotriton_adapter.h +190 -0
  11. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/aotriton_versions.h +25 -0
  12. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/flash_attn/ck/me_ck_api.h +72 -0
  13. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/flash_attn/flash_api.h +568 -0
  14. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/gemm_kernel_utils.h +37 -0
  15. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/xpu/sdp_utils.h +22 -0
  16. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/utils/Factory.h +25 -0
  17. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/utils/ParamUtils.h +47 -0
  18. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/utils/ParamsHash.h +109 -0
  19. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d.h +97 -0
  20. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward.h +45 -0
  21. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_compositeexplicitautograd_dispatch.h +29 -0
  22. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_cpu_dispatch.h +28 -0
  23. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_cuda_dispatch.h +28 -0
  24. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_native.h +28 -0
  25. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_ops.h +45 -0
  26. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_compositeexplicitautograd_dispatch.h +31 -0
  27. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_cpu_dispatch.h +29 -0
  28. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_cuda_dispatch.h +29 -0
  29. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_native.h +30 -0
  30. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_ops.h +45 -0
  31. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d.h +97 -0
  32. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward.h +45 -0
  33. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_compositeexplicitautograd_dispatch.h +29 -0
  34. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_cpu_dispatch.h +28 -0
  35. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_cuda_dispatch.h +28 -0
  36. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_native.h +28 -0
  37. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_ops.h +45 -0
  38. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_compositeexplicitautograd_dispatch.h +31 -0
  39. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_cpu_dispatch.h +29 -0
  40. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_cuda_dispatch.h +29 -0
  41. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_native.h +29 -0
  42. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_ops.h +45 -0
  43. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim.h +36 -0
  44. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim_compositeimplicitautograd_dispatch.h +28 -0
  45. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim_native.h +26 -0
  46. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim_ops.h +34 -0
  47. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu.h +69 -0
  48. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_compositeexplicitautograd_dispatch.h +29 -0
  49. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_cpu_dispatch.h +33 -0
  50. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_meta_dispatch.h +29 -0
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/epilogue_predicated_tile_iterator.h ADDED
@@ -0,0 +1,757 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /***************************************************************************************************
3
+ * Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights
4
+ *reserved. SPDX-License-Identifier: BSD-3-Clause
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ *this list of conditions and the following disclaimer.
11
+ *
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ * this list of conditions and the following disclaimer in the documentation
14
+ * and/or other materials provided with the distribution.
15
+ *
16
+ * 3. Neither the name of the copyright holder nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ *ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+ *LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ *INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ *CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ *ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ *POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ **************************************************************************************************/
33
+ /*! \file
34
+ \brief Epilogue iterator that supports prefetching
35
+
36
+ Mostly copied from <cutlass/epilogue/threadblock/predicated_tile_iterator.h>
37
+ */
38
+
39
+ #pragma once
40
+
41
+ #include <cutlass/arch/arch.h>
42
+ #include <cutlass/arch/memory.h>
43
+ #include <cutlass/array.h>
44
+ #include <cutlass/cutlass.h>
45
+ #include <cutlass/epilogue/threadblock/output_tile_thread_map.h>
46
+ #include <cutlass/epilogue/threadblock/predicated_tile_iterator_params.h>
47
+ #include <cutlass/layout/matrix.h>
48
+ #include <cutlass/layout/tensor.h>
49
+ #include <cutlass/matrix_shape.h>
50
+ #include <cutlass/numeric_types.h>
51
+ #include <cutlass/tensor_ref.h>
52
+ #include <cutlass/transform/pitch_linear_thread_map.h>
53
+
54
+ ////////////////////////////////////////////////////////////////////////////////
55
+
56
+ namespace cutlass {
57
+
58
+ ////////////////////////////////////////////////////////////////////////////////
59
+
60
+ namespace epilogue {
61
+ namespace threadblock {
62
+
63
+ ////////////////////////////////////////////////////////////////////////////////
64
+
65
+ /// Tile iterator used to load and store output tile from global memory in
66
+ /// epilogue.
67
+ ///
68
+ /// Satisfies: ReadableTileIterator | PredicatedTileIterator |
69
+ /// ForwardTileIterator
70
+ ///
71
+ template <
72
+ typename ThreadMap_, ///< Thread map (concept: OutputTileThreadMap)
73
+ typename Element_, ///< Element data type
74
+ bool ScatterD = false, ///< Scatter D operand or not
75
+ bool UseCUDAStore = false>
76
+ class PredicatedTileIteratorPrefetch {
77
+ public:
78
+ using ThreadMap = ThreadMap_;
79
+ using Shape = typename ThreadMap::Shape;
80
+
81
+ using Element = Element_;
82
+
83
+ using Layout = layout::RowMajor;
84
+ using TensorRef = TensorRef<Element, Layout>;
85
+ using ConstTensorRef = typename TensorRef::ConstTensorRef;
86
+
87
+ using Index = typename Layout::Index;
88
+ using LongIndex = typename Layout::LongIndex;
89
+ using TensorCoord = MatrixCoord;
90
+
91
+ static int const kElementsPerAccess = ThreadMap::kElementsPerAccess;
92
+ static int const kThreads = ThreadMap::kThreads;
93
+ static int const kIterations = ThreadMap::Count::kTile;
94
+
95
+ static_assert(
96
+ ThreadMap::Iterations::kRow > 0,
97
+ "ThreadMap::Iterations::kRow must be > 0");
98
+ static_assert(
99
+ ThreadMap::Iterations::kGroup > 0,
100
+ "ThreadMap::Iterations::kGroup must be > 0");
101
+ static_assert(
102
+ ThreadMap::Iterations::kCluster > 0,
103
+ "ThreadMap::Iterations::kCluster must be > 0");
104
+ static_assert(
105
+ ThreadMap::Iterations::kColumn > 0,
106
+ "ThreadMap::Iterations::kColumn must be > 0");
107
+
108
+ /// Fragment object
109
+ using Fragment = Array<
110
+ Element,
111
+ ThreadMap::Iterations::kColumn * ThreadMap::Iterations::kRow *
112
+ ThreadMap::Iterations::kGroup * ThreadMap::Iterations::kCluster *
113
+ ThreadMap::kElementsPerAccess>;
114
+
115
+ /// Memory access size
116
+ using AccessType = AlignedArray<Element, ThreadMap::kElementsPerAccess>;
117
+
118
+ //
119
+ // Parameters struct
120
+ //
121
+
122
+ /// Uses a non-template class
123
+ struct Params : PredicatedTileIteratorParams {
124
+ using Base = PredicatedTileIteratorParams;
125
+
126
+ CUTLASS_HOST_DEVICE
127
+ Params() {}
128
+
129
+ CUTLASS_HOST_DEVICE
130
+ Params(Layout const& layout)
131
+ : PredicatedTileIteratorParams(
132
+ layout.stride(0) * int(sizeof(AccessType)) / kElementsPerAccess,
133
+ make_OutputTileThreadMapDesc<ThreadMap>()) {}
134
+
135
+ CUTLASS_HOST_DEVICE
136
+ Params(Base const& base) : Base(base) {}
137
+ };
138
+
139
+ /// Mask object
140
+ struct Mask {
141
+ static int const kCount = ThreadMap::Iterations::kColumn;
142
+
143
+ /// Predicate state
144
+ bool predicates[kCount];
145
+
146
+ //
147
+ // Mask
148
+ //
149
+ CUTLASS_HOST_DEVICE
150
+ Mask() {
151
+ enable();
152
+ }
153
+
154
+ ///< Efficiently disables all accesses guarded by mask
155
+ CUTLASS_HOST_DEVICE void clear() {
156
+ CUTLASS_PRAGMA_UNROLL
157
+ for (int i = 0; i < kCount; ++i) {
158
+ predicates[i] = false;
159
+ }
160
+ }
161
+
162
+ ///< CUTLASS_HOST_DEVICE enables all accesses guarded by mask
163
+ CUTLASS_DEVICE void enable() {
164
+ CUTLASS_PRAGMA_UNROLL
165
+ for (int i = 0; i < kCount; ++i) {
166
+ predicates[i] = true;
167
+ }
168
+ }
169
+ };
170
+
171
+ private:
172
+ //
173
+ // Data members
174
+ //
175
+
176
+ /// Parameters structure containing reference and precomputed state.
177
+ PredicatedTileIteratorParams params_;
178
+
179
+ /// Byte-level pointer
180
+ uint8_t* byte_pointer_;
181
+
182
+ /// Array of boolean values to contain steady-state predicates
183
+ Mask mask_;
184
+
185
+ /// Extent of the matrix tile in rows
186
+ Index extent_row_;
187
+
188
+ /// Extent of the matrix tile in rows
189
+ Index extent_column_;
190
+
191
+ /// A thread's starting row position (assuming steady-state predicates have
192
+ /// been computed)
193
+ Index thread_start_row_;
194
+
195
+ /// A thread's starting column
196
+ Index thread_start_column_;
197
+
198
+ /// Internal state counter
199
+ int state_[3];
200
+
201
+ /// Scatter indices
202
+ int const* indices_;
203
+
204
+ //
205
+ // Static asserts about internal strides
206
+ //
207
+
208
+ static_assert(sizeof(extent_row_) == 4, "Expected 32b extents");
209
+ static_assert(sizeof(thread_start_row_) == 4, "Expected 32b extents");
210
+ static_assert(
211
+ sizeof(PredicatedTileIteratorParams::stride) == 8,
212
+ "Expected 64b strides");
213
+
214
+ private:
215
+ //
216
+ // Methods
217
+ //
218
+
219
+ public:
220
+ //
221
+ // Methods
222
+ //
223
+
224
+ /// Constructor
225
+ CUTLASS_DEVICE
226
+ PredicatedTileIteratorPrefetch(
227
+ PredicatedTileIteratorParams const& params,
228
+ Element* pointer,
229
+ TensorCoord extent,
230
+ int thread_idx,
231
+ TensorCoord threadblock_offset = TensorCoord(),
232
+ int const* indices = nullptr)
233
+ : params_(params), indices_(indices) {
234
+ TensorCoord thread_offset =
235
+ ThreadMap::initial_offset(thread_idx) + threadblock_offset;
236
+
237
+ extent_row_ = extent.row();
238
+ extent_column_ = extent.column();
239
+
240
+ thread_start_row_ = thread_offset.row();
241
+ thread_start_column_ = thread_offset.column();
242
+
243
+ // Initialize predicates
244
+ CUTLASS_PRAGMA_UNROLL
245
+ for (int c = 0; c < ThreadMap::Iterations::kColumn; ++c) {
246
+ mask_.predicates[c] =
247
+ ((thread_offset.column() + ThreadMap::Delta::kColumn * c) <
248
+ extent.column());
249
+ }
250
+
251
+ // Null pointer performs no accesses
252
+ if (!pointer) {
253
+ mask_.clear();
254
+ }
255
+
256
+ if (ScatterD && !indices) {
257
+ mask_.clear();
258
+ }
259
+
260
+ // Initialize pointer
261
+ byte_pointer_ = reinterpret_cast<uint8_t*>(pointer) +
262
+ LongIndex(thread_offset.row()) * LongIndex(params_.stride) +
263
+ LongIndex(thread_offset.column()) * sizeof(AccessType) /
264
+ kElementsPerAccess;
265
+
266
+ if (ScatterD) {
267
+ byte_pointer_ = reinterpret_cast<uint8_t*>(pointer) +
268
+ LongIndex(thread_offset.column()) * sizeof(AccessType) /
269
+ kElementsPerAccess;
270
+ }
271
+
272
+ // Initialize internal state counter
273
+ state_[0] = state_[1] = state_[2] = 0;
274
+ }
275
+
276
+ /// Adds a pointer offset in units of Element
277
+ CUTLASS_HOST_DEVICE
278
+ void add_pointer_offset(LongIndex pointer_offset) {
279
+ byte_pointer_ += pointer_offset * sizeof_bits<Element>::value / 8;
280
+ }
281
+
282
+ CUTLASS_DEVICE
283
+ void prefetch_all() {
284
+ CUTLASS_PRAGMA_UNROLL
285
+ for (int iter = 0; iter < kIterations; ++iter) {
286
+ prefetch();
287
+ ++(*this);
288
+ }
289
+ }
290
+
291
+ CUTLASS_DEVICE
292
+ void prefetch() {
293
+ uint8_t* byte_pointer = byte_pointer_;
294
+
295
+ CUTLASS_PRAGMA_UNROLL
296
+ for (int cluster = 0; cluster < ThreadMap::Iterations::kCluster;
297
+ ++cluster) {
298
+ CUTLASS_PRAGMA_UNROLL
299
+ for (int group = 0; group < ThreadMap::Iterations::kGroup; ++group) {
300
+ CUTLASS_PRAGMA_UNROLL
301
+ for (int row = 0; row < ThreadMap::Iterations::kRow; ++row) {
302
+ int row_offset = row * ThreadMap::Delta::kRow +
303
+ group * ThreadMap::Delta::kGroup +
304
+ cluster * ThreadMap::Delta::kCluster;
305
+
306
+ AccessType* memory_pointer =
307
+ reinterpret_cast<AccessType*>(byte_pointer);
308
+
309
+ CUTLASS_PRAGMA_UNROLL
310
+ for (int column = 0; column < ThreadMap::Iterations::kColumn;
311
+ ++column) {
312
+ // on windows using unsigned long here gives the error
313
+ // error: asm operand type size(4) does not match
314
+ // type/size implied by constraint 'l'
315
+ uint64_t addr = (uint64_t)((void*)&memory_pointer
316
+ [column * ThreadMap::Delta::kColumn /
317
+ kElementsPerAccess]);
318
+ asm volatile("prefetch.global.L1 [ %1 ];" : "=l"(addr) : "l"(addr));
319
+ }
320
+
321
+ if (row + 1 < ThreadMap::Iterations::kRow) {
322
+ if (!ScatterD) {
323
+ byte_pointer += params_.increment_row;
324
+ }
325
+ }
326
+ }
327
+
328
+ if (group + 1 < ThreadMap::Iterations::kGroup) {
329
+ byte_pointer += params_.increment_group;
330
+ }
331
+ }
332
+
333
+ if (cluster + 1 < ThreadMap::Iterations::kCluster) {
334
+ byte_pointer += params_.increment_cluster;
335
+ }
336
+ }
337
+ }
338
+
339
+ /// Loads a fragment from memory
340
+ CUTLASS_DEVICE
341
+ void load_with_byte_offset(Fragment& frag, int64_t byte_offset) const {
342
+ uint8_t* byte_pointer = byte_pointer_;
343
+ AccessType* frag_ptr = reinterpret_cast<AccessType*>(&frag);
344
+
345
+ CUTLASS_PRAGMA_UNROLL
346
+ for (int cluster = 0; cluster < ThreadMap::Iterations::kCluster;
347
+ ++cluster) {
348
+ CUTLASS_PRAGMA_UNROLL
349
+ for (int group = 0; group < ThreadMap::Iterations::kGroup; ++group) {
350
+ CUTLASS_PRAGMA_UNROLL
351
+ for (int row = 0; row < ThreadMap::Iterations::kRow; ++row) {
352
+ int frag_row_idx =
353
+ (row +
354
+ ThreadMap::Iterations::kRow *
355
+ (group + ThreadMap::Iterations::kGroup * cluster));
356
+
357
+ int row_offset = row * ThreadMap::Delta::kRow +
358
+ group * ThreadMap::Delta::kGroup +
359
+ cluster * ThreadMap::Delta::kCluster;
360
+
361
+ bool row_guard = ((row_offset + thread_start_row_) < extent_row_);
362
+
363
+ AccessType* memory_pointer =
364
+ reinterpret_cast<AccessType*>(byte_pointer + byte_offset);
365
+
366
+ if (ScatterD && row_guard) {
367
+ assert(indices_);
368
+
369
+ memory_pointer = reinterpret_cast<AccessType*>(
370
+ byte_pointer + byte_offset +
371
+ LongIndex(indices_[row_offset + thread_start_row_]) *
372
+ LongIndex(params_.stride));
373
+ }
374
+
375
+ CUTLASS_PRAGMA_UNROLL
376
+ for (int column = 0; column < ThreadMap::Iterations::kColumn;
377
+ ++column) {
378
+ bool guard = row_guard && mask_.predicates[column];
379
+
380
+ cutlass::arch::global_load<AccessType, sizeof(AccessType)>(
381
+ frag_ptr
382
+ [frag_row_idx * ThreadMap::Iterations::kColumn + column],
383
+ (void*)&memory_pointer
384
+ [column * ThreadMap::Delta::kColumn / kElementsPerAccess],
385
+ guard);
386
+ }
387
+
388
+ if (row + 1 < ThreadMap::Iterations::kRow) {
389
+ if (!ScatterD) {
390
+ byte_pointer += params_.increment_row;
391
+ }
392
+ }
393
+ }
394
+
395
+ if (group + 1 < ThreadMap::Iterations::kGroup) {
396
+ byte_pointer += params_.increment_group;
397
+ }
398
+ }
399
+
400
+ if (cluster + 1 < ThreadMap::Iterations::kCluster) {
401
+ byte_pointer += params_.increment_cluster;
402
+ }
403
+ }
404
+ }
405
+
406
+ /// Loads a fragment from memory
407
+ CUTLASS_DEVICE
408
+ void load(Fragment& frag) const {
409
+ load_with_byte_offset(frag, 0);
410
+ }
411
+
412
+ /// Stores a fragment to memory
413
+ CUTLASS_DEVICE
414
+ void store_with_byte_offset(Fragment const& frag, int64_t byte_offset) const {
415
+ uint8_t* byte_pointer = byte_pointer_;
416
+ AccessType const* frag_ptr = reinterpret_cast<AccessType const*>(&frag);
417
+
418
+ CUTLASS_PRAGMA_UNROLL
419
+ for (int cluster = 0; cluster < ThreadMap::Iterations::kCluster;
420
+ ++cluster) {
421
+ CUTLASS_PRAGMA_UNROLL
422
+ for (int group = 0; group < ThreadMap::Iterations::kGroup; ++group) {
423
+ CUTLASS_PRAGMA_UNROLL
424
+ for (int row = 0; row < ThreadMap::Iterations::kRow; ++row) {
425
+ int frag_row_idx =
426
+ (row +
427
+ ThreadMap::Iterations::kRow *
428
+ (group + ThreadMap::Iterations::kGroup * cluster));
429
+
430
+ int row_offset = row * ThreadMap::Delta::kRow +
431
+ group * ThreadMap::Delta::kGroup +
432
+ cluster * ThreadMap::Delta::kCluster;
433
+
434
+ bool row_guard = ((row_offset + thread_start_row_) < extent_row_);
435
+
436
+ AccessType* memory_pointer =
437
+ reinterpret_cast<AccessType*>(byte_pointer + byte_offset);
438
+
439
+ if (ScatterD && row_guard) {
440
+ assert(indices_);
441
+
442
+ memory_pointer = reinterpret_cast<AccessType*>(
443
+ byte_pointer + byte_offset +
444
+ LongIndex(indices_[row_offset + thread_start_row_]) *
445
+ LongIndex(params_.stride));
446
+ }
447
+
448
+ CUTLASS_PRAGMA_UNROLL
449
+ for (int column = 0; column < ThreadMap::Iterations::kColumn;
450
+ ++column) {
451
+ bool guard = row_guard && mask_.predicates[column];
452
+
453
+ if (UseCUDAStore) {
454
+ if (guard) {
455
+ memory_pointer
456
+ [column * ThreadMap::Delta::kColumn / kElementsPerAccess] =
457
+ frag_ptr
458
+ [frag_row_idx * ThreadMap::Iterations::kColumn +
459
+ column];
460
+ }
461
+ } else {
462
+ cutlass::arch::global_store<AccessType, sizeof(AccessType)>(
463
+ frag_ptr
464
+ [frag_row_idx * ThreadMap::Iterations::kColumn + column],
465
+ (void*)&memory_pointer
466
+ [column * ThreadMap::Delta::kColumn / kElementsPerAccess],
467
+ guard);
468
+ }
469
+ }
470
+
471
+ if (row + 1 < ThreadMap::Iterations::kRow) {
472
+ if (!ScatterD) {
473
+ byte_pointer += params_.increment_row;
474
+ }
475
+ }
476
+ }
477
+
478
+ if (group + 1 < ThreadMap::Iterations::kGroup) {
479
+ byte_pointer += params_.increment_group;
480
+ }
481
+ }
482
+
483
+ if (cluster + 1 < ThreadMap::Iterations::kCluster) {
484
+ byte_pointer += params_.increment_cluster;
485
+ }
486
+ }
487
+ }
488
+
489
+ /// Stores a fragment to memory
490
+ CUTLASS_DEVICE
491
+ void store(Fragment const& frag) const {
492
+ store_with_byte_offset(frag, 0);
493
+ }
494
+
495
+ /// Loads a fragment from memory
496
+ CUTLASS_DEVICE
497
+ void downsample_load_with_byte_offset(
498
+ Fragment& frag,
499
+ int64_t byte_offset,
500
+ int convolution_P,
501
+ int convolution_Q,
502
+ int add_P,
503
+ int add_Q,
504
+ int problem_N) const {
505
+ uint8_t* byte_pointer = byte_pointer_;
506
+ AccessType* frag_ptr = reinterpret_cast<AccessType*>(&frag);
507
+
508
+ CUTLASS_PRAGMA_UNROLL
509
+ for (int cluster = 0; cluster < ThreadMap::Iterations::kCluster;
510
+ ++cluster) {
511
+ CUTLASS_PRAGMA_UNROLL
512
+ for (int group = 0; group < ThreadMap::Iterations::kGroup; ++group) {
513
+ CUTLASS_PRAGMA_UNROLL
514
+ for (int row = 0; row < ThreadMap::Iterations::kRow; ++row) {
515
+ int frag_row_idx =
516
+ (row +
517
+ ThreadMap::Iterations::kRow *
518
+ (group + ThreadMap::Iterations::kGroup * cluster));
519
+
520
+ int row_offset = row * ThreadMap::Delta::kRow +
521
+ group * ThreadMap::Delta::kGroup +
522
+ cluster * ThreadMap::Delta::kCluster;
523
+
524
+ bool row_guard = ((row_offset + thread_start_row_) < extent_row_);
525
+
526
+ int output_row = row_offset + thread_start_row_;
527
+ int output_N = output_row / (convolution_P * convolution_Q);
528
+ int output_PQ = output_row % (convolution_P * convolution_Q);
529
+ int output_P = output_PQ / convolution_Q;
530
+ int output_Q = output_PQ % convolution_Q;
531
+
532
+ int input_row = output_N * 2 * convolution_P * 2 * convolution_Q +
533
+ (2 * output_P + add_P) * 2 * convolution_Q + 2 * output_Q + add_Q;
534
+
535
+ int64_t byte_offset =
536
+ (input_row - output_row) * problem_N * sizeof(float);
537
+
538
+ AccessType* memory_pointer =
539
+ reinterpret_cast<AccessType*>(byte_pointer + byte_offset);
540
+
541
+ CUTLASS_PRAGMA_UNROLL
542
+ for (int column = 0; column < ThreadMap::Iterations::kColumn;
543
+ ++column) {
544
+ bool guard = row_guard && mask_.predicates[column];
545
+
546
+ cutlass::arch::global_load<AccessType, sizeof(AccessType)>(
547
+ frag_ptr
548
+ [frag_row_idx * ThreadMap::Iterations::kColumn + column],
549
+ (void*)&memory_pointer
550
+ [column * ThreadMap::Delta::kColumn / kElementsPerAccess],
551
+ guard);
552
+ }
553
+
554
+ if (row + 1 < ThreadMap::Iterations::kRow) {
555
+ byte_pointer += params_.increment_row;
556
+ }
557
+ }
558
+
559
+ if (group + 1 < ThreadMap::Iterations::kGroup) {
560
+ byte_pointer += params_.increment_group;
561
+ }
562
+ }
563
+
564
+ if (cluster + 1 < ThreadMap::Iterations::kCluster) {
565
+ byte_pointer += params_.increment_cluster;
566
+ }
567
+ }
568
+ }
569
+
570
+ /// Loads a fragment from memory
571
+ CUTLASS_DEVICE
572
+ void upsample_load_with_byte_offset(
573
+ Fragment& frag,
574
+ int64_t byte_offset,
575
+ int convolution_P,
576
+ int convolution_Q,
577
+ int add_P,
578
+ int add_Q,
579
+ int problem_N) const {
580
+ uint8_t* byte_pointer = byte_pointer_;
581
+ AccessType* frag_ptr = reinterpret_cast<AccessType*>(&frag);
582
+
583
+ CUTLASS_PRAGMA_UNROLL
584
+ for (int cluster = 0; cluster < ThreadMap::Iterations::kCluster;
585
+ ++cluster) {
586
+ CUTLASS_PRAGMA_UNROLL
587
+ for (int group = 0; group < ThreadMap::Iterations::kGroup; ++group) {
588
+ CUTLASS_PRAGMA_UNROLL
589
+ for (int row = 0; row < ThreadMap::Iterations::kRow; ++row) {
590
+ int frag_row_idx =
591
+ (row +
592
+ ThreadMap::Iterations::kRow *
593
+ (group + ThreadMap::Iterations::kGroup * cluster));
594
+
595
+ int row_offset = row * ThreadMap::Delta::kRow +
596
+ group * ThreadMap::Delta::kGroup +
597
+ cluster * ThreadMap::Delta::kCluster;
598
+
599
+ bool row_guard = ((row_offset + thread_start_row_) < extent_row_);
600
+
601
+ int output_row = row_offset + thread_start_row_;
602
+ int output_N = output_row / (convolution_P * convolution_Q);
603
+ int output_PQ = output_row % (convolution_P * convolution_Q);
604
+ int output_P = output_PQ / convolution_Q;
605
+ int output_Q = output_PQ % convolution_Q;
606
+ int row_add_P = add_P;
607
+ int row_add_Q = add_Q;
608
+ if (output_P > convolution_P - 2)
609
+ row_add_P = 0;
610
+ if (output_Q > convolution_Q - 2)
611
+ row_add_Q = 0;
612
+
613
+ int input_row = output_N * (convolution_P / 2) * (convolution_Q / 2) +
614
+ ((output_P + row_add_P) / 2) * (convolution_Q / 2) +
615
+ (output_Q + row_add_Q) / 2;
616
+
617
+ int64_t byte_offset =
618
+ (input_row - output_row) * problem_N * sizeof(float);
619
+
620
+ AccessType* memory_pointer =
621
+ reinterpret_cast<AccessType*>(byte_pointer + byte_offset);
622
+
623
+ CUTLASS_PRAGMA_UNROLL
624
+ for (int column = 0; column < ThreadMap::Iterations::kColumn;
625
+ ++column) {
626
+ bool guard = row_guard && mask_.predicates[column];
627
+
628
+ cutlass::arch::global_load<AccessType, sizeof(AccessType)>(
629
+ frag_ptr
630
+ [frag_row_idx * ThreadMap::Iterations::kColumn + column],
631
+ (void*)&memory_pointer
632
+ [column * ThreadMap::Delta::kColumn / kElementsPerAccess],
633
+ guard);
634
+ }
635
+
636
+ if (row + 1 < ThreadMap::Iterations::kRow) {
637
+ byte_pointer += params_.increment_row;
638
+ }
639
+ }
640
+
641
+ if (group + 1 < ThreadMap::Iterations::kGroup) {
642
+ byte_pointer += params_.increment_group;
643
+ }
644
+ }
645
+
646
+ if (cluster + 1 < ThreadMap::Iterations::kCluster) {
647
+ byte_pointer += params_.increment_cluster;
648
+ }
649
+ }
650
+ }
651
+
652
+ CUTLASS_DEVICE
653
+ MatrixCoord thread_start() const {
654
+ return MatrixCoord(thread_start_row_, thread_start_column_);
655
+ }
656
+
657
+ /// Need to get the thread start row from the tile iterator
658
+ CUTLASS_DEVICE
659
+ int32_t thread_start_row() const {
660
+ return thread_start_row_;
661
+ }
662
+
663
+ /// Need to get the thread start row from the tile iterator
664
+ CUTLASS_DEVICE
665
+ int32_t thread_start_column() const {
666
+ return thread_start_column_;
667
+ }
668
+
669
+ /// Extent of the matrix in rows
670
+ CUTLASS_DEVICE
671
+ Index extent_row() const {
672
+ return extent_row_;
673
+ }
674
+
675
+ /// Extent of the matrix in columns
676
+ CUTLASS_DEVICE
677
+ Index extent_column() const {
678
+ return extent_column_;
679
+ }
680
+
681
+ /// Advances to the next position to load or store
682
+ CUTLASS_HOST_DEVICE
683
+ PredicatedTileIteratorPrefetch& operator++() {
684
+ ++state_[0];
685
+
686
+ if (!ScatterD) {
687
+ byte_pointer_ += params_.advance_row;
688
+ }
689
+
690
+ thread_start_row_ += ThreadMap::Shape::kRow;
691
+
692
+ if (state_[0] == ThreadMap::Count::kRow) {
693
+ state_[0] = 0;
694
+ ++state_[1];
695
+ byte_pointer_ += params_.advance_group;
696
+
697
+ thread_start_row_ += (ThreadMap::Shape::kGroup - 1) *
698
+ ThreadMap::Shape::kRow * ThreadMap::Count::kRow;
699
+
700
+ if (state_[1] == ThreadMap::Count::kGroup) {
701
+ state_[1] = 0;
702
+ ++state_[2];
703
+ byte_pointer_ += params_.advance_cluster;
704
+
705
+ thread_start_row_ += ThreadMap::Count::kGroup *
706
+ ThreadMap::Shape::kGroup * ThreadMap::Count::kRow *
707
+ ThreadMap::Shape::kRow;
708
+
709
+ if (state_[2] == ThreadMap::Count::kCluster) {
710
+ state_[2] = 0;
711
+ byte_pointer_ += params_.advance_tile;
712
+ }
713
+ }
714
+ }
715
+
716
+ return *this;
717
+ }
718
+
719
+ ///< Efficiently disables all accesses guarded by mask
720
+ CUTLASS_DEVICE void clear_mask() {
721
+ mask_.clear();
722
+ }
723
+
724
+ ///< Efficiently enables all accesses guarded by mask
725
+ CUTLASS_DEVICE void enable_mask() {
726
+ mask_.enable();
727
+ }
728
+
729
+ ///< Sets the mask
730
+ CUTLASS_DEVICE void get_mask(Mask& mask) const {
731
+ mask = mask_;
732
+ }
733
+
734
+ ///< Sets the mask
735
+ CUTLASS_DEVICE void set_mask(Mask const& mask) {
736
+ mask_ = mask;
737
+ }
738
+ };
739
+
740
+ template <typename IT>
741
+ struct MakePrefetchableIterator {
742
+ using Iterator = PredicatedTileIteratorPrefetch<
743
+ typename IT::ThreadMap,
744
+ typename IT::Element>;
745
+ };
746
+
747
+ ///////////////////////////////////////////////////////////////////////////////
748
+
749
+ } // namespace threadblock
750
+ } // namespace epilogue
751
+ } // namespace cutlass
752
+
753
+ ////////////////////////////////////////////////////////////////////////////////
754
+
755
+ #else
756
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
757
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/make_residual_last.h ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ #pragma once
10
+
11
+ #include <ATen/native/transformers/cuda/mem_eff_attention/iterators/predicated_tile_access_iterator_residual_last.h>
12
+ #include <ATen/native/transformers/cuda/mem_eff_attention/iterators/predicated_tile_iterator_residual_last.h>
13
+
14
+
15
+ namespace cutlass {
16
+ namespace transform {
17
+ namespace threadblock {
18
+
19
+ template <typename BaseIterator>
20
+ struct MakeIteratorResidualLast;
21
+
22
+ template <
23
+ typename Shape,
24
+ typename Element,
25
+ typename Layout,
26
+ int AdvanceRank,
27
+ typename ThreadMap,
28
+ int AccessSize,
29
+ bool Gather>
30
+ struct MakeIteratorResidualLast<PredicatedTileIterator<
31
+ Shape,
32
+ Element,
33
+ Layout,
34
+ AdvanceRank,
35
+ ThreadMap,
36
+ AccessSize,
37
+ Gather>> {
38
+ using Iterator = PredicatedTileIteratorResidualLast<
39
+ Shape,
40
+ Element,
41
+ Layout,
42
+ AdvanceRank,
43
+ ThreadMap,
44
+ AccessSize,
45
+ Gather>;
46
+ };
47
+
48
+ template <
49
+ typename Shape,
50
+ typename Element,
51
+ typename Layout,
52
+ int AdvanceRank,
53
+ typename ThreadMap,
54
+ typename AccessType,
55
+ bool Gather>
56
+ struct MakeIteratorResidualLast<PredicatedTileAccessIterator<
57
+ Shape,
58
+ Element,
59
+ Layout,
60
+ AdvanceRank,
61
+ ThreadMap,
62
+ AccessType,
63
+ Gather>> {
64
+ using Iterator = PredicatedTileAccessIteratorResidualLast<
65
+ Shape,
66
+ Element,
67
+ Layout,
68
+ AdvanceRank,
69
+ ThreadMap,
70
+ AccessType,
71
+ Gather>;
72
+ };
73
+ } // namespace threadblock
74
+ } // namespace transform
75
+ } // namespace cutlass
76
+
77
+ #else
78
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
79
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/predicated_tile_access_iterator_residual_last.h ADDED
@@ -0,0 +1,2120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /***************************************************************************************************
3
+ * Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights
4
+ *reserved. SPDX-License-Identifier: BSD-3-Clause
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ *this list of conditions and the following disclaimer.
11
+ *
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ * this list of conditions and the following disclaimer in the documentation
14
+ * and/or other materials provided with the distribution.
15
+ *
16
+ * 3. Neither the name of the copyright holder nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ *ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+ *LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ *INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ *CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ *ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ *POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ **************************************************************************************************/
33
+ /*! \file
34
+ \brief Templates calculating the address and predicates to the load of tiles
35
+ from pitch-linear rank=2 tensors.
36
+
37
+ This iterator uses masks to guard out-of-bounds accesses. The first tile
38
+ this iterator visits maybe partial, then the remaining tiles are complete.
39
+ So, we only need to compute the predicates twice, once before the first tile
40
+ and once for the remaining full tiles which can share the same predicates.
41
+
42
+ A precomputed "Params" object minimizes the amount of state that must be
43
+ stored in registers, and integer addition is used to advance the pointer
44
+ through memory.
45
+ */
46
+
47
+ #pragma once
48
+
49
+ #include <cutlass/array.h>
50
+ #include <cutlass/coord.h>
51
+ #include <cutlass/cutlass.h>
52
+ #include <cutlass/layout/matrix.h>
53
+ #include <cutlass/layout/pitch_linear.h>
54
+ #include <cutlass/matrix_shape.h>
55
+ #include <cutlass/predicate_vector.h>
56
+ #include <cutlass/tensor_ref.h>
57
+ #include <cutlass/tensor_view.h>
58
+ #include <cutlass/transform/threadblock/predicated_tile_access_iterator_params.h>
59
+
60
+ ////////////////////////////////////////////////////////////////////////////////
61
+
62
+ ////////////////////////////////////////////////////////////////////////////////
63
+
64
+ namespace cutlass {
65
+ namespace transform {
66
+ namespace threadblock {
67
+
68
+ ////////////////////////////////////////////////////////////////////////////////
69
+
70
+ /// PredicatedTileAccessIteratorResidualLast
71
+ ///
72
+ template <
73
+ typename Shape,
74
+ typename Element,
75
+ typename Layout,
76
+ int AdvanceRank,
77
+ typename ThreadMap,
78
+ typename AccessType,
79
+ bool Gather = false>
80
+ class PredicatedTileAccessIteratorResidualLast;
81
+
82
+ ////////////////////////////////////////////////////////////////////////////////
83
+
84
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for pitch-linear
85
+ /// data.
86
+ ///
87
+ template <
88
+ typename Shape_,
89
+ typename Element_,
90
+ int AdvanceRank,
91
+ typename ThreadMap_,
92
+ typename AccessType_,
93
+ bool Gather>
94
+ class PredicatedTileAccessIteratorResidualLast<
95
+ Shape_,
96
+ Element_,
97
+ layout::PitchLinear,
98
+ AdvanceRank,
99
+ ThreadMap_,
100
+ AccessType_,
101
+ Gather> {
102
+ public:
103
+ static_assert(
104
+ AdvanceRank == 0 || AdvanceRank == 1,
105
+ "Specialization for pitch-linear iterator may along advance along the "
106
+ "contiguous(rank=0) or strided(rank=1) dimension.");
107
+
108
+ using Shape = Shape_;
109
+ using Element = Element_;
110
+ using Layout = layout::PitchLinear;
111
+ static int const kAdvanceRank = AdvanceRank;
112
+ using ThreadMap = ThreadMap_;
113
+ using AccessType = AccessType_;
114
+
115
+ using Index = typename Layout::Index;
116
+ using LongIndex = typename Layout::LongIndex;
117
+
118
+ using TensorRef = TensorRef<Element, Layout>;
119
+ using TensorView = TensorView<Element, Layout>;
120
+ using TensorCoord = typename Layout::TensorCoord;
121
+
122
+ using Pointer = Element*;
123
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
124
+
125
+ using UnderlyingPredicates = PredicatedTileAccessIteratorPredicates<
126
+ Shape,
127
+ Element,
128
+ Layout,
129
+ AdvanceRank,
130
+ ThreadMap,
131
+ AccessType>;
132
+
133
+ static int const kAccessesPerVector =
134
+ ThreadMap::kElementsPerAccess / AccessType::kElements;
135
+
136
+ static_assert(
137
+ !(ThreadMap::kElementsPerAccess % AccessType::kElements),
138
+ "Vectors implied by the thread map must be divisible by the access type.");
139
+
140
+ using Mask = typename UnderlyingPredicates::Mask;
141
+
142
+ /// Uses a non-template class
143
+ struct Params : PredicatedTileAccessIteratorParams {
144
+ using Base = PredicatedTileAccessIteratorParams;
145
+
146
+ // Default ctor
147
+ CUTLASS_HOST_DEVICE
148
+ Params() {}
149
+
150
+ /// Construct the Params object given a pitch-linear tensor's layout
151
+ CUTLASS_HOST_DEVICE
152
+ Params(Layout const& layout)
153
+ : Base(
154
+ layout.stride(0),
155
+ MakePredicatedTileAccessIteratorDesc<
156
+ Shape,
157
+ Element,
158
+ Layout,
159
+ kAdvanceRank,
160
+ ThreadMap>()()) {}
161
+
162
+ CUTLASS_HOST_DEVICE
163
+ Params(Base const& base) : Base(base) {}
164
+ };
165
+
166
+ private:
167
+ /// Internal pointer type permits fast address arithmetic
168
+ using BytePointer = char*;
169
+
170
+ private:
171
+ //
172
+ // Data members
173
+ //
174
+
175
+ UnderlyingPredicates the_predicates;
176
+ Mask residual_tile_mask;
177
+
178
+ /// Parameters object with precomputed internal state
179
+ Params params_;
180
+
181
+ /// Internal pointer to first access of tile
182
+ BytePointer pointer_;
183
+
184
+ /// Below is used when Gather is turned on. We need to record strided_offset
185
+ /// and contiguous_offset separated to compute the offset by using
186
+ ///
187
+ /// offset = contiguous_offset + indices[strided_offset]
188
+ ///
189
+
190
+ /// Gather indices
191
+ int const* indices_;
192
+
193
+ Index gather_offset_strided;
194
+
195
+ private:
196
+ /// Computes predicates based on internally tracked per-thread offset.
197
+ CUTLASS_DEVICE
198
+ void compute_predicates_(
199
+ /// Extent of the matrix window
200
+ TensorCoord extent,
201
+ /// optionally, simplify predicate calculation during 'steady state' phase
202
+ bool is_steady_state = false) {
203
+ the_predicates.compute_predicates_(extent, is_steady_state);
204
+ }
205
+
206
+ public:
207
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
208
+ /// and thread ID
209
+ CUTLASS_HOST_DEVICE
210
+ PredicatedTileAccessIteratorResidualLast(
211
+ /// Precomputed parameters object
212
+ Params const& params,
213
+ /// Pointer to start of tensor
214
+ Pointer pointer,
215
+ /// Extent of tensor
216
+ TensorCoord extent,
217
+ /// ID of each participating thread
218
+ int thread_id,
219
+ /// Initial offset of threadblock
220
+ TensorCoord const& threadblock_offset,
221
+ /// Gather indices
222
+ int const* indices = nullptr)
223
+ : params_(params),
224
+ pointer_(reinterpret_cast<BytePointer>(
225
+ const_cast<NonConstPointer>(pointer))),
226
+ the_predicates(extent),
227
+ indices_(indices) {
228
+ the_predicates.set_predicates(thread_id, threadblock_offset);
229
+ the_predicates.get_mask(residual_tile_mask);
230
+
231
+ // Working around a weird compiler bug happening on P100 for the backward.
232
+ // I've seen together: the_predicates.predicates_[0] = 14 (instead of 15)
233
+ // residual_tile_mask[0] = 15 (correct)
234
+ //
235
+ // Adding prints when the value is calculated (in `compute_predicates_`)
236
+ // sometimes removes the bug. The consequence is that we skip some
237
+ // element of a tensor, leading to wrong results
238
+ // Setting `compute_predicates_`'s second argument (`is_steady_state`) to
239
+ // true also seems to get rid of the bug - at the cost of twice as many
240
+ // comparisons.
241
+ #if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 700)
242
+ constexpr bool kWorkAroundCompilerBug = false;
243
+ #else
244
+ constexpr bool kWorkAroundCompilerBug = true;
245
+ #endif
246
+ the_predicates.compute_predicates_(extent, true && !kWorkAroundCompilerBug);
247
+
248
+ // update internal pointers
249
+ Layout layout(params_.stride_);
250
+
251
+ if (!Gather) {
252
+ add_pointer_offset(layout(the_predicates.thread_offset_));
253
+ } else {
254
+ gather_offset_strided = the_predicates.thread_offset_.strided();
255
+ add_pointer_offset(
256
+ layout(make_Coord(the_predicates.thread_offset_.contiguous(), 0)));
257
+ }
258
+ }
259
+
260
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
261
+ /// offset
262
+ CUTLASS_HOST_DEVICE
263
+ PredicatedTileAccessIteratorResidualLast(
264
+ /// Precomputed parameters object
265
+ Params const& params,
266
+ /// Pointer to start of tensor
267
+ Pointer pointer,
268
+ /// Extent of tensor
269
+ TensorCoord extent,
270
+ ///< ID of each participating thread
271
+ int thread_id)
272
+ : PredicatedTileAccessIteratorResidualLast(
273
+ params,
274
+ pointer,
275
+ extent,
276
+ thread_id,
277
+ make_Coord(0, 0)) {}
278
+
279
+ /// Overrides the internal iteration index
280
+ CUTLASS_HOST_DEVICE
281
+ void set_iteration_index(int index) {
282
+ the_predicates.set_iteration_index(index);
283
+ }
284
+
285
+ CUTLASS_HOST_DEVICE
286
+ void set_residual_tile(bool is_residual_tile) {
287
+ if (is_residual_tile) {
288
+ the_predicates.set_mask(residual_tile_mask);
289
+ }
290
+ }
291
+
292
+ /// Adds a pointer offset in units of Element
293
+ CUTLASS_HOST_DEVICE
294
+ void add_pointer_offset(LongIndex pointer_offset) {
295
+ pointer_ += sizeof_bits<Element>::value * pointer_offset / 8;
296
+ }
297
+
298
+ /// Advances an iterator along logical dimensions of matrix in units of whole
299
+ /// tiles
300
+ CUTLASS_DEVICE
301
+ void add_tile_offset(TensorCoord const& tile_offset) {
302
+ if (!Gather) {
303
+ if (kAdvanceRank) {
304
+ pointer_ += params_.inc_advance_ * LongIndex(tile_offset.strided());
305
+ pointer_ += Shape::kContiguous * tile_offset.contiguous();
306
+ } else {
307
+ pointer_ += params_.inc_advance_ * LongIndex(tile_offset.contiguous());
308
+ pointer_ += Shape::kStrided * tile_offset.strided();
309
+ }
310
+ } else {
311
+ add_pointer_offset(Shape::kContiguous * tile_offset.contiguous());
312
+ gather_offset_strided += Shape::kStrided * tile_offset.strided();
313
+ }
314
+ }
315
+
316
+ /// Returns a pointer
317
+ CUTLASS_HOST_DEVICE
318
+ AccessType* get() const {
319
+ if (Gather) {
320
+ assert(indices_);
321
+
322
+ if (!valid()) {
323
+ return nullptr;
324
+ }
325
+
326
+ LongIndex contiguous_offset = the_predicates.iteration_contiguous_ *
327
+ (ThreadMap::Delta::kContiguous * sizeof_bits<Element>::value /
328
+ 8) +
329
+ the_predicates.iteration_vector_;
330
+ int strided_index = gather_offset_strided +
331
+ the_predicates.iteration_strided_ * ThreadMap::Delta::kStrided;
332
+
333
+ LongIndex strided_offset = indices_[strided_index] *
334
+ LongIndex(params_.stride_) * sizeof_bits<Element>::value / 8;
335
+
336
+ return reinterpret_cast<AccessType*>(
337
+ pointer_ + contiguous_offset + strided_offset);
338
+ }
339
+
340
+ return reinterpret_cast<AccessType*>(
341
+ pointer_ +
342
+ the_predicates.iteration_contiguous_ *
343
+ (ThreadMap::Delta::kContiguous *
344
+ sizeof_bits<Element>::value) /
345
+ 8) +
346
+ the_predicates.iteration_vector_;
347
+ }
348
+
349
+ /// Increment and return an instance to self.
350
+ CUTLASS_HOST_DEVICE
351
+ PredicatedTileAccessIteratorResidualLast& operator++() {
352
+ the_predicates.operator++();
353
+
354
+ ++the_predicates.iteration_vector_;
355
+ if (the_predicates.iteration_vector_ < kAccessesPerVector) {
356
+ return *this;
357
+ }
358
+
359
+ the_predicates.iteration_vector_ = 0;
360
+ ++the_predicates.iteration_contiguous_;
361
+
362
+ if (the_predicates.iteration_contiguous_ <
363
+ ThreadMap::Iterations::kContiguous) {
364
+ return *this;
365
+ }
366
+
367
+ // Enter here only if (iteration_contiguous_ ==
368
+ // ThreadMap::Iteration::kContiguous)
369
+ the_predicates.iteration_contiguous_ = 0;
370
+ ++the_predicates.iteration_strided_;
371
+
372
+ if (the_predicates.iteration_strided_ < ThreadMap::Iterations::kStrided) {
373
+ if (!Gather) {
374
+ pointer_ += params_.inc_strided_;
375
+ }
376
+
377
+ return *this;
378
+ }
379
+
380
+ // Enter here only if (iteration_stride_ == ThreadMap::Iteration::kStrided)
381
+ // which means we enter the next tile.
382
+ the_predicates.iteration_strided_ = 0;
383
+
384
+ if (!Gather) {
385
+ // advance to next tile
386
+ pointer_ += params_.inc_next_;
387
+
388
+ // now return to start tile - if the iterator is subsequently advanced,
389
+ // this subtraction as well as the subsequent integer addition are both
390
+ // elided by the compiler.
391
+ pointer_ -= params_.inc_advance_;
392
+ }
393
+
394
+ return *this;
395
+ }
396
+
397
+ /// Increment and return an instance to self.
398
+ CUTLASS_HOST_DEVICE
399
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
400
+ PredicatedTileAccessIteratorResidualLast self(*this);
401
+ operator++();
402
+ return self;
403
+ }
404
+
405
+ /// Clears the predicate set efficiently
406
+ CUTLASS_HOST_DEVICE
407
+ void clear_mask(bool enable = true) {
408
+ the_predicates.clear_mask(enable);
409
+ }
410
+
411
+ /// Clears the predicate set efficiently
412
+ CUTLASS_HOST_DEVICE
413
+ void enable_mask() {
414
+ the_predicates.enable_mask();
415
+ }
416
+
417
+ /// Sets the predicate mask, overriding value stored in predicate iterator
418
+ CUTLASS_HOST_DEVICE
419
+ void set_mask(Mask const& mask) {
420
+ the_predicates.set_mask(mask);
421
+ }
422
+
423
+ /// Gets the mask
424
+ CUTLASS_HOST_DEVICE
425
+ void get_mask(Mask& mask) {
426
+ the_predicates.get_mask(mask);
427
+ }
428
+
429
+ /// Returns whether access is valid or not
430
+ CUTLASS_HOST_DEVICE
431
+ bool valid() const {
432
+ return the_predicates.valid();
433
+ }
434
+ };
435
+
436
+ ////////////////////////////////////////////////////////////////////////////////
437
+
438
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for column-major
439
+ /// data.
440
+ ///
441
+ /// Satisfies: ForwardTileIteratorConcept |
442
+ /// ReadableContiguousTileIteratorConcept |
443
+ /// WriteableContiguousTileIteratorConcept |
444
+ /// MaskedTileIteratorConcept
445
+ ///
446
+ template <
447
+ typename Shape_,
448
+ typename Element_,
449
+ int AdvanceRank,
450
+ typename ThreadMap_,
451
+ typename AccessType_,
452
+ bool Gather>
453
+ class PredicatedTileAccessIteratorResidualLast<
454
+ Shape_,
455
+ Element_,
456
+ layout::ColumnMajor,
457
+ AdvanceRank,
458
+ ThreadMap_,
459
+ AccessType_,
460
+ Gather> {
461
+ public:
462
+ static_assert(
463
+ AdvanceRank == 0 || AdvanceRank == 1,
464
+ "Specialization for pitch-linear iterator may along advance along the "
465
+ "contiguous(rank=0) or strided(rank=1) dimension.");
466
+
467
+ using Shape = Shape_;
468
+ using Element = Element_;
469
+ using Layout = layout::ColumnMajor;
470
+ static int const kAdvanceRank = AdvanceRank;
471
+ using ThreadMap = ThreadMap_;
472
+ using AccessType = AccessType_;
473
+
474
+ using Index = typename Layout::Index;
475
+ using LongIndex = typename Layout::LongIndex;
476
+
477
+ using TensorRef = TensorRef<Element, Layout>;
478
+ using TensorView = TensorView<Element, Layout>;
479
+ using TensorCoord = typename Layout::TensorCoord;
480
+
481
+ using Pointer = Element*;
482
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
483
+
484
+ using UnderlyingIterator = PredicatedTileAccessIteratorResidualLast<
485
+ layout::PitchLinearShape<Shape::kRow, Shape::kColumn>,
486
+ Element,
487
+ layout::PitchLinear,
488
+ (kAdvanceRank == 0 ? 0 : 1),
489
+ ThreadMap,
490
+ AccessType,
491
+ Gather>;
492
+
493
+ /// Predicate vector stores mask to guard accesses
494
+ using Mask = typename UnderlyingIterator::Mask;
495
+
496
+ static int const kAccessesPerVector = UnderlyingIterator::kAccessesPerVector;
497
+
498
+ /// Parameters object is precomputed state and is host-constructible
499
+ class Params {
500
+ private:
501
+ friend PredicatedTileAccessIteratorResidualLast;
502
+
503
+ /// Parameters object
504
+ typename UnderlyingIterator::Params params_;
505
+
506
+ public:
507
+ /// Default ctor
508
+ CUTLASS_HOST_DEVICE
509
+ Params() {}
510
+
511
+ /// Construct the Params object given a pitch-linear tensor's layout
512
+ CUTLASS_HOST_DEVICE
513
+ Params(Layout const& layout)
514
+ : params_(layout::PitchLinear(layout.stride(0))){};
515
+
516
+ /// Construct the Params object given a pitch-linear tensor's layout
517
+ CUTLASS_HOST_DEVICE
518
+ Params(typename UnderlyingIterator::Params::Base const& base)
519
+ : params_(base) {}
520
+ };
521
+
522
+ private:
523
+ //
524
+ // Data members
525
+ //
526
+
527
+ /// Underlying pitch-linear tile iterator
528
+ UnderlyingIterator iterator_;
529
+
530
+ public:
531
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
532
+ /// and thread ID
533
+ CUTLASS_HOST_DEVICE
534
+ PredicatedTileAccessIteratorResidualLast(
535
+ ///< Precomputed parameters object
536
+ Params const& params,
537
+ ///< Pointer to start of tensor
538
+ Pointer pointer,
539
+ ///< Extent of tensor
540
+ TensorCoord extent,
541
+ ///< ID of each participating thread
542
+ int thread_id,
543
+ ///< Initial offset of threadblock
544
+ TensorCoord const& threadblock_offset,
545
+ int const* indices =
546
+ nullptr ///< gather/scatter indices, note no support for
547
+ ///< gather/scatter at this specialization
548
+ )
549
+ : iterator_(
550
+ params.params_,
551
+ pointer,
552
+ layout::PitchLinearCoord(extent.row(), extent.column()),
553
+ thread_id,
554
+ layout::PitchLinearCoord(
555
+ threadblock_offset.row(),
556
+ threadblock_offset.column()),
557
+ indices) {}
558
+
559
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
560
+ /// offset
561
+ CUTLASS_HOST_DEVICE
562
+ PredicatedTileAccessIteratorResidualLast(
563
+ Params const& params, ///< Precomputed parameters object
564
+ Pointer pointer, ///< Pointer to start of tensor
565
+ TensorCoord extent, ///< Extent of tensor
566
+ int thread_id ///< ID of each participating thread
567
+ )
568
+ : PredicatedTileAccessIteratorResidualLast(
569
+ params,
570
+ pointer,
571
+ extent,
572
+ thread_id,
573
+ make_Coord(0, 0)) {}
574
+
575
+ /// Overrides the internal iteration index
576
+ CUTLASS_HOST_DEVICE
577
+ void set_iteration_index(int index) {
578
+ iterator_.set_iteration_index(index);
579
+ }
580
+
581
+ CUTLASS_HOST_DEVICE
582
+ void set_residual_tile(bool enable) {
583
+ iterator_.set_residual_tile(enable);
584
+ }
585
+
586
+ /// Adds a pointer offset in units of Element
587
+ CUTLASS_HOST_DEVICE
588
+ void add_pointer_offset(LongIndex pointer_offset) {
589
+ iterator_.add_pointer_offset(pointer_offset);
590
+ }
591
+
592
+ /// Advances an iterator along logical dimensions of matrix in units of whole
593
+ /// tiles
594
+ CUTLASS_HOST_DEVICE
595
+ void add_tile_offset(TensorCoord const& tile_offset) {
596
+ iterator_.add_tile_offset({tile_offset.row(), tile_offset.column()});
597
+ }
598
+
599
+ /// Returns a pointer
600
+ CUTLASS_HOST_DEVICE
601
+ AccessType* get() const {
602
+ return reinterpret_cast<AccessType*>(iterator_.get());
603
+ }
604
+
605
+ /// Advances to the next tile in memory.
606
+ ///
607
+ /// The first time this method is called, predicates are updated, and the
608
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
609
+ /// Subsequent calls are lightweight and must only update the internal
610
+ /// pointer.
611
+ CUTLASS_HOST_DEVICE
612
+ PredicatedTileAccessIteratorResidualLast& operator++() {
613
+ ++iterator_;
614
+ return *this;
615
+ }
616
+
617
+ /// Advances to the next tile in memory.
618
+ ///
619
+ /// The first time this method is called, predicates are updated, and the
620
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
621
+ /// Subsequent calls are lightweight and must only update the internal
622
+ /// pointer.
623
+ CUTLASS_HOST_DEVICE
624
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
625
+ PredicatedTileAccessIteratorResidualLast self(*this);
626
+ operator++();
627
+ return self;
628
+ }
629
+
630
+ /// Clears the predicate set efficiently
631
+ CUTLASS_HOST_DEVICE
632
+ void clear_mask(bool enable = true) {
633
+ iterator_.clear_mask(enable);
634
+ }
635
+
636
+ /// Clears the predicate set efficiently
637
+ CUTLASS_HOST_DEVICE
638
+ void enable_mask() {
639
+ iterator_.enable_mask();
640
+ }
641
+
642
+ /// Sets the predicate mask, overriding value stored in predicate iterator
643
+ CUTLASS_HOST_DEVICE
644
+ void set_mask(Mask const& mask) {
645
+ iterator_.set_mask(mask);
646
+ }
647
+
648
+ /// Gets the mask
649
+ CUTLASS_HOST_DEVICE
650
+ void get_mask(Mask& mask) {
651
+ iterator_.get_mask(mask);
652
+ }
653
+
654
+ /// Returns whether access is valid or not
655
+ CUTLASS_HOST_DEVICE
656
+ bool valid() {
657
+ return iterator_.valid();
658
+ }
659
+ };
660
+
661
+ ////////////////////////////////////////////////////////////////////////////////
662
+
663
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for row-major
664
+ /// data.
665
+ ///
666
+ /// Satisfies: ForwardTileIteratorConcept |
667
+ /// ReadableContiguousTileIteratorConcept |
668
+ /// WriteableContiguousTileIteratorConcept |
669
+ /// MaskedTileIteratorConcept
670
+ ///
671
+ template <
672
+ typename Shape_,
673
+ typename Element_,
674
+ int AdvanceRank,
675
+ typename ThreadMap_,
676
+ typename AccessType_,
677
+ bool Gather>
678
+ class PredicatedTileAccessIteratorResidualLast<
679
+ Shape_,
680
+ Element_,
681
+ layout::RowMajor,
682
+ AdvanceRank,
683
+ ThreadMap_,
684
+ AccessType_,
685
+ Gather> {
686
+ public:
687
+ static_assert(
688
+ AdvanceRank == 0 || AdvanceRank == 1,
689
+ "Specialization for pitch-linear iterator may along advance along the "
690
+ "contiguous(rank=0) or strided(rank=1) dimension.");
691
+
692
+ using Shape = Shape_;
693
+ using Element = Element_;
694
+ using Layout = layout::RowMajor;
695
+ static int const kAdvanceRank = AdvanceRank;
696
+ using ThreadMap = ThreadMap_;
697
+ using AccessType = AccessType_;
698
+
699
+ using Index = typename Layout::Index;
700
+ using LongIndex = typename Layout::LongIndex;
701
+
702
+ using TensorRef = TensorRef<Element, Layout>;
703
+ using TensorView = TensorView<Element, Layout>;
704
+ using TensorCoord = typename Layout::TensorCoord;
705
+
706
+ using Pointer = Element*;
707
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
708
+
709
+ using UnderlyingIterator = PredicatedTileAccessIteratorResidualLast<
710
+ layout::PitchLinearShape<Shape::kColumn, Shape::kRow>,
711
+ Element,
712
+ layout::PitchLinear,
713
+ (kAdvanceRank == 0 ? 1 : 0),
714
+ ThreadMap,
715
+ AccessType,
716
+ Gather>;
717
+
718
+ static int const kAccessesPerVector = UnderlyingIterator::kAccessesPerVector;
719
+
720
+ /// Predicate vector stores mask to guard accesses
721
+ using Mask = typename UnderlyingIterator::Mask;
722
+
723
+ /// Parameters object is precomputed state and is host-constructible
724
+ class Params {
725
+ private:
726
+ friend PredicatedTileAccessIteratorResidualLast;
727
+
728
+ /// Parameters object
729
+ typename UnderlyingIterator::Params params_;
730
+
731
+ public:
732
+ /// Default ctor
733
+ CUTLASS_HOST_DEVICE
734
+ Params() {}
735
+
736
+ /// Construct the Params object given a pitch-linear tensor's layout
737
+ CUTLASS_HOST_DEVICE
738
+ Params(Layout const& layout)
739
+ : params_(layout::PitchLinear(layout.stride(0))){};
740
+
741
+ /// Construct the Params object given a pitch-linear tensor's layout
742
+ CUTLASS_HOST_DEVICE
743
+ Params(typename UnderlyingIterator::Params::Base const& base)
744
+ : params_(base) {}
745
+ };
746
+
747
+ private:
748
+ //
749
+ // Data members
750
+ //
751
+
752
+ /// Underlying pitch-linear tile iterator
753
+ UnderlyingIterator iterator_;
754
+
755
+ public:
756
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
757
+ /// and thread ID
758
+ CUTLASS_HOST_DEVICE
759
+ PredicatedTileAccessIteratorResidualLast(
760
+ ///< Precomputed parameters object
761
+ Params const& params,
762
+ ///< Pointer to start of tensor
763
+ Pointer pointer,
764
+ ///< Extent of tensor
765
+ TensorCoord extent,
766
+ ///< ID of each participating thread
767
+ int thread_id,
768
+ ///< Initial offset of threadblock
769
+ TensorCoord const& threadblock_offset,
770
+ /// Gather indices
771
+ int const* indices = nullptr)
772
+ : iterator_(
773
+ params.params_,
774
+ pointer,
775
+ layout::PitchLinearCoord(extent.column(), extent.row()),
776
+ thread_id,
777
+ layout::PitchLinearCoord(
778
+ threadblock_offset.column(),
779
+ threadblock_offset.row()),
780
+ indices) {}
781
+
782
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
783
+ /// offset
784
+ CUTLASS_HOST_DEVICE
785
+ PredicatedTileAccessIteratorResidualLast(
786
+ Params const& params, ///< Precomputed parameters object
787
+ Pointer pointer, ///< Pointer to start of tensor
788
+ TensorCoord extent, ///< Extent of tensor
789
+ int thread_id ///< ID of each participating thread
790
+ )
791
+ : PredicatedTileAccessIteratorResidualLast(
792
+ params,
793
+ pointer,
794
+ extent,
795
+ thread_id,
796
+ make_Coord(0, 0)) {}
797
+
798
+ /// Overrides the internal iteration index
799
+ CUTLASS_HOST_DEVICE
800
+ void set_iteration_index(int index) {
801
+ iterator_.set_iteration_index(index);
802
+ }
803
+
804
+ CUTLASS_HOST_DEVICE
805
+ void set_residual_tile(bool enable) {
806
+ iterator_.set_residual_tile(enable);
807
+ }
808
+
809
+ /// Adds a pointer offset in units of Element
810
+ CUTLASS_HOST_DEVICE
811
+ void add_pointer_offset(LongIndex pointer_offset) {
812
+ iterator_.add_pointer_offset(pointer_offset);
813
+ }
814
+
815
+ /// Advances an iterator along logical dimensions of matrix in units of whole
816
+ /// tiles
817
+ CUTLASS_HOST_DEVICE
818
+ void add_tile_offset(TensorCoord const& tile_offset) {
819
+ iterator_.add_tile_offset({tile_offset.column(), tile_offset.row()});
820
+ }
821
+
822
+ /// Returns a pointer
823
+ CUTLASS_HOST_DEVICE
824
+ AccessType* get() const {
825
+ return reinterpret_cast<AccessType*>(iterator_.get());
826
+ }
827
+
828
+ /// Advances to the next tile in memory.
829
+ ///
830
+ /// The first time this method is called, predicates are updated, and the
831
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
832
+ /// Subsequent calls are lightweight and must only update the internal
833
+ /// pointer.
834
+ CUTLASS_HOST_DEVICE
835
+ PredicatedTileAccessIteratorResidualLast& operator++() {
836
+ ++iterator_;
837
+ return *this;
838
+ }
839
+
840
+ /// Advances to the next tile in memory.
841
+ ///
842
+ /// The first time this method is called, predicates are updated, and the
843
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
844
+ /// Subsequent calls are lightweight and must only update the internal
845
+ /// pointer.
846
+ CUTLASS_HOST_DEVICE
847
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
848
+ PredicatedTileAccessIteratorResidualLast self(*this);
849
+ operator++();
850
+ return self;
851
+ }
852
+
853
+ /// Clears the predicate set efficiently
854
+ CUTLASS_HOST_DEVICE
855
+ void clear_mask(bool enable = true) {
856
+ iterator_.clear_mask(enable);
857
+ }
858
+
859
+ /// Clears the predicate set efficiently
860
+ CUTLASS_HOST_DEVICE
861
+ void enable_mask() {
862
+ iterator_.enable_mask();
863
+ }
864
+
865
+ /// Sets the predicate mask, overriding value stored in predicate iterator
866
+ CUTLASS_HOST_DEVICE
867
+ void set_mask(Mask const& mask) {
868
+ iterator_.set_mask(mask);
869
+ }
870
+
871
+ /// Gets the mask
872
+ CUTLASS_HOST_DEVICE
873
+ void get_mask(Mask& mask) {
874
+ iterator_.get_mask(mask);
875
+ }
876
+
877
+ /// Returns whether access is valid or not
878
+ CUTLASS_HOST_DEVICE
879
+ bool valid() {
880
+ return iterator_.valid();
881
+ }
882
+ };
883
+
884
+ ////////////////////////////////////////////////////////////////////////////////
885
+
886
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for affine rank 2
887
+ /// data.
888
+ ///
889
+ /// Satisfies: ForwardTileIteratorConcept |
890
+ /// ReadableContiguousTileIteratorConcept |
891
+ /// WriteableContiguousTileIteratorConcept |
892
+ /// MaskedTileIteratorConcept
893
+ ///
894
+ template <
895
+ typename Shape_,
896
+ typename Element_,
897
+ int AdvanceRank,
898
+ typename ThreadMap_,
899
+ typename AccessType_>
900
+ class PredicatedTileAccessIteratorResidualLast<
901
+ Shape_,
902
+ Element_,
903
+ layout::AffineRankN<2>,
904
+ AdvanceRank,
905
+ ThreadMap_,
906
+ AccessType_,
907
+ false> {
908
+ public:
909
+ static_assert(
910
+ AdvanceRank == 0 || AdvanceRank == 1,
911
+ "Specialization for pitch-linear iterator may along advance along the "
912
+ "contiguous(rank=0) or strided(rank=1) dimension.");
913
+
914
+ using Shape = Shape_;
915
+ using Element = Element_;
916
+ using Layout = layout::AffineRankN<2>;
917
+ static int const kAdvanceRank = AdvanceRank;
918
+ using ThreadMap = ThreadMap_;
919
+ using AccessType = AccessType_;
920
+
921
+ using Index = typename Layout::Index;
922
+ using LongIndex = typename Layout::LongIndex;
923
+
924
+ using TensorRef = TensorRef<Element, Layout>;
925
+ using TensorView = TensorView<Element, Layout>;
926
+ using TensorCoord = typename Layout::TensorCoord;
927
+
928
+ using Pointer = Element*;
929
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
930
+
931
+ using UnderlyingPredicates = PredicatedTileAccessIteratorPredicates<
932
+ Shape,
933
+ Element,
934
+ layout::PitchLinear,
935
+ AdvanceRank,
936
+ ThreadMap,
937
+ AccessType>;
938
+
939
+ static int const kAccessesPerVector =
940
+ ThreadMap::kElementsPerAccess / AccessType::kElements;
941
+
942
+ static_assert(
943
+ !(ThreadMap::kElementsPerAccess % AccessType::kElements),
944
+ "Vectors implied by the thread map must be divisible by the access type.");
945
+
946
+ /// Predicate vector stores mask to guard accesses
947
+ using Mask = typename UnderlyingPredicates::Mask;
948
+
949
+ /// Parameters object is precomputed state and is host-constructible
950
+ class Params {
951
+ public:
952
+ friend PredicatedTileAccessIteratorResidualLast;
953
+
954
+ private:
955
+ /// stride of pitch-linear layout (units of Element)
956
+ Coord<Layout::kStrideRank, Layout::LongIndex> stride_;
957
+ /// amount (in byte) to increment pointer to move to next access along
958
+ /// contiguous dimension
959
+ LongIndex inc_contiguous_;
960
+ /// amount (in byte) to increment pointer from first access of current
961
+ /// contiguous dimension to first access of next one.
962
+ LongIndex inc_strided_;
963
+ /// amount (in byte) to increment pointer from last access of current
964
+ /// contiguous dimension to first access of next one.
965
+ LongIndex inc_next_strided_;
966
+ /// amount (in byte) to increment pointer from last access to first access
967
+ /// of next tile
968
+ LongIndex inc_next_;
969
+ /// amount (in byte) to increment pointer from first access of current tile
970
+ /// to first access of next tile
971
+ LongIndex inc_advance_;
972
+
973
+ public:
974
+ // Default ctor
975
+ CUTLASS_HOST_DEVICE
976
+ Params()
977
+ : stride_(0),
978
+ inc_contiguous_(0),
979
+ inc_strided_(0),
980
+ inc_next_(0),
981
+ inc_advance_(0) {}
982
+
983
+ /// Construct the Params object given a pitch-linear tensor's layout
984
+ CUTLASS_HOST_DEVICE
985
+ Params(Layout const& layout)
986
+ : stride_({layout.stride(0), layout.stride(1)}) {
987
+ inc_contiguous_ =
988
+ (LongIndex(stride_[0]) * ThreadMap::Delta::kContiguous) *
989
+ sizeof_bits<Element>::value / 8;
990
+
991
+ inc_strided_ = (LongIndex(stride_[1]) * ThreadMap::Delta::kStrided) *
992
+ sizeof_bits<Element>::value / 8;
993
+
994
+ inc_next_strided_ = inc_strided_ -
995
+ LongIndex(ThreadMap::Iterations::kContiguous - 1) * inc_contiguous_;
996
+
997
+ if (kAdvanceRank) {
998
+ // advance along strided dimension
999
+ inc_advance_ = Shape::kStrided * LongIndex(stride_[1]) *
1000
+ sizeof_bits<Element>::value / 8;
1001
+ } else {
1002
+ // advance along contiguous dimension
1003
+ inc_advance_ =
1004
+ Shape::kContiguous * stride_[0] * sizeof_bits<Element>::value / 8;
1005
+ }
1006
+
1007
+ inc_next_ = inc_advance_ -
1008
+ LongIndex(ThreadMap::Iterations::kContiguous - 1) * inc_contiguous_ -
1009
+ LongIndex(ThreadMap::Iterations::kStrided - 1) * inc_strided_;
1010
+ };
1011
+ };
1012
+
1013
+ private:
1014
+ /// Internal pointer type permits fast address arithmetic
1015
+ using BytePointer = char*;
1016
+
1017
+ //
1018
+ // Data members
1019
+ //
1020
+
1021
+ /// Parameters object with precomputed internal state
1022
+ Params params_;
1023
+
1024
+ /// Internal pointer to first access of tile
1025
+ BytePointer pointer_;
1026
+
1027
+ UnderlyingPredicates the_predicates;
1028
+ Mask residual_tile_mask;
1029
+
1030
+ private:
1031
+ /// Computes predicates based on internally tracked per-thread offset.
1032
+ CUTLASS_DEVICE
1033
+ void compute_predicates_(
1034
+ /// Extent of the matrix window
1035
+ TensorCoord extent,
1036
+ /// optionally, simplify predicate calculation during 'steady state' phase
1037
+ bool is_steady_state = false) {
1038
+ the_predicates.compute_predicates_(extent, is_steady_state);
1039
+ }
1040
+
1041
+ public:
1042
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1043
+ /// and thread ID
1044
+ CUTLASS_HOST_DEVICE
1045
+ PredicatedTileAccessIteratorResidualLast(
1046
+ ///< Precomputed parameters object
1047
+ Params const& params,
1048
+ ///< Pointer to start of tensor
1049
+ Pointer pointer,
1050
+ ///< Extent of tensor
1051
+ TensorCoord extent,
1052
+ ///< ID of each participating thread
1053
+ int thread_id,
1054
+ ///< Initial offset of threadblock
1055
+ TensorCoord const& threadblock_offset,
1056
+ int const* indices =
1057
+ nullptr ///< gather/scatter indices, note no support for
1058
+ ///< gather/scatter at this specialization
1059
+ )
1060
+ : params_(params),
1061
+ pointer_(reinterpret_cast<BytePointer>(
1062
+ const_cast<NonConstPointer>(pointer))),
1063
+ the_predicates(extent) {
1064
+ the_predicates.set_predicates(thread_id, threadblock_offset);
1065
+
1066
+ // update internal pointers
1067
+ Layout layout(params_.stride_);
1068
+ add_pointer_offset(layout(the_predicates.thread_offset_));
1069
+ }
1070
+
1071
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
1072
+ /// offset
1073
+ CUTLASS_HOST_DEVICE
1074
+ PredicatedTileAccessIteratorResidualLast(
1075
+ Params const& params, ///< Precomputed parameters object
1076
+ Pointer pointer, ///< Pointer to start of tensor
1077
+ TensorCoord extent, ///< Extent of tensor
1078
+ int thread_id ///< ID of each participating thread
1079
+ )
1080
+ : PredicatedTileAccessIteratorResidualLast(
1081
+ params,
1082
+ pointer,
1083
+ extent,
1084
+ thread_id,
1085
+ make_Coord(0, 0)) {}
1086
+
1087
+ /// Overrides the internal iteration index
1088
+ CUTLASS_HOST_DEVICE
1089
+ void set_iteration_index(int index) {
1090
+ the_predicates.set_iteration_index(index);
1091
+ }
1092
+
1093
+ CUTLASS_HOST_DEVICE
1094
+ void set_residual_tile(bool is_residual_tile) {
1095
+ if (is_residual_tile) {
1096
+ the_predicates.set_mask(residual_tile_mask);
1097
+ }
1098
+ }
1099
+
1100
+ /// Adds a pointer offset in units of Element
1101
+ CUTLASS_HOST_DEVICE
1102
+ void add_pointer_offset(LongIndex pointer_offset) {
1103
+ pointer_ += sizeof_bits<Element>::value * pointer_offset / 8;
1104
+ }
1105
+
1106
+ /// Advances an iterator along logical dimensions of matrix in units of whole
1107
+ /// tiles
1108
+ CUTLASS_HOST_DEVICE
1109
+ void add_tile_offset(TensorCoord const& tile_offset) {
1110
+ if (kAdvanceRank) {
1111
+ pointer_ += params_.inc_advance_ * LongIndex(tile_offset[1]);
1112
+ pointer_ += Shape::kContiguous * tile_offset[0];
1113
+ } else {
1114
+ pointer_ += params_.inc_advance_ * LongIndex(tile_offset[0]);
1115
+ pointer_ += Shape::kStrided * tile_offset[1];
1116
+ }
1117
+ }
1118
+
1119
+ /// Returns a pointer
1120
+ CUTLASS_HOST_DEVICE
1121
+ AccessType* get() const {
1122
+ return reinterpret_cast<AccessType*>(pointer_) +
1123
+ the_predicates.iteration_vector_;
1124
+ }
1125
+
1126
+ /// Advances to the next tile in memory.
1127
+ ///
1128
+ /// The first time this method is called, predicates are updated, and the
1129
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1130
+ /// Subsequent calls are lightweight and must only update the internal
1131
+ /// pointer.
1132
+ CUTLASS_HOST_DEVICE
1133
+ PredicatedTileAccessIteratorResidualLast& operator++() {
1134
+ the_predicates.operator++();
1135
+ ++the_predicates.iteration_vector_;
1136
+ if (the_predicates.iteration_vector_ < kAccessesPerVector) {
1137
+ return *this;
1138
+ }
1139
+
1140
+ the_predicates.iteration_vector_ = 0;
1141
+ ++the_predicates.iteration_contiguous_;
1142
+
1143
+ if (the_predicates.iteration_contiguous_ <
1144
+ ThreadMap::Iterations::kContiguous) {
1145
+ pointer_ += params_.inc_contiguous_;
1146
+ return *this;
1147
+ }
1148
+
1149
+ // Enter here only if (iteration_contiguous_ ==
1150
+ // ThreadMap::Iteration::kContiguous)
1151
+ the_predicates.iteration_contiguous_ = 0;
1152
+ ++the_predicates.iteration_strided_;
1153
+
1154
+ if (the_predicates.iteration_strided_ < ThreadMap::Iterations::kStrided) {
1155
+ pointer_ += params_.inc_next_strided_;
1156
+ return *this;
1157
+ }
1158
+
1159
+ // Enter here only if (iteration_stride_ == ThreadMap::Iteration::kStrided)
1160
+ // which means we enter the next tile.
1161
+ the_predicates.iteration_strided_ = 0;
1162
+
1163
+ // advance to next tile
1164
+ pointer_ += params_.inc_next_;
1165
+
1166
+ // now return to start tile - if the iterator is subsequently advanced, this
1167
+ // subtraction as well as the subsequent integer addition are both elided by
1168
+ // the compiler.
1169
+ pointer_ -= params_.inc_advance_;
1170
+
1171
+ return *this;
1172
+ }
1173
+
1174
+ /// Advances to the next tile in memory.
1175
+ ///
1176
+ /// The first time this method is called, predicates are updated, and the
1177
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1178
+ /// Subsequent calls are lightweight and must only update the internal
1179
+ /// pointer.
1180
+ CUTLASS_HOST_DEVICE
1181
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
1182
+ PredicatedTileAccessIteratorResidualLast self(*this);
1183
+ operator++();
1184
+ return self;
1185
+ }
1186
+
1187
+ /// Clears the predicate set efficiently
1188
+ CUTLASS_HOST_DEVICE
1189
+ void clear_mask(bool enable = true) {
1190
+ the_predicates.clear_mask(enable);
1191
+ }
1192
+
1193
+ /// Clears the predicate set efficiently
1194
+ CUTLASS_HOST_DEVICE
1195
+ void enable_mask() {
1196
+ the_predicates.enable_mask();
1197
+ }
1198
+
1199
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1200
+ CUTLASS_HOST_DEVICE
1201
+ void set_mask(Mask const& mask) {
1202
+ the_predicates.set_mask(mask);
1203
+ }
1204
+
1205
+ /// Gets the mask
1206
+ CUTLASS_HOST_DEVICE
1207
+ void get_mask(Mask& mask) {
1208
+ the_predicates.get_mask(mask);
1209
+ }
1210
+
1211
+ /// Returns whether access is valid or not
1212
+ CUTLASS_HOST_DEVICE
1213
+ bool valid() {
1214
+ return the_predicates.valid();
1215
+ }
1216
+ };
1217
+
1218
+ ////////////////////////////////////////////////////////////////////////////////
1219
+
1220
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for affine rank 2
1221
+ /// column-major data.
1222
+ ///
1223
+ /// Satisfies: ForwardTileIteratorConcept |
1224
+ /// ReadableContiguousTileIteratorConcept |
1225
+ /// WriteableContiguousTileIteratorConcept |
1226
+ /// MaskedTileIteratorConcept
1227
+ ///
1228
+ template <
1229
+ typename Shape_,
1230
+ typename Element_,
1231
+ int AdvanceRank,
1232
+ typename ThreadMap_,
1233
+ typename AccessType_>
1234
+ class PredicatedTileAccessIteratorResidualLast<
1235
+ Shape_,
1236
+ Element_,
1237
+ layout::AffineRank2ColumnMajor,
1238
+ AdvanceRank,
1239
+ ThreadMap_,
1240
+ AccessType_,
1241
+ false> {
1242
+ public:
1243
+ static_assert(
1244
+ AdvanceRank == 0 || AdvanceRank == 1,
1245
+ "Specialization for pitch-linear iterator may along advance along the "
1246
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1247
+
1248
+ using Shape = Shape_;
1249
+ using Element = Element_;
1250
+ using Layout = layout::AffineRank2ColumnMajor;
1251
+ static int const kAdvanceRank = AdvanceRank;
1252
+ using ThreadMap = ThreadMap_;
1253
+ using AccessType = AccessType_;
1254
+
1255
+ using Index = typename Layout::Index;
1256
+ using LongIndex = typename Layout::LongIndex;
1257
+
1258
+ using TensorRef = TensorRef<Element, Layout>;
1259
+ using TensorView = TensorView<Element, Layout>;
1260
+ using TensorCoord = typename Layout::TensorCoord;
1261
+
1262
+ using Pointer = Element*;
1263
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1264
+
1265
+ // Map to the underlying AffineRankN<2> layout
1266
+ using UnderlyingIterator = PredicatedTileAccessIteratorResidualLast<
1267
+ layout::PitchLinearShape<Shape::kRow, Shape::kColumn>,
1268
+ Element,
1269
+ layout::AffineRankN<2>,
1270
+ (kAdvanceRank == 0 ? 0 : 1),
1271
+ ThreadMap,
1272
+ AccessType>;
1273
+
1274
+ static int const kAccessesPerVector = UnderlyingIterator::kAccessesPerVector;
1275
+
1276
+ /// Predicate vector stores mask to guard accesses
1277
+ using Mask = typename UnderlyingIterator::Mask;
1278
+
1279
+ /// Parameters object is precomputed state and is host-constructible
1280
+ class Params {
1281
+ private:
1282
+ friend PredicatedTileAccessIteratorResidualLast;
1283
+
1284
+ /// Parameters object
1285
+ typename UnderlyingIterator::Params params_;
1286
+
1287
+ public:
1288
+ /// Default ctor
1289
+ CUTLASS_HOST_DEVICE
1290
+ Params() {}
1291
+
1292
+ /// Construct the Params object given an AffineRankN<2> tensor's layout
1293
+ CUTLASS_HOST_DEVICE
1294
+ Params(Layout const& layout)
1295
+ : params_(layout::AffineRankN<2>(layout.stride(0), layout.stride(1))){};
1296
+ };
1297
+
1298
+ private:
1299
+ //
1300
+ // Data members
1301
+ //
1302
+
1303
+ /// Underlying AffineRankN<2> tile iterator
1304
+ UnderlyingIterator iterator_;
1305
+
1306
+ public:
1307
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1308
+ /// and thread ID
1309
+ CUTLASS_HOST_DEVICE
1310
+ PredicatedTileAccessIteratorResidualLast(
1311
+ ///< Precomputed parameters object
1312
+ Params const& params,
1313
+ ///< Pointer to start of tensor
1314
+ Pointer pointer,
1315
+ ///< Extent of tensor
1316
+ TensorCoord extent,
1317
+ ///< ID of each participating thread
1318
+ int thread_id,
1319
+ ///< Initial offset of threadblock
1320
+ TensorCoord const& threadblock_offset,
1321
+ int const* indices =
1322
+ nullptr ///< gather/scatter indices, note no support for
1323
+ ///< gather/scatter at this specialization
1324
+ )
1325
+ : iterator_(
1326
+ params.params_,
1327
+ pointer,
1328
+ layout::PitchLinearCoord(extent.row(), extent.column()),
1329
+ thread_id,
1330
+ layout::PitchLinearCoord(
1331
+ threadblock_offset.row(),
1332
+ threadblock_offset.column())) {}
1333
+
1334
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
1335
+ /// offset
1336
+ CUTLASS_HOST_DEVICE
1337
+ PredicatedTileAccessIteratorResidualLast(
1338
+ Params const& params, ///< Precomputed parameters object
1339
+ Pointer pointer, ///< Pointer to start of tensor
1340
+ TensorCoord extent, ///< Extent of tensor
1341
+ int thread_id ///< ID of each participating thread
1342
+ )
1343
+ : PredicatedTileAccessIteratorResidualLast(
1344
+ params,
1345
+ pointer,
1346
+ extent,
1347
+ thread_id,
1348
+ make_Coord(0, 0)) {}
1349
+
1350
+ /// Overrides the internal iteration index
1351
+ CUTLASS_HOST_DEVICE
1352
+ void set_iteration_index(int index) {
1353
+ iterator_.set_iteration_index(index);
1354
+ }
1355
+
1356
+ CUTLASS_HOST_DEVICE
1357
+ void set_residual_tile(bool enable) {
1358
+ iterator_.set_residual_tile(enable);
1359
+ }
1360
+
1361
+ /// Adds a pointer offset in units of Element
1362
+ CUTLASS_HOST_DEVICE
1363
+ void add_pointer_offset(LongIndex pointer_offset) {
1364
+ iterator_.add_pointer_offset(pointer_offset);
1365
+ }
1366
+
1367
+ /// Advances an iterator along logical dimensions of matrix in units of whole
1368
+ /// tiles
1369
+ CUTLASS_HOST_DEVICE
1370
+ void add_tile_offset(TensorCoord const& tile_offset) {
1371
+ iterator_.add_tile_offset(
1372
+ make_Coord(tile_offset.row(), tile_offset.column()));
1373
+ }
1374
+
1375
+ /// Returns a pointer
1376
+ CUTLASS_HOST_DEVICE
1377
+ AccessType* get() const {
1378
+ return reinterpret_cast<AccessType*>(iterator_.get());
1379
+ }
1380
+
1381
+ /// Advances to the next tile in memory.
1382
+ ///
1383
+ /// The first time this method is called, predicates are updated, and the
1384
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1385
+ /// Subsequent calls are lightweight and must only update the internal
1386
+ /// pointer.
1387
+ CUTLASS_HOST_DEVICE
1388
+ PredicatedTileAccessIteratorResidualLast& operator++() {
1389
+ ++iterator_;
1390
+ return *this;
1391
+ }
1392
+
1393
+ /// Advances to the next tile in memory.
1394
+ ///
1395
+ /// The first time this method is called, predicates are updated, and the
1396
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1397
+ /// Subsequent calls are lightweight and must only update the internal
1398
+ /// pointer.
1399
+ CUTLASS_HOST_DEVICE
1400
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
1401
+ PredicatedTileAccessIteratorResidualLast self(*this);
1402
+ operator++();
1403
+ return self;
1404
+ }
1405
+
1406
+ /// Clears the predicate set efficiently
1407
+ CUTLASS_HOST_DEVICE
1408
+ void clear_mask(bool enable = true) {
1409
+ iterator_.clear_mask(enable);
1410
+ }
1411
+
1412
+ /// Clears the predicate set efficiently
1413
+ CUTLASS_HOST_DEVICE
1414
+ void enable_mask() {
1415
+ iterator_.enable_mask();
1416
+ }
1417
+
1418
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1419
+ CUTLASS_HOST_DEVICE
1420
+ void set_mask(Mask const& mask) {
1421
+ iterator_.set_mask(mask);
1422
+ }
1423
+
1424
+ /// Gets the mask
1425
+ CUTLASS_HOST_DEVICE
1426
+ void get_mask(Mask& mask) {
1427
+ iterator_.get_mask(mask);
1428
+ }
1429
+
1430
+ /// Returns whether access is valid or not
1431
+ CUTLASS_HOST_DEVICE
1432
+ bool valid() {
1433
+ return iterator_.valid();
1434
+ }
1435
+ };
1436
+
1437
+ ////////////////////////////////////////////////////////////////////////////////
1438
+
1439
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for affine rank-2
1440
+ /// row-major data.
1441
+ ///
1442
+ /// Satisfies: ForwardTileIteratorConcept |
1443
+ /// ReadableContiguousTileIteratorConcept |
1444
+ /// WriteableContiguousTileIteratorConcept |
1445
+ /// MaskedTileIteratorConcept
1446
+ ///
1447
+ template <
1448
+ typename Shape_,
1449
+ typename Element_,
1450
+ int AdvanceRank,
1451
+ typename ThreadMap_,
1452
+ typename AccessType_>
1453
+ class PredicatedTileAccessIteratorResidualLast<
1454
+ Shape_,
1455
+ Element_,
1456
+ layout::AffineRank2RowMajor,
1457
+ AdvanceRank,
1458
+ ThreadMap_,
1459
+ AccessType_,
1460
+ false> {
1461
+ public:
1462
+ static_assert(
1463
+ AdvanceRank == 0 || AdvanceRank == 1,
1464
+ "Specialization for pitch-linear iterator may along advance along the "
1465
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1466
+
1467
+ using Shape = Shape_;
1468
+ using Element = Element_;
1469
+ using Layout = layout::AffineRank2RowMajor;
1470
+ static int const kAdvanceRank = AdvanceRank;
1471
+ using ThreadMap = ThreadMap_;
1472
+ using AccessType = AccessType_;
1473
+
1474
+ using Index = typename Layout::Index;
1475
+ using LongIndex = typename Layout::LongIndex;
1476
+
1477
+ using TensorRef = TensorRef<Element, Layout>;
1478
+ using TensorView = TensorView<Element, Layout>;
1479
+ using TensorCoord = typename Layout::TensorCoord;
1480
+
1481
+ using Pointer = Element*;
1482
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1483
+
1484
+ // Map to the underlying AffineRankN<2> layout
1485
+ using UnderlyingIterator = PredicatedTileAccessIteratorResidualLast<
1486
+ layout::PitchLinearShape<Shape::kColumn, Shape::kRow>,
1487
+ Element,
1488
+ layout::AffineRankN<2>,
1489
+ (kAdvanceRank == 0 ? 1 : 0),
1490
+ ThreadMap,
1491
+ AccessType>;
1492
+
1493
+ static int const kAccessesPerVector = UnderlyingIterator::kAccessesPerVector;
1494
+
1495
+ /// Predicate vector stores mask to guard accesses
1496
+ using Mask = typename UnderlyingIterator::Mask;
1497
+
1498
+ /// Parameters object is precomputed state and is host-constructible
1499
+ class Params {
1500
+ private:
1501
+ friend PredicatedTileAccessIteratorResidualLast;
1502
+
1503
+ /// Parameters object
1504
+ typename UnderlyingIterator::Params params_;
1505
+
1506
+ public:
1507
+ /// Default ctor
1508
+ CUTLASS_HOST_DEVICE
1509
+ Params() {}
1510
+
1511
+ /// Construct the Params object given an AffineRankN<2> tensor's layout
1512
+ CUTLASS_HOST_DEVICE
1513
+ Params(Layout const& layout)
1514
+ : params_(layout::AffineRankN<2>(layout.stride(1), layout.stride(0))){};
1515
+ };
1516
+
1517
+ private:
1518
+ //
1519
+ // Data members
1520
+ //
1521
+
1522
+ /// Underlying AffineRankN<2> tile iterator
1523
+ UnderlyingIterator iterator_;
1524
+
1525
+ public:
1526
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1527
+ /// and thread ID
1528
+ CUTLASS_HOST_DEVICE
1529
+ PredicatedTileAccessIteratorResidualLast(
1530
+ ///< Precomputed parameters object
1531
+ Params const& params,
1532
+ ///< Pointer to start of tensor
1533
+ Pointer pointer,
1534
+ ///< Extent of tensor
1535
+ TensorCoord extent,
1536
+ ///< ID of each participating thread
1537
+ int thread_id,
1538
+ ///< Initial offset of threadblock
1539
+ TensorCoord const& threadblock_offset,
1540
+ int const* indices =
1541
+ nullptr ///< gather/scatter indices, note no support for
1542
+ ///< gather/scatter at this specialization
1543
+ )
1544
+ : iterator_(
1545
+ params.params_,
1546
+ pointer,
1547
+ layout::PitchLinearCoord(extent.column(), extent.row()),
1548
+ thread_id,
1549
+ layout::PitchLinearCoord(
1550
+ threadblock_offset.column(),
1551
+ threadblock_offset.row())) {}
1552
+
1553
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
1554
+ /// offset
1555
+ CUTLASS_HOST_DEVICE
1556
+ PredicatedTileAccessIteratorResidualLast(
1557
+ Params const& params, ///< Precomputed parameters object
1558
+ Pointer pointer, ///< Pointer to start of tensor
1559
+ TensorCoord extent, ///< Extent of tensor
1560
+ int thread_id ///< ID of each participating thread
1561
+ )
1562
+ : PredicatedTileAccessIteratorResidualLast(
1563
+ params,
1564
+ pointer,
1565
+ extent,
1566
+ thread_id,
1567
+ make_Coord(0, 0)) {}
1568
+
1569
+ /// Overrides the internal iteration index
1570
+ CUTLASS_HOST_DEVICE
1571
+ void set_iteration_index(int index) {
1572
+ iterator_.set_iteration_index(index);
1573
+ }
1574
+
1575
+ CUTLASS_HOST_DEVICE
1576
+ void set_residual_tile(bool enable) {
1577
+ iterator_.set_residual_tile(enable);
1578
+ }
1579
+
1580
+ /// Adds a pointer offset in units of Element
1581
+ CUTLASS_HOST_DEVICE
1582
+ void add_pointer_offset(LongIndex pointer_offset) {
1583
+ iterator_.add_pointer_offset(pointer_offset);
1584
+ }
1585
+
1586
+ /// Advances an iterator along logical dimensions of matrix in units of whole
1587
+ /// tiles
1588
+ CUTLASS_HOST_DEVICE
1589
+ void add_tile_offset(TensorCoord const& tile_offset) {
1590
+ iterator_.add_tile_offset(
1591
+ make_Coord(tile_offset.column(), tile_offset.row()));
1592
+ }
1593
+
1594
+ /// Returns a pointer
1595
+ CUTLASS_HOST_DEVICE
1596
+ AccessType* get() const {
1597
+ return reinterpret_cast<AccessType*>(iterator_.get());
1598
+ }
1599
+
1600
+ /// Advances to the next tile in memory.
1601
+ ///
1602
+ /// The first time this method is called, predicates are updated, and the
1603
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1604
+ /// Subsequent calls are lightweight and must only update the internal
1605
+ /// pointer.
1606
+ CUTLASS_HOST_DEVICE
1607
+ PredicatedTileAccessIteratorResidualLast& operator++() {
1608
+ ++iterator_;
1609
+ return *this;
1610
+ }
1611
+
1612
+ /// Advances to the next tile in memory.
1613
+ ///
1614
+ /// The first time this method is called, predicates are updated, and the
1615
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1616
+ /// Subsequent calls are lightweight and must only update the internal
1617
+ /// pointer.
1618
+ CUTLASS_HOST_DEVICE
1619
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
1620
+ PredicatedTileAccessIteratorResidualLast self(*this);
1621
+ operator++();
1622
+ return self;
1623
+ }
1624
+
1625
+ /// Clears the predicate set efficiently
1626
+ CUTLASS_HOST_DEVICE
1627
+ void clear_mask(bool enable = true) {
1628
+ iterator_.clear_mask(enable);
1629
+ }
1630
+
1631
+ /// Clears the predicate set efficiently
1632
+ CUTLASS_HOST_DEVICE
1633
+ void enable_mask() {
1634
+ iterator_.enable_mask();
1635
+ }
1636
+
1637
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1638
+ CUTLASS_HOST_DEVICE
1639
+ void set_mask(Mask const& mask) {
1640
+ iterator_.set_mask(mask);
1641
+ }
1642
+
1643
+ /// Gets the mask
1644
+ CUTLASS_HOST_DEVICE
1645
+ void get_mask(Mask& mask) {
1646
+ iterator_.get_mask(mask);
1647
+ }
1648
+
1649
+ /// Returns whether access is valid or not
1650
+ CUTLASS_HOST_DEVICE
1651
+ bool valid() {
1652
+ return iterator_.valid();
1653
+ }
1654
+ };
1655
+
1656
+ ////////////////////////////////////////////////////////////////////////////////
1657
+
1658
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for column-major
1659
+ /// interleaved data. It is mapped to the congruous layout.
1660
+ ///
1661
+ /// Satisfies: ForwardTileIteratorConcept |
1662
+ /// ReadableContiguousTileIteratorConcept |
1663
+ /// WriteableContiguousTileIteratorConcept |
1664
+ /// MaskedTileIteratorConcept
1665
+ ///
1666
+
1667
+ template <
1668
+ typename Shape_,
1669
+ typename Element_,
1670
+ int AdvanceRank,
1671
+ typename ThreadMap_,
1672
+ typename AccessType_,
1673
+ int InterleavedK>
1674
+ class PredicatedTileAccessIteratorResidualLast<
1675
+ Shape_,
1676
+ Element_,
1677
+ layout::ColumnMajorInterleaved<InterleavedK>,
1678
+ AdvanceRank,
1679
+ ThreadMap_,
1680
+ AccessType_,
1681
+ false> {
1682
+ public:
1683
+ static_assert(
1684
+ AdvanceRank == 0 || AdvanceRank == 1,
1685
+ "Specialization for pitch-linear iterator may along advance along the "
1686
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1687
+
1688
+ using Shape = Shape_;
1689
+ using Element = Element_;
1690
+ static int const kInterleavedK = InterleavedK;
1691
+ using Layout = layout::ColumnMajorInterleaved<kInterleavedK>;
1692
+ static int const kAdvanceRank = AdvanceRank;
1693
+ using ThreadMap = ThreadMap_;
1694
+ using AccessType = AccessType_;
1695
+
1696
+ using Index = typename Layout::Index;
1697
+ using LongIndex = typename Layout::LongIndex;
1698
+
1699
+ using TensorRef = TensorRef<Element, Layout>;
1700
+ using TensorView = TensorView<Element, Layout>;
1701
+ using TensorCoord = typename Layout::TensorCoord;
1702
+
1703
+ using Pointer = Element*;
1704
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1705
+
1706
+ using UnderlyingIterator = PredicatedTileAccessIteratorResidualLast<
1707
+ layout::PitchLinearShape<
1708
+ Shape::kRow * kInterleavedK,
1709
+ Shape::kColumn / kInterleavedK>,
1710
+ Element,
1711
+ layout::PitchLinear,
1712
+ (kAdvanceRank == 0 ? 0 : 1),
1713
+ ThreadMap,
1714
+ AccessType>;
1715
+
1716
+ static int const kAccessesPerVector = UnderlyingIterator::kAccessesPerVector;
1717
+
1718
+ /// Predicate vector stores mask to guard accesses
1719
+ using Mask = typename UnderlyingIterator::Mask;
1720
+
1721
+ /// Parameters object is precomputed state and is host-constructible
1722
+ class Params {
1723
+ private:
1724
+ friend PredicatedTileAccessIteratorResidualLast;
1725
+
1726
+ /// Parameters object
1727
+ typename UnderlyingIterator::Params params_;
1728
+
1729
+ public:
1730
+ CUTLASS_HOST_DEVICE
1731
+ Params() {}
1732
+
1733
+ /// Construct the Params object given a pitch-linear tensor's layout
1734
+ CUTLASS_HOST_DEVICE
1735
+ Params(Layout const& layout)
1736
+ : params_(layout::PitchLinear(layout.stride(0))) {}
1737
+
1738
+ CUTLASS_HOST_DEVICE
1739
+ Params(typename UnderlyingIterator::Params::Base const& base)
1740
+ : params_(base) {}
1741
+ };
1742
+
1743
+ private:
1744
+ //
1745
+ // Data members
1746
+ //
1747
+
1748
+ /// Underlying pitch-linear tile iterator
1749
+ UnderlyingIterator iterator_;
1750
+
1751
+ public:
1752
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1753
+ /// and thread ID
1754
+ CUTLASS_HOST_DEVICE
1755
+ PredicatedTileAccessIteratorResidualLast(
1756
+ /// Precomputed parameters object
1757
+ Params const& params,
1758
+ /// Pointer to start of tensor
1759
+ Pointer pointer,
1760
+ /// Extent of tensor
1761
+ TensorCoord extent,
1762
+ /// ID of each participating thread
1763
+ int thread_id,
1764
+ /// Initial offset of threadblock
1765
+ TensorCoord const& threadblock_offset,
1766
+ int const* indices =
1767
+ nullptr ///< gather/scatter indices, note no support for
1768
+ ///< gather/scatter at this specialization
1769
+ )
1770
+ : iterator_(
1771
+ params.params_,
1772
+ pointer,
1773
+ layout::PitchLinearCoord(
1774
+ extent.row() * kInterleavedK,
1775
+ extent.column() / kInterleavedK),
1776
+ thread_id,
1777
+ layout::PitchLinearCoord(
1778
+ threadblock_offset.row() * kInterleavedK,
1779
+ threadblock_offset.column() / kInterleavedK)) {}
1780
+
1781
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
1782
+ /// offset
1783
+ CUTLASS_HOST_DEVICE
1784
+ PredicatedTileAccessIteratorResidualLast(
1785
+ Params const& params, ///< Precomputed parameters object
1786
+ Pointer pointer, ///< Pointer to start of tensor
1787
+ TensorCoord extent, ///< Extent of tensor
1788
+ int thread_id ///< ID of each participating thread
1789
+ )
1790
+ : PredicatedTileAccessIteratorResidualLast(
1791
+ params,
1792
+ pointer,
1793
+ extent,
1794
+ thread_id,
1795
+ make_Coord(0, 0)) {}
1796
+
1797
+ /// Overrides the internal iteration index
1798
+ CUTLASS_HOST_DEVICE
1799
+ void set_iteration_index(int index) {
1800
+ iterator_.set_iteration_index(index);
1801
+ }
1802
+
1803
+ CUTLASS_HOST_DEVICE
1804
+ void set_residual_tile(bool enable) {
1805
+ iterator_.set_residual_tile(enable);
1806
+ }
1807
+
1808
+ /// Adds a pointer offset in units of Element
1809
+ CUTLASS_HOST_DEVICE
1810
+ void add_pointer_offset(LongIndex pointer_offset) {
1811
+ iterator_.add_pointer_offset(pointer_offset);
1812
+ }
1813
+
1814
+ /// Advances an iterator along logical dimensions of matrix in units of whole
1815
+ /// tiles
1816
+ CUTLASS_HOST_DEVICE
1817
+ void add_tile_offset(TensorCoord const& tile_offset) {
1818
+ iterator_.add_tile_offset({tile_offset.row(), tile_offset.column()});
1819
+ }
1820
+
1821
+ /// Returns a pointer
1822
+ CUTLASS_HOST_DEVICE
1823
+ AccessType* get() const {
1824
+ return reinterpret_cast<AccessType*>(iterator_.get());
1825
+ }
1826
+
1827
+ /// Advances to the next tile in memory.
1828
+ ///
1829
+ /// The first time this method is called, predicates are updated, and the
1830
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1831
+ /// Subsequent calls are lightweight and must only update the internal
1832
+ /// pointer.
1833
+ CUTLASS_HOST_DEVICE
1834
+ PredicatedTileAccessIteratorResidualLast& operator++() {
1835
+ ++iterator_;
1836
+ return *this;
1837
+ }
1838
+
1839
+ /// Advances to the next tile in memory.
1840
+ ///
1841
+ /// The first time this method is called, predicates are updated, and the
1842
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1843
+ /// Subsequent calls are lightweight and must only update the internal
1844
+ /// pointer.
1845
+ CUTLASS_HOST_DEVICE
1846
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
1847
+ PredicatedTileAccessIteratorResidualLast self(*this);
1848
+ operator++();
1849
+ return self;
1850
+ }
1851
+
1852
+ /// Clears the predicate set efficiently
1853
+ CUTLASS_HOST_DEVICE
1854
+ void clear_mask(bool enable = true) {
1855
+ iterator_.clear_mask(enable);
1856
+ }
1857
+
1858
+ /// Clears the predicate set efficiently
1859
+ CUTLASS_HOST_DEVICE
1860
+ void enable_mask() {
1861
+ iterator_.enable_mask();
1862
+ }
1863
+
1864
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1865
+ CUTLASS_HOST_DEVICE
1866
+ void set_mask(Mask const& mask) {
1867
+ iterator_.set_mask(mask);
1868
+ }
1869
+
1870
+ /// Gets the mask
1871
+ CUTLASS_HOST_DEVICE
1872
+ void get_mask(Mask& mask) {
1873
+ iterator_.get_mask(mask);
1874
+ }
1875
+
1876
+ /// Returns whether access is valid or not
1877
+ CUTLASS_HOST_DEVICE
1878
+ bool valid() {
1879
+ return iterator_.valid();
1880
+ }
1881
+ };
1882
+
1883
+ ////////////////////////////////////////////////////////////////////////////////
1884
+
1885
+ /// Specialization of PredicatedTileAccessIteratorResidualLast for row-major
1886
+ /// interleaved data.
1887
+ // It is mapped to the congruous layout.
1888
+ ///
1889
+ /// Satisfies: ForwardTileIteratorConcept |
1890
+ /// ReadableContiguousTileIteratorConcept |
1891
+ /// WriteableContiguousTileIteratorConcept |
1892
+ /// MaskedTileIteratorConcept
1893
+ ///
1894
+ template <
1895
+ typename Shape_,
1896
+ typename Element_,
1897
+ int AdvanceRank,
1898
+ typename ThreadMap_,
1899
+ typename AccessType_,
1900
+ int InterleavedK>
1901
+ class PredicatedTileAccessIteratorResidualLast<
1902
+ Shape_,
1903
+ Element_,
1904
+ layout::RowMajorInterleaved<InterleavedK>,
1905
+ AdvanceRank,
1906
+ ThreadMap_,
1907
+ AccessType_,
1908
+ false> {
1909
+ public:
1910
+ static_assert(
1911
+ AdvanceRank == 0 || AdvanceRank == 1,
1912
+ "Specialization for pitch-linear iterator may along advance along the "
1913
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1914
+
1915
+ using Shape = Shape_;
1916
+ using Element = Element_;
1917
+ static int const kInterleavedK = InterleavedK;
1918
+ using Layout = layout::RowMajorInterleaved<kInterleavedK>;
1919
+ static int const kAdvanceRank = AdvanceRank;
1920
+ using ThreadMap = ThreadMap_;
1921
+ using AccessType = AccessType_;
1922
+
1923
+ using Index = typename Layout::Index;
1924
+ using LongIndex = typename Layout::LongIndex;
1925
+
1926
+ using TensorRef = TensorRef<Element, Layout>;
1927
+ using TensorView = TensorView<Element, Layout>;
1928
+ using TensorCoord = typename Layout::TensorCoord;
1929
+
1930
+ using Pointer = Element*;
1931
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1932
+
1933
+ using UnderlyingIterator = PredicatedTileAccessIteratorResidualLast<
1934
+ layout::PitchLinearShape<
1935
+ Shape::kColumn * kInterleavedK,
1936
+ Shape::kRow / kInterleavedK>,
1937
+ Element,
1938
+ layout::PitchLinear,
1939
+ (kAdvanceRank == 0 ? 1 : 0),
1940
+ ThreadMap,
1941
+ AccessType>;
1942
+
1943
+ static int const kAccessesPerVector = UnderlyingIterator::kAccessesPerVector;
1944
+
1945
+ /// Predicate vector stores mask to guard accesses
1946
+ using Mask = typename UnderlyingIterator::Mask;
1947
+
1948
+ /// Parameters object is precomputed state and is host-constructible
1949
+ class Params {
1950
+ private:
1951
+ friend PredicatedTileAccessIteratorResidualLast;
1952
+
1953
+ /// Parameters object
1954
+ typename UnderlyingIterator::Params params_;
1955
+
1956
+ public:
1957
+ CUTLASS_HOST_DEVICE
1958
+ Params() {}
1959
+
1960
+ /// Construct the Params object given a pitch-linear tensor's layout
1961
+ CUTLASS_HOST_DEVICE
1962
+ Params(Layout const& layout)
1963
+ : params_(layout::PitchLinear(layout.stride(0))) {}
1964
+
1965
+ CUTLASS_HOST_DEVICE
1966
+ Params(typename UnderlyingIterator::Params::Base const& base)
1967
+ : params_(base) {}
1968
+ };
1969
+
1970
+ private:
1971
+ //
1972
+ // Data members
1973
+ //
1974
+
1975
+ /// Underlying pitch-linear tile iterator
1976
+ UnderlyingIterator iterator_;
1977
+
1978
+ public:
1979
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1980
+ /// and thread ID
1981
+ CUTLASS_HOST_DEVICE
1982
+ PredicatedTileAccessIteratorResidualLast(
1983
+ /// Precomputed parameters object
1984
+ Params const& params,
1985
+ /// Pointer to start of tensor
1986
+ Pointer pointer,
1987
+ /// Extent of tensor
1988
+ TensorCoord extent,
1989
+ /// ID of each participating thread
1990
+ int thread_id,
1991
+ /// Initial offset of threadblock
1992
+ TensorCoord const& threadblock_offset,
1993
+ int const* indices =
1994
+ nullptr ///< gather/scatter indices, note no support for
1995
+ ///< gather/scatter at this specialization
1996
+ )
1997
+ : iterator_(
1998
+ params.params_,
1999
+ pointer,
2000
+ layout::PitchLinearCoord(
2001
+ extent.column() * kInterleavedK,
2002
+ extent.row() / kInterleavedK),
2003
+ thread_id,
2004
+ layout::PitchLinearCoord(
2005
+ threadblock_offset.column() * kInterleavedK,
2006
+ threadblock_offset.row() / kInterleavedK)) {}
2007
+
2008
+ /// Construct a PredicatedTileAccessIteratorResidualLast with zero threadblock
2009
+ /// offset
2010
+ CUTLASS_HOST_DEVICE
2011
+ PredicatedTileAccessIteratorResidualLast(
2012
+ Params const& params, ///< Precomputed parameters object
2013
+ Pointer pointer, ///< Pointer to start of tensor
2014
+ TensorCoord extent, ///< Extent of tensor
2015
+ int thread_id ///< ID of each participating thread
2016
+ )
2017
+ : PredicatedTileAccessIteratorResidualLast(
2018
+ params,
2019
+ pointer,
2020
+ extent,
2021
+ thread_id,
2022
+ make_Coord(0, 0)) {}
2023
+
2024
+ /// Overrides the internal iteration index
2025
+ CUTLASS_HOST_DEVICE
2026
+ void set_iteration_index(int index) {
2027
+ iterator_.set_iteration_index(index);
2028
+ }
2029
+
2030
+ CUTLASS_HOST_DEVICE
2031
+ void set_residual_tile(bool enable) {
2032
+ iterator_.set_residual_tile(enable);
2033
+ }
2034
+
2035
+ /// Adds a pointer offset in units of Element
2036
+ CUTLASS_HOST_DEVICE
2037
+ void add_pointer_offset(LongIndex pointer_offset) {
2038
+ iterator_.add_pointer_offset(pointer_offset);
2039
+ }
2040
+
2041
+ /// Advances an iterator along logical dimensions of matrix in units of whole
2042
+ /// tiles
2043
+ CUTLASS_HOST_DEVICE
2044
+ void add_tile_offset(TensorCoord const& tile_offset) {
2045
+ iterator_.add_tile_offset({tile_offset.column(), tile_offset.row()});
2046
+ }
2047
+
2048
+ /// Returns a pointer
2049
+ CUTLASS_HOST_DEVICE
2050
+ AccessType* get() const {
2051
+ return reinterpret_cast<AccessType*>(iterator_.get());
2052
+ }
2053
+
2054
+ /// Advances to the next tile in memory.
2055
+ ///
2056
+ /// The first time this method is called, predicates are updated, and the
2057
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
2058
+ /// Subsequent calls are lightweight and must only update the internal
2059
+ /// pointer.
2060
+ CUTLASS_HOST_DEVICE
2061
+ PredicatedTileAccessIteratorResidualLast& operator++() {
2062
+ ++iterator_;
2063
+ return *this;
2064
+ }
2065
+
2066
+ /// Advances to the next tile in memory.
2067
+ ///
2068
+ /// The first time this method is called, predicates are updated, and the
2069
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
2070
+ /// Subsequent calls are lightweight and must only update the internal
2071
+ /// pointer.
2072
+ CUTLASS_HOST_DEVICE
2073
+ PredicatedTileAccessIteratorResidualLast operator++(int) {
2074
+ PredicatedTileAccessIteratorResidualLast self(*this);
2075
+ operator++();
2076
+ return self;
2077
+ }
2078
+
2079
+ /// Clears the predicate set efficiently
2080
+ CUTLASS_HOST_DEVICE
2081
+ void clear_mask(bool enable = true) {
2082
+ iterator_.clear_mask(enable);
2083
+ }
2084
+
2085
+ /// Clears the predicate set efficiently
2086
+ CUTLASS_HOST_DEVICE
2087
+ void enable_mask() {
2088
+ iterator_.enable_mask();
2089
+ }
2090
+
2091
+ /// Sets the predicate mask, overriding value stored in predicate iterator
2092
+ CUTLASS_HOST_DEVICE
2093
+ void set_mask(Mask const& mask) {
2094
+ iterator_.set_mask(mask);
2095
+ }
2096
+
2097
+ /// Gets the mask
2098
+ CUTLASS_HOST_DEVICE
2099
+ void get_mask(Mask& mask) {
2100
+ iterator_.get_mask(mask);
2101
+ }
2102
+
2103
+ /// Returns whether access is valid or not
2104
+ CUTLASS_HOST_DEVICE
2105
+ bool valid() {
2106
+ return iterator_.valid();
2107
+ }
2108
+ };
2109
+
2110
+ ////////////////////////////////////////////////////////////////////////////////
2111
+
2112
+ } // namespace threadblock
2113
+ } // namespace transform
2114
+ } // namespace cutlass
2115
+
2116
+ ////////////////////////////////////////////////////////////////////////////////
2117
+
2118
+ #else
2119
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
2120
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/predicated_tile_iterator_residual_last.h ADDED
@@ -0,0 +1,2125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /***************************************************************************************************
3
+ * Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights
4
+ *reserved. SPDX-License-Identifier: BSD-3-Clause
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ *this list of conditions and the following disclaimer.
11
+ *
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ * this list of conditions and the following disclaimer in the documentation
14
+ * and/or other materials provided with the distribution.
15
+ *
16
+ * 3. Neither the name of the copyright holder nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ *ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+ *LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ *INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ *CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ *ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ *POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ **************************************************************************************************/
33
+ /*! \file
34
+ \brief Templates implementing loading of tiles from pitch-linear rank=2
35
+ tensors.
36
+
37
+ This iterator uses masks to guard out-of-bounds accesses. The first tile
38
+ this iterator visits maybe partial, then the remaining tiles are complete.
39
+ So, we only need to compute the predicates twice, once before the first tile
40
+ and once for the remaining full tiles which can share the same predicates.
41
+
42
+ A precomputed "Params" object minimizes the amount of state that must be
43
+ stored in registers, and integer addition is used to advance the pointer
44
+ through memory.
45
+ */
46
+
47
+ #pragma once
48
+
49
+ #include <cutlass/arch/memory.h>
50
+ #include <cutlass/transform/threadblock/predicated_tile_access_iterator.h>
51
+
52
+ ////////////////////////////////////////////////////////////////////////////////
53
+
54
+ namespace cutlass {
55
+ namespace transform {
56
+ namespace threadblock {
57
+
58
+ ////////////////////////////////////////////////////////////////////////////////
59
+
60
+ /// PredicatedTileIteratorResidualLast
61
+ ///
62
+ /// Satisfies: ForwardTileIteratorConcept |
63
+ /// ReadableContiguousTileIteratorConcept |
64
+ /// WriteableContiguousTileIteratorConcept |
65
+ /// MaskedTileIteratorConcept
66
+ ///
67
+ /// Regular tile iterator using a precomputed control structure to minimize
68
+ /// register liveness and integer arithmetic.
69
+ ///
70
+ /// Layout is assumed to be invariant at the time the precomputed "Params"
71
+ /// object is constructed.
72
+ ///
73
+ /// Base pointer and tensor extents may be specified at the time the iterator is
74
+ /// constructed. Subsequently, they are assumed to be immutable.
75
+ ///
76
+ /// Adding a logical coordinate offset may be performed at the time the iterator
77
+ /// is constructed. Subsequent additions to logical coordinate offset may be
78
+ /// performed but are relatively expensive.
79
+ ///
80
+ /// Visitation order is intended to first visit a "residual" tile that may be
81
+ /// partially full in both the advance dimension and the steady-state dimension.
82
+ /// This is assumed to be the last tile in the iteration sequence. Advancing an
83
+ /// iterator that has just been constructed moves to the first tile that is full
84
+ /// in the advance dimension and recomputes predicates. Subsequent accesses may
85
+ /// be performed without updating internal predicates and are efficient in terms
86
+ /// of live register state and pointer arithmetic instructions.
87
+ ///
88
+ /// To be efficient, this assumes the iterator will be dereferenced and advanced
89
+ /// at least once outside any looping structure to minimize integer arithmetic.
90
+ ///
91
+ /// Access out of bounds are safe so long as `clear_mask()` is called prior to
92
+ /// dereferencing the iterator.
93
+ ///
94
+ ///
95
+ /// Example:
96
+ ///
97
+ /// An efficient pipeline structure may be constructed as follows:
98
+ ///
99
+ // template <typename Iterator>
100
+ // __global__ void kernel(
101
+ // typename Iterator::Params params,
102
+ // typename Iterator::Element *ptr,
103
+ // TensorCoord extent) {
104
+ //
105
+ // typename Iterator::Fragment fragment;
106
+ //
107
+ // TensorCoord threadblock_offset(0, 0);
108
+ //
109
+ // Iterator iter(params, ptr, extent, threadIdx.x, threadblock_offsets);
110
+ //
111
+ //
112
+ // fragment = *iter; // load "residue" tile first
113
+ // ++iter; // advance to first "steady state" tile and update
114
+ // internal masks
115
+ //
116
+ //
117
+ // #pragma unroll
118
+ // for (int i = Remaining - 1; i >= 0; --i) {
119
+ //
120
+ // f(fragment);
121
+ //
122
+ // if (!i) {
123
+ // iter.clear_mask(); // light-weight operation to clear masks -
124
+ // subsequent loads become NO-OPs.
125
+ // }
126
+ //
127
+ // fragment = *iter; // load tile during "steady state" phase
128
+ // ++iter; // advance to next tile - lightweight due to
129
+ // steady-state masks
130
+ // }
131
+ // }
132
+ //
133
+ // void host(TensorView<Element, 2, layout::PitchLinear> view) {
134
+ //
135
+ // using Iterator =
136
+ // transform::threadblock::PredicatedTileIteratorResidualLast;
137
+ //
138
+ // typename Iterator::Params params(view.layout());
139
+ //
140
+ // kernel<Iterator>(params, view.data());
141
+ // }
142
+ ///
143
+ ///
144
+ template <
145
+ typename Shape,
146
+ typename Element,
147
+ typename Layout,
148
+ int AdvanceRank,
149
+ typename ThreadMap,
150
+ int AccessSize = ThreadMap::kElementsPerAccess,
151
+ bool Gather = false>
152
+ class PredicatedTileIteratorResidualLast;
153
+
154
+ ////////////////////////////////////////////////////////////////////////////////
155
+
156
+ /// Specialization of PredicatedTileIteratorResidualLast for pitch-linear data.
157
+ ///
158
+ /// Satisfies: ForwardTileIteratorConcept |
159
+ /// ReadableContiguousTileIteratorConcept |
160
+ /// WriteableContiguousTileIteratorConcept |
161
+ /// MaskedTileIteratorConcept
162
+ ///
163
+ template <
164
+ typename Shape_,
165
+ typename Element_,
166
+ int AdvanceRank,
167
+ typename ThreadMap_,
168
+ int AccessSize,
169
+ bool Gather>
170
+ class PredicatedTileIteratorResidualLast<
171
+ Shape_,
172
+ Element_,
173
+ layout::PitchLinear,
174
+ AdvanceRank,
175
+ ThreadMap_,
176
+ AccessSize,
177
+ Gather> {
178
+ public:
179
+ static_assert(
180
+ AdvanceRank == 0 || AdvanceRank == 1,
181
+ "Specialization for pitch-linear iterator may advance along the "
182
+ "contiguous(rank=0) or strided(rank=1) dimension.");
183
+
184
+ using Shape = Shape_;
185
+ using Element = Element_;
186
+ using Layout = layout::PitchLinear;
187
+ static int const kAdvanceRank = AdvanceRank;
188
+ using ThreadMap = ThreadMap_;
189
+
190
+ using Index = typename Layout::Index;
191
+ using LongIndex = typename Layout::LongIndex;
192
+
193
+ using TensorRef = TensorRef<Element, Layout>;
194
+ using TensorView = TensorView<Element, Layout>;
195
+ using TensorCoord = typename Layout::TensorCoord;
196
+
197
+ using Pointer = Element*;
198
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
199
+
200
+ /// Type used for internal memory accesses
201
+ using AccessType = AlignedArray<
202
+ Element,
203
+ AccessSize,
204
+ (AccessSize * sizeof_bits<Element>::value / 8)>;
205
+
206
+ /// Underlying iterator to compute the addresses
207
+ using TileAccessIterator = PredicatedTileAccessIteratorResidualLast<
208
+ Shape,
209
+ Element,
210
+ Layout,
211
+ kAdvanceRank,
212
+ ThreadMap,
213
+ AccessType,
214
+ Gather>;
215
+
216
+ static int const kAccessesPerVector = TileAccessIterator::kAccessesPerVector;
217
+
218
+ /// Fragment object to be loaded or stored
219
+ using Fragment = cutlass::Array<
220
+ Element,
221
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
222
+
223
+ /// Predicate vector stores mask to guard accesses
224
+ using Mask = typename TileAccessIterator::Mask;
225
+
226
+ /// Parameters object is precomputed state and is host-constructible
227
+ class Params {
228
+ public:
229
+ using Base = typename TileAccessIterator::Params::Base;
230
+
231
+ friend PredicatedTileIteratorResidualLast;
232
+
233
+ private:
234
+ /// Parameters object
235
+ typename TileAccessIterator::Params params_;
236
+
237
+ public:
238
+ /// Construct the Params object given a pitch-linear tensor's layout
239
+ CUTLASS_HOST_DEVICE
240
+ Params(Layout const& layout) : params_(layout) {}
241
+
242
+ CUTLASS_HOST_DEVICE
243
+ Params() {}
244
+
245
+ CUTLASS_HOST_DEVICE
246
+ Params(Base const& base) : params_(base) {}
247
+ };
248
+
249
+ private:
250
+ /// Internal pointer type permits fast address arithmetic
251
+ using BytePointer = char*;
252
+
253
+ private:
254
+ //
255
+ // Data members
256
+ //
257
+
258
+ /// Data member to the tile access iterator
259
+ TileAccessIterator address_iterator_;
260
+
261
+ public:
262
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
263
+ /// and thread ID
264
+ CUTLASS_HOST_DEVICE
265
+ PredicatedTileIteratorResidualLast(
266
+ /// Precomputed parameters object
267
+ Params const& params,
268
+ /// Pointer to start of tensor
269
+ Pointer pointer,
270
+ /// Extent of tensor
271
+ TensorCoord extent,
272
+ /// ID of each participating thread
273
+ int thread_id,
274
+ /// Initial offset of threadblock
275
+ TensorCoord const& threadblock_offset,
276
+ /// Gather indices
277
+ int const* indices = nullptr)
278
+ : address_iterator_(
279
+ params.params_,
280
+ pointer,
281
+ extent,
282
+ thread_id,
283
+ threadblock_offset,
284
+ indices) {}
285
+
286
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
287
+ /// offset
288
+ CUTLASS_HOST_DEVICE
289
+ PredicatedTileIteratorResidualLast(
290
+ Params const& params, ///< Precomputed parameters object
291
+ Pointer pointer, ///< Pointer to start of tensor
292
+ TensorCoord extent, ///< Extent of tensor
293
+ int thread_id ///< ID of each participating thread
294
+ )
295
+ : PredicatedTileIteratorResidualLast(
296
+ params,
297
+ pointer,
298
+ extent,
299
+ thread_id,
300
+ make_Coord(0, 0)) {}
301
+
302
+ /// Adds a pointer offset in units of Element
303
+ CUTLASS_HOST_DEVICE
304
+ void add_pointer_offset(LongIndex pointer_offset) {
305
+ address_iterator_.add_pointer_offset(pointer_offset);
306
+ }
307
+
308
+ /// Advances to the next tile in memory.
309
+ ///
310
+ /// The first time this method is called, predicates are updated, and the
311
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
312
+ /// Subsequent calls are lightweight and must only update the internal
313
+ /// pointer.
314
+ CUTLASS_HOST_DEVICE
315
+ PredicatedTileIteratorResidualLast& operator++() {
316
+ if (kAdvanceRank)
317
+ address_iterator_.add_tile_offset({0, 1});
318
+ else
319
+ address_iterator_.add_tile_offset({1, 0});
320
+
321
+ return *this;
322
+ }
323
+
324
+ /// Advances to the next tile in memory.
325
+ ///
326
+ /// The first time this method is called, predicates are updated, and the
327
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
328
+ /// Subsequent calls are lightweight and must only update the internal
329
+ /// pointer.
330
+ CUTLASS_HOST_DEVICE
331
+ PredicatedTileIteratorResidualLast operator++(int) {
332
+ PredicatedTileIteratorResidualLast self(*this);
333
+ operator++();
334
+ return self;
335
+ }
336
+
337
+ /// Clears the predicate set efficiently
338
+ CUTLASS_HOST_DEVICE
339
+ void clear_mask(bool enable = true) {
340
+ address_iterator_.clear_mask(enable);
341
+ }
342
+
343
+ CUTLASS_HOST_DEVICE
344
+ void set_residual_tile(bool enable) {
345
+ address_iterator_.set_residual_tile(enable);
346
+ }
347
+
348
+ /// Clears the predicate set efficiently
349
+ CUTLASS_HOST_DEVICE
350
+ void enable_mask() {
351
+ address_iterator_.enable_mask();
352
+ }
353
+
354
+ /// Sets the predicate mask, overriding value stored in predicate iterator
355
+ CUTLASS_HOST_DEVICE
356
+ void set_mask(Mask const& mask) {
357
+ address_iterator_.set_mask(mask);
358
+ }
359
+
360
+ /// Gets the mask
361
+ CUTLASS_HOST_DEVICE
362
+ void get_mask(Mask& mask) {
363
+ address_iterator_.get_mask(mask);
364
+ }
365
+
366
+ CUTLASS_DEVICE
367
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
368
+ load_with_byte_offset(
369
+ frag, pointer_offset * sizeof_bits<Element>::value / 8);
370
+ }
371
+
372
+ CUTLASS_DEVICE
373
+ void load_with_byte_offset(Fragment& frag, LongIndex byte_offset) {
374
+ AccessType* frag_ptr = reinterpret_cast<AccessType*>(&frag);
375
+
376
+ CUTLASS_PRAGMA_UNROLL
377
+ for (int s = 0; s < ThreadMap::Iterations::kStrided; ++s) {
378
+ CUTLASS_PRAGMA_UNROLL
379
+ for (int c = 0; c < ThreadMap::Iterations::kContiguous; ++c) {
380
+ CUTLASS_PRAGMA_UNROLL
381
+ for (int v = 0; v < kAccessesPerVector; ++v) {
382
+ int idx = v +
383
+ kAccessesPerVector * (c + s * ThreadMap::Iterations::kContiguous);
384
+
385
+ address_iterator_.set_iteration_index(idx);
386
+ char const* byte_ptr =
387
+ reinterpret_cast<char const*>(address_iterator_.get()) +
388
+ byte_offset;
389
+
390
+ AccessType const* access_ptr =
391
+ reinterpret_cast<AccessType const*>(byte_ptr);
392
+
393
+ cutlass::arch::global_load<AccessType, sizeof(AccessType)>(
394
+ frag_ptr[idx], access_ptr, address_iterator_.valid());
395
+
396
+ ++address_iterator_;
397
+ }
398
+ }
399
+ }
400
+ }
401
+
402
+ /// Loads a fragment from memory
403
+ CUTLASS_DEVICE
404
+ void load(Fragment& frag) {
405
+ load_with_byte_offset(frag, 0);
406
+ }
407
+
408
+ /// Store a fragment to memory
409
+ CUTLASS_DEVICE
410
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
411
+ store_with_byte_offset(
412
+ frag, pointer_offset * sizeof_bits<Element>::value / 8);
413
+ }
414
+
415
+ /// Store a fragment to memory
416
+ CUTLASS_DEVICE
417
+ void store_with_byte_offset(Fragment const& frag, LongIndex byte_offset) {
418
+ address_iterator_.set_iteration_index(0);
419
+ AccessType const* frag_ptr = reinterpret_cast<AccessType const*>(&frag);
420
+
421
+ CUTLASS_PRAGMA_UNROLL
422
+ for (int s = 0; s < ThreadMap::Iterations::kStrided; ++s) {
423
+ CUTLASS_PRAGMA_UNROLL
424
+ for (int c = 0; c < ThreadMap::Iterations::kContiguous; ++c) {
425
+ CUTLASS_PRAGMA_UNROLL
426
+ for (int v = 0; v < kAccessesPerVector; ++v) {
427
+ int idx = v +
428
+ kAccessesPerVector * (c + s * ThreadMap::Iterations::kContiguous);
429
+
430
+ char* byte_ptr =
431
+ reinterpret_cast<char*>(address_iterator_.get()) + byte_offset;
432
+ AccessType* access_ptr = reinterpret_cast<AccessType*>(byte_ptr);
433
+
434
+ if (address_iterator_.valid()) {
435
+ *access_ptr = frag_ptr[idx];
436
+ }
437
+ ++address_iterator_;
438
+ }
439
+ }
440
+ }
441
+ }
442
+
443
+ /// Store a fragment to memory
444
+ CUTLASS_DEVICE
445
+ void store(Fragment const& frag) {
446
+ store_with_byte_offset(frag, 0);
447
+ }
448
+ };
449
+
450
+ ////////////////////////////////////////////////////////////////////////////////
451
+
452
+ /// Specialization of PredicatedTileIteratorResidualLast for pitch-linear data.
453
+ ///
454
+ /// Satisfies: ForwardTileIteratorConcept |
455
+ /// ReadableContiguousTileIteratorConcept |
456
+ /// WriteableContiguousTileIteratorConcept |
457
+ /// MaskedTileIteratorConcept
458
+ ///
459
+ template <
460
+ typename Shape_,
461
+ typename Element_,
462
+ int AdvanceRank,
463
+ typename ThreadMap_,
464
+ int AccessSize,
465
+ bool Gather>
466
+ class PredicatedTileIteratorResidualLast<
467
+ Shape_,
468
+ Element_,
469
+ layout::ColumnMajor,
470
+ AdvanceRank,
471
+ ThreadMap_,
472
+ AccessSize,
473
+ Gather> {
474
+ public:
475
+ static_assert(
476
+ AdvanceRank == 0 || AdvanceRank == 1,
477
+ "Specialization for pitch-linear iterator may along advance along the "
478
+ "contiguous(rank=0) or strided(rank=1) dimension.");
479
+
480
+ using Shape = Shape_;
481
+ using Element = Element_;
482
+ using Layout = layout::ColumnMajor;
483
+ static int const kAdvanceRank = AdvanceRank;
484
+ using ThreadMap = ThreadMap_;
485
+
486
+ using Index = typename Layout::Index;
487
+ using LongIndex = typename Layout::LongIndex;
488
+
489
+ using TensorRef = TensorRef<Element, Layout>;
490
+ using TensorView = TensorView<Element, Layout>;
491
+ using TensorCoord = typename Layout::TensorCoord;
492
+
493
+ using Pointer = Element*;
494
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
495
+
496
+ using UnderlyingIterator = PredicatedTileIteratorResidualLast<
497
+ layout::PitchLinearShape<Shape::kRow, Shape::kColumn>,
498
+ Element,
499
+ layout::PitchLinear,
500
+ (kAdvanceRank == 0 ? 0 : 1),
501
+ ThreadMap,
502
+ AccessSize,
503
+ Gather>;
504
+
505
+ using AccessType = typename UnderlyingIterator::AccessType;
506
+
507
+ /// Fragment object to be loaded or stored
508
+ using Fragment = cutlass::Array<
509
+ Element,
510
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
511
+
512
+ /// Predicate vector stores mask to guard accesses
513
+ using Mask = typename UnderlyingIterator::Mask;
514
+
515
+ /// Parameters object is precomputed state and is host-constructible
516
+ class Params {
517
+ private:
518
+ friend PredicatedTileIteratorResidualLast;
519
+
520
+ /// Parameters object
521
+ typename UnderlyingIterator::Params params_;
522
+
523
+ public:
524
+ CUTLASS_HOST_DEVICE
525
+ Params() {}
526
+
527
+ /// Construct the Params object given a pitch-linear tensor's layout
528
+ CUTLASS_HOST_DEVICE
529
+ Params(Layout const& layout)
530
+ : params_(layout::PitchLinear(layout.stride(0))) {}
531
+
532
+ CUTLASS_HOST_DEVICE
533
+ Params(typename UnderlyingIterator::Params::Base const& base)
534
+ : params_(base) {}
535
+ };
536
+
537
+ private:
538
+ //
539
+ // Data members
540
+ //
541
+
542
+ /// Underlying pitch-linear tile iterator
543
+ UnderlyingIterator iterator_;
544
+
545
+ public:
546
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
547
+ /// and thread ID
548
+ CUTLASS_HOST_DEVICE
549
+ PredicatedTileIteratorResidualLast(
550
+ Params const& params, ///< Precomputed parameters object
551
+ Pointer pointer, ///< Pointer to start of tensor
552
+ TensorCoord extent, ///< Extent of tensor
553
+ int thread_id, ///< ID of each participating thread
554
+ TensorCoord const& threadblock_offset, ///< Initial offset of threadblock
555
+ int const* indices =
556
+ nullptr ///< gather/scatter indices, note no support for
557
+ ///< gather/scatter at this specialization
558
+ )
559
+ : iterator_(
560
+ params.params_,
561
+ pointer,
562
+ layout::PitchLinearCoord(extent.row(), extent.column()),
563
+ thread_id,
564
+ layout::PitchLinearCoord(
565
+ threadblock_offset.row(),
566
+ threadblock_offset.column()),
567
+ indices) {}
568
+
569
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
570
+ /// offset
571
+ CUTLASS_HOST_DEVICE
572
+ PredicatedTileIteratorResidualLast(
573
+ Params const& params, ///< Precomputed parameters object
574
+ Pointer pointer, ///< Pointer to start of tensor
575
+ TensorCoord extent, ///< Extent of tensor
576
+ int thread_id ///< ID of each participating thread
577
+ )
578
+ : PredicatedTileIteratorResidualLast(
579
+ params,
580
+ pointer,
581
+ extent,
582
+ thread_id,
583
+ make_Coord(0, 0)) {}
584
+
585
+ /// Adds a pointer offset in units of Element
586
+ CUTLASS_HOST_DEVICE
587
+ void add_pointer_offset(LongIndex pointer_offset) {
588
+ iterator_.add_pointer_offset(pointer_offset);
589
+ }
590
+
591
+ /// Advances to the next tile in memory.
592
+ ///
593
+ /// The first time this method is called, predicates are updated, and the
594
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
595
+ /// Subsequent calls are lightweight and must only update the internal
596
+ /// pointer.
597
+ CUTLASS_HOST_DEVICE
598
+ PredicatedTileIteratorResidualLast& operator++() {
599
+ ++iterator_;
600
+ return *this;
601
+ }
602
+
603
+ /// Advances to the next tile in memory.
604
+ ///
605
+ /// The first time this method is called, predicates are updated, and the
606
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
607
+ /// Subsequent calls are lightweight and must only update the internal
608
+ /// pointer.
609
+ CUTLASS_HOST_DEVICE
610
+ PredicatedTileIteratorResidualLast operator++(int) {
611
+ PredicatedTileIteratorResidualLast self(*this);
612
+ operator++();
613
+ return self;
614
+ }
615
+
616
+ /// Clears the predicate set efficiently
617
+ CUTLASS_HOST_DEVICE
618
+ void clear_mask(bool enable = true) {
619
+ iterator_.clear_mask(enable);
620
+ }
621
+
622
+ CUTLASS_HOST_DEVICE
623
+ void set_residual_tile(bool enable) {
624
+ iterator_.set_residual_tile(enable);
625
+ }
626
+
627
+ /// Clears the predicate set efficiently
628
+ CUTLASS_HOST_DEVICE
629
+ void enable_mask() {
630
+ iterator_.enable_mask();
631
+ }
632
+
633
+ /// Sets the predicate mask, overriding value stored in predicate iterator
634
+ CUTLASS_HOST_DEVICE
635
+ void set_mask(Mask const& mask) {
636
+ iterator_.set_mask(mask);
637
+ }
638
+
639
+ /// Gets the mask
640
+ CUTLASS_HOST_DEVICE
641
+ void get_mask(Mask& mask) {
642
+ iterator_.get_mask(mask);
643
+ }
644
+
645
+ /// Loads a fragment from memory
646
+ CUTLASS_DEVICE
647
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
648
+ iterator_.load_with_pointer_offset(frag, pointer_offset);
649
+ }
650
+
651
+ /// Loads a fragment from memory
652
+ CUTLASS_DEVICE
653
+ void load_with_byte_offset(Fragment& frag, LongIndex byte_offset) {
654
+ iterator_.load_with_byte_offset(frag, byte_offset);
655
+ }
656
+
657
+ /// Loads a fragment from memory
658
+ CUTLASS_DEVICE
659
+ void load(Fragment& frag) {
660
+ load_with_pointer_offset(frag, 0);
661
+ }
662
+
663
+ /// Store a fragment to memory
664
+ CUTLASS_DEVICE
665
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
666
+ iterator_.store_with_pointer_offset(frag, pointer_offset);
667
+ }
668
+
669
+ /// Store a fragment to memory
670
+ CUTLASS_DEVICE
671
+ void store_with_byte_offset(Fragment const& frag, LongIndex byte_offset) {
672
+ iterator_.store_with_byte_offset(frag, byte_offset);
673
+ }
674
+
675
+ /// Store a fragment to memory
676
+ CUTLASS_DEVICE
677
+ void store(Fragment const& frag) {
678
+ store_with_pointer_offset(frag, 0);
679
+ }
680
+ };
681
+
682
+ ////////////////////////////////////////////////////////////////////////////////
683
+
684
+ /// Specialization of PredicatedTileIteratorResidualLast for pitch-linear data.
685
+ ///
686
+ /// Satisfies: ForwardTileIteratorConcept |
687
+ /// ReadableContiguousTileIteratorConcept |
688
+ /// WriteableContiguousTileIteratorConcept |
689
+ /// MaskedTileIteratorConcept
690
+ ///
691
+ template <
692
+ typename Shape_,
693
+ typename Element_,
694
+ int AdvanceRank,
695
+ typename ThreadMap_,
696
+ int AccessSize,
697
+ bool Gather>
698
+ class PredicatedTileIteratorResidualLast<
699
+ Shape_,
700
+ Element_,
701
+ layout::RowMajor,
702
+ AdvanceRank,
703
+ ThreadMap_,
704
+ AccessSize,
705
+ Gather> {
706
+ public:
707
+ static_assert(
708
+ AdvanceRank == 0 || AdvanceRank == 1,
709
+ "Specialization for pitch-linear iterator may along advance along the "
710
+ "contiguous(rank=0) or strided(rank=1) dimension.");
711
+
712
+ using Shape = Shape_;
713
+ using Element = Element_;
714
+ using Layout = layout::RowMajor;
715
+ static int const kAdvanceRank = AdvanceRank;
716
+ using ThreadMap = ThreadMap_;
717
+
718
+ using Index = typename Layout::Index;
719
+ using LongIndex = typename Layout::LongIndex;
720
+
721
+ using TensorRef = TensorRef<Element, Layout>;
722
+ using TensorView = TensorView<Element, Layout>;
723
+ using TensorCoord = typename Layout::TensorCoord;
724
+
725
+ using Pointer = Element*;
726
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
727
+
728
+ using UnderlyingIterator = PredicatedTileIteratorResidualLast<
729
+ layout::PitchLinearShape<Shape::kColumn, Shape::kRow>,
730
+ Element,
731
+ layout::PitchLinear,
732
+ (kAdvanceRank == 0 ? 1 : 0),
733
+ ThreadMap,
734
+ AccessSize,
735
+ Gather>;
736
+
737
+ using AccessType = typename UnderlyingIterator::AccessType;
738
+
739
+ /// Fragment object to be loaded or stored
740
+ using Fragment = cutlass::Array<
741
+ Element,
742
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
743
+
744
+ /// Predicate vector stores mask to guard accesses
745
+ using Mask = typename UnderlyingIterator::Mask;
746
+
747
+ /// Parameters object is precomputed state and is host-constructible
748
+ class Params {
749
+ private:
750
+ friend PredicatedTileIteratorResidualLast;
751
+
752
+ /// Parameters object
753
+ typename UnderlyingIterator::Params params_;
754
+
755
+ public:
756
+ CUTLASS_HOST_DEVICE
757
+ Params() {}
758
+
759
+ /// Construct the Params object given a pitch-linear tensor's layout
760
+ CUTLASS_HOST_DEVICE
761
+ Params(Layout const& layout)
762
+ : params_(layout::PitchLinear(layout.stride(0))) {}
763
+
764
+ CUTLASS_HOST_DEVICE
765
+ Params(typename UnderlyingIterator::Params::Base const& base)
766
+ : params_(base) {}
767
+ };
768
+
769
+ private:
770
+ //
771
+ // Data members
772
+ //
773
+
774
+ /// Underlying pitch-linear tile iterator
775
+ UnderlyingIterator iterator_;
776
+
777
+ public:
778
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
779
+ /// and thread ID
780
+ CUTLASS_HOST_DEVICE
781
+ PredicatedTileIteratorResidualLast(
782
+ Params const& params, ///< Precomputed parameters object
783
+ Pointer pointer, ///< Pointer to start of tensor
784
+ TensorCoord extent, ///< Extent of tensor
785
+ int thread_id, ///< ID of each participating thread
786
+ TensorCoord const& threadblock_offset, ///< Initial offset of threadblock
787
+ int const* indices = nullptr ///< Gather indices
788
+ )
789
+ : iterator_(
790
+ params.params_,
791
+ pointer,
792
+ layout::PitchLinearCoord(extent.column(), extent.row()),
793
+ thread_id,
794
+ layout::PitchLinearCoord(
795
+ threadblock_offset.column(),
796
+ threadblock_offset.row()),
797
+ indices) {}
798
+
799
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
800
+ /// offset
801
+ CUTLASS_HOST_DEVICE
802
+ PredicatedTileIteratorResidualLast(
803
+ Params const& params, ///< Precomputed parameters object
804
+ Pointer pointer, ///< Pointer to start of tensor
805
+ TensorCoord extent, ///< Extent of tensor
806
+ int thread_id ///< ID of each participating thread
807
+ )
808
+ : PredicatedTileIteratorResidualLast(
809
+ params,
810
+ pointer,
811
+ extent,
812
+ thread_id,
813
+ make_Coord(0, 0)) {}
814
+
815
+ /// Adds a pointer offset in units of Element
816
+ CUTLASS_HOST_DEVICE
817
+ void add_pointer_offset(LongIndex pointer_offset) {
818
+ iterator_.add_pointer_offset(pointer_offset);
819
+ }
820
+
821
+ /// Advances to the next tile in memory.
822
+ ///
823
+ /// The first time this method is called, predicates are updated, and the
824
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
825
+ /// Subsequent calls are lightweight and must only update the internal
826
+ /// pointer.
827
+ CUTLASS_HOST_DEVICE
828
+ PredicatedTileIteratorResidualLast& operator++() {
829
+ ++iterator_;
830
+ return *this;
831
+ }
832
+
833
+ /// Advances to the next tile in memory.
834
+ ///
835
+ /// The first time this method is called, predicates are updated, and the
836
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
837
+ /// Subsequent calls are lightweight and must only update the internal
838
+ /// pointer.
839
+ CUTLASS_HOST_DEVICE
840
+ PredicatedTileIteratorResidualLast operator++(int) {
841
+ PredicatedTileIteratorResidualLast self(*this);
842
+ operator++();
843
+ return self;
844
+ }
845
+
846
+ /// Clears the predicate set efficiently
847
+ CUTLASS_HOST_DEVICE
848
+ void clear_mask(bool enable = true) {
849
+ iterator_.clear_mask(enable);
850
+ }
851
+
852
+ CUTLASS_HOST_DEVICE
853
+ void set_residual_tile(bool enable) {
854
+ iterator_.set_residual_tile(enable);
855
+ }
856
+
857
+ /// Clears the predicate set efficiently
858
+ CUTLASS_HOST_DEVICE
859
+ void enable_mask() {
860
+ iterator_.enable_mask();
861
+ }
862
+
863
+ /// Sets the predicate mask, overriding value stored in predicate iterator
864
+ CUTLASS_HOST_DEVICE
865
+ void set_mask(Mask const& mask) {
866
+ iterator_.set_mask(mask);
867
+ }
868
+
869
+ /// Gets the mask
870
+ CUTLASS_HOST_DEVICE
871
+ void get_mask(Mask& mask) {
872
+ iterator_.get_mask(mask);
873
+ }
874
+
875
+ /// Loads a fragment from memory
876
+ CUTLASS_DEVICE
877
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
878
+ iterator_.load_with_pointer_offset(frag, pointer_offset);
879
+ }
880
+
881
+ /// Loads a fragment from memory
882
+ CUTLASS_DEVICE
883
+ void load_with_byte_offset(Fragment& frag, LongIndex byte_offset) {
884
+ iterator_.load_with_byte_offset(frag, byte_offset);
885
+ }
886
+
887
+ /// Loads a fragment from memory
888
+ CUTLASS_DEVICE
889
+ void load(Fragment& frag) {
890
+ load_with_pointer_offset(frag, 0);
891
+ }
892
+
893
+ /// Store a fragment to memory
894
+ CUTLASS_DEVICE
895
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
896
+ iterator_.store_with_pointer_offset(frag, pointer_offset);
897
+ }
898
+
899
+ /// Store a fragment to memory
900
+ CUTLASS_DEVICE
901
+ void store_with_byte_offset(Fragment const& frag, LongIndex byte_offset) {
902
+ iterator_.store_with_byte_offset(frag, byte_offset);
903
+ }
904
+
905
+ /// Store a fragment to memory
906
+ CUTLASS_DEVICE
907
+ void store(Fragment const& frag) {
908
+ store_with_pointer_offset(frag, 0);
909
+ }
910
+ };
911
+
912
+ ////////////////////////////////////////////////////////////////////////////////
913
+
914
+ /// Specialization of PredicatedTileIteratorResidualLast for affine rank-2 data.
915
+ ///
916
+ /// Satisfies: ForwardTileIteratorConcept |
917
+ /// ReadableContiguousTileIteratorConcept |
918
+ /// WriteableContiguousTileIteratorConcept |
919
+ /// MaskedTileIteratorConcept
920
+ ///
921
+ template <
922
+ typename Shape_,
923
+ typename Element_,
924
+ int AdvanceRank,
925
+ typename ThreadMap_,
926
+ int AccessSize>
927
+ class PredicatedTileIteratorResidualLast<
928
+ Shape_,
929
+ Element_,
930
+ layout::AffineRankN<2>,
931
+ AdvanceRank,
932
+ ThreadMap_,
933
+ AccessSize,
934
+ false> {
935
+ public:
936
+ static_assert(
937
+ AdvanceRank == 0 || AdvanceRank == 1,
938
+ "Specialization for pitch-linear iterator may advance along the "
939
+ "contiguous(rank=0) or strided(rank=1) dimension.");
940
+
941
+ using Shape = Shape_;
942
+ using Element = Element_;
943
+ using Layout = layout::AffineRankN<2>;
944
+ static int const kAdvanceRank = AdvanceRank;
945
+ using ThreadMap = ThreadMap_;
946
+
947
+ using Index = typename Layout::Index;
948
+ using LongIndex = typename Layout::LongIndex;
949
+
950
+ using TensorRef = TensorRef<Element, Layout>;
951
+ using TensorView = TensorView<Element, Layout>;
952
+ using TensorCoord = typename Layout::TensorCoord;
953
+
954
+ using Pointer = Element*;
955
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
956
+
957
+ /// Type used for internal memory accesses
958
+ using AccessType = AlignedArray<
959
+ Element,
960
+ AccessSize,
961
+ (AccessSize * sizeof_bits<Element>::value / 8)>;
962
+
963
+ /// Underlying iterator to compute the addresses
964
+ using TileAccessIterator = PredicatedTileAccessIteratorResidualLast<
965
+ Shape,
966
+ Element,
967
+ Layout,
968
+ kAdvanceRank,
969
+ ThreadMap,
970
+ AccessType>;
971
+
972
+ static int const kAccessesPerVector = TileAccessIterator::kAccessesPerVector;
973
+
974
+ /// Fragment object to be loaded or stored
975
+ using Fragment = cutlass::Array<
976
+ Element,
977
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
978
+
979
+ /// Predicate vector stores mask to guard accesses
980
+ using Mask = typename TileAccessIterator::Mask;
981
+
982
+ /// Parameters object is precomputed state and is host-constructible
983
+ class Params {
984
+ public:
985
+ friend PredicatedTileIteratorResidualLast;
986
+
987
+ private:
988
+ /// Parameters object
989
+ typename TileAccessIterator::Params params_;
990
+
991
+ public:
992
+ /// Construct the Params object given a pitch-linear tensor's layout
993
+ CUTLASS_HOST_DEVICE
994
+ Params(Layout const& layout) : params_(layout) {}
995
+
996
+ CUTLASS_HOST_DEVICE
997
+ Params() {}
998
+ };
999
+
1000
+ private:
1001
+ /// Internal pointer type permits fast address arithmetic
1002
+ using BytePointer = char*;
1003
+
1004
+ private:
1005
+ //
1006
+ // Data members
1007
+ //
1008
+
1009
+ /// Data member to the tile access iterator
1010
+ TileAccessIterator address_iterator_;
1011
+
1012
+ public:
1013
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1014
+ /// and thread ID
1015
+ CUTLASS_HOST_DEVICE
1016
+ PredicatedTileIteratorResidualLast(
1017
+ /// Precomputed parameters object
1018
+ Params const& params,
1019
+ /// Pointer to start of tensor
1020
+ Pointer pointer,
1021
+ /// Extent of tensor
1022
+ TensorCoord extent,
1023
+ /// ID of each participating thread
1024
+ int thread_id,
1025
+ /// Initial offset of threadblock
1026
+ TensorCoord const& threadblock_offset,
1027
+ int const* indices =
1028
+ nullptr ///< gather/scatter indices, note no support for
1029
+ ///< gather/scatter at this specialization
1030
+ )
1031
+ : address_iterator_(
1032
+ params.params_,
1033
+ pointer,
1034
+ extent,
1035
+ thread_id,
1036
+ threadblock_offset) {}
1037
+
1038
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
1039
+ /// offset
1040
+ CUTLASS_HOST_DEVICE
1041
+ PredicatedTileIteratorResidualLast(
1042
+ Params const& params, ///< Precomputed parameters object
1043
+ Pointer pointer, ///< Pointer to start of tensor
1044
+ TensorCoord extent, ///< Extent of tensor
1045
+ int thread_id ///< ID of each participating thread
1046
+ )
1047
+ : PredicatedTileIteratorResidualLast(
1048
+ params,
1049
+ pointer,
1050
+ extent,
1051
+ thread_id,
1052
+ make_Coord(0, 0)) {}
1053
+
1054
+ /// Adds a pointer offset in units of Element
1055
+ CUTLASS_HOST_DEVICE
1056
+ void add_pointer_offset(LongIndex pointer_offset) {
1057
+ address_iterator_.add_pointer_offset(pointer_offset);
1058
+ }
1059
+
1060
+ /// Advances to the next tile in memory.
1061
+ ///
1062
+ /// The first time this method is called, predicates are updated, and the
1063
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1064
+ /// Subsequent calls are lightweight and must only update the internal
1065
+ /// pointer.
1066
+ CUTLASS_HOST_DEVICE
1067
+ PredicatedTileIteratorResidualLast& operator++() {
1068
+ if (kAdvanceRank)
1069
+ address_iterator_.add_tile_offset(make_Coord(0, 1));
1070
+ else
1071
+ address_iterator_.add_tile_offset(make_Coord(1, 0));
1072
+
1073
+ return *this;
1074
+ }
1075
+
1076
+ /// Advances to the next tile in memory.
1077
+ ///
1078
+ /// The first time this method is called, predicates are updated, and the
1079
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1080
+ /// Subsequent calls are lightweight and must only update the internal
1081
+ /// pointer.
1082
+ CUTLASS_HOST_DEVICE
1083
+ PredicatedTileIteratorResidualLast operator++(int) {
1084
+ PredicatedTileIteratorResidualLast self(*this);
1085
+ operator++();
1086
+ return self;
1087
+ }
1088
+
1089
+ /// Clears the predicate set efficiently
1090
+ CUTLASS_HOST_DEVICE
1091
+ void clear_mask(bool enable = true) {
1092
+ address_iterator_.clear_mask(enable);
1093
+ }
1094
+
1095
+ CUTLASS_HOST_DEVICE
1096
+ void set_residual_tile(bool enable) {
1097
+ address_iterator_.set_residual_tile(enable);
1098
+ }
1099
+
1100
+ /// Clears the predicate set efficiently
1101
+ CUTLASS_HOST_DEVICE
1102
+ void enable_mask() {
1103
+ address_iterator_.enable_mask();
1104
+ }
1105
+
1106
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1107
+ CUTLASS_HOST_DEVICE
1108
+ void set_mask(Mask const& mask) {
1109
+ address_iterator_.set_mask(mask);
1110
+ }
1111
+
1112
+ /// Gets the mask
1113
+ CUTLASS_HOST_DEVICE
1114
+ void get_mask(Mask& mask) {
1115
+ address_iterator_.get_mask(mask);
1116
+ }
1117
+
1118
+ CUTLASS_DEVICE
1119
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
1120
+ load_with_byte_offset(
1121
+ frag, pointer_offset * sizeof_bits<Element>::value / 8);
1122
+ }
1123
+
1124
+ CUTLASS_DEVICE
1125
+ void load_with_byte_offset(Fragment& frag, LongIndex byte_offset) {
1126
+ AccessType* frag_ptr = reinterpret_cast<AccessType*>(&frag);
1127
+
1128
+ CUTLASS_PRAGMA_UNROLL
1129
+ for (int s = 0; s < ThreadMap::Iterations::kStrided; ++s) {
1130
+ CUTLASS_PRAGMA_UNROLL
1131
+ for (int c = 0; c < ThreadMap::Iterations::kContiguous; ++c) {
1132
+ CUTLASS_PRAGMA_UNROLL
1133
+ for (int v = 0; v < kAccessesPerVector; ++v) {
1134
+ int idx = v +
1135
+ kAccessesPerVector * (c + s * ThreadMap::Iterations::kContiguous);
1136
+
1137
+ address_iterator_.set_iteration_index(idx);
1138
+ char const* byte_ptr =
1139
+ reinterpret_cast<char const*>(address_iterator_.get()) +
1140
+ byte_offset;
1141
+
1142
+ AccessType const* access_ptr =
1143
+ reinterpret_cast<AccessType const*>(byte_ptr);
1144
+
1145
+ cutlass::arch::global_load<AccessType, sizeof(AccessType)>(
1146
+ frag_ptr[idx], access_ptr, address_iterator_.valid());
1147
+
1148
+ ++address_iterator_;
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+
1154
+ /// Loads a fragment from memory
1155
+ CUTLASS_DEVICE
1156
+ void load(Fragment& frag) {
1157
+ load_with_byte_offset(frag, 0);
1158
+ }
1159
+
1160
+ /// Store a fragment to memory
1161
+ CUTLASS_DEVICE
1162
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
1163
+ store_with_byte_offset(
1164
+ frag, pointer_offset * sizeof_bits<Element>::value / 8);
1165
+ }
1166
+
1167
+ /// Store a fragment to memory
1168
+ CUTLASS_DEVICE
1169
+ void store_with_byte_offset(Fragment const& frag, LongIndex byte_offset) {
1170
+ address_iterator_.set_iteration_index(0);
1171
+ AccessType const* frag_ptr = reinterpret_cast<AccessType const*>(&frag);
1172
+
1173
+ CUTLASS_PRAGMA_UNROLL
1174
+ for (int s = 0; s < ThreadMap::Iterations::kStrided; ++s) {
1175
+ CUTLASS_PRAGMA_UNROLL
1176
+ for (int c = 0; c < ThreadMap::Iterations::kContiguous; ++c) {
1177
+ CUTLASS_PRAGMA_UNROLL
1178
+ for (int v = 0; v < kAccessesPerVector; ++v) {
1179
+ int idx = v +
1180
+ kAccessesPerVector * (c + s * ThreadMap::Iterations::kContiguous);
1181
+
1182
+ char* byte_ptr =
1183
+ reinterpret_cast<char*>(address_iterator_.get()) + byte_offset;
1184
+ AccessType* access_ptr = reinterpret_cast<AccessType*>(byte_ptr);
1185
+
1186
+ if (address_iterator_.valid()) {
1187
+ *access_ptr = frag_ptr[idx];
1188
+ }
1189
+ ++address_iterator_;
1190
+ }
1191
+ }
1192
+ }
1193
+ }
1194
+
1195
+ /// Store a fragment to memory
1196
+ CUTLASS_DEVICE
1197
+ void store(Fragment const& frag) {
1198
+ store_with_byte_offset(frag, 0);
1199
+ }
1200
+ };
1201
+
1202
+ ////////////////////////////////////////////////////////////////////////////////
1203
+
1204
+ /// Specialization of PredicatedTileIteratorResidualLast for affine rank 2
1205
+ /// column-major data.
1206
+ ///
1207
+ /// Satisfies: ForwardTileIteratorConcept |
1208
+ /// ReadableContiguousTileIteratorConcept |
1209
+ /// WriteableContiguousTileIteratorConcept |
1210
+ /// MaskedTileIteratorConcept
1211
+ ///
1212
+ template <
1213
+ typename Shape_,
1214
+ typename Element_,
1215
+ int AdvanceRank,
1216
+ typename ThreadMap_,
1217
+ int AccessSize>
1218
+ class PredicatedTileIteratorResidualLast<
1219
+ Shape_,
1220
+ Element_,
1221
+ layout::AffineRank2ColumnMajor,
1222
+ AdvanceRank,
1223
+ ThreadMap_,
1224
+ AccessSize,
1225
+ false> {
1226
+ public:
1227
+ static_assert(
1228
+ AdvanceRank == 0 || AdvanceRank == 1,
1229
+ "Specialization for pitch-linear iterator may along advance along the "
1230
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1231
+
1232
+ using Shape = Shape_;
1233
+ using Element = Element_;
1234
+ using Layout = layout::AffineRank2ColumnMajor;
1235
+ static int const kAdvanceRank = AdvanceRank;
1236
+ using ThreadMap = ThreadMap_;
1237
+
1238
+ using Index = typename Layout::Index;
1239
+ using LongIndex = typename Layout::LongIndex;
1240
+
1241
+ using TensorRef = TensorRef<Element, Layout>;
1242
+ using TensorView = TensorView<Element, Layout>;
1243
+ using TensorCoord = typename Layout::TensorCoord;
1244
+
1245
+ using Pointer = Element*;
1246
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1247
+
1248
+ // Map to the underlying AffineRankN<2> layout
1249
+ using UnderlyingIterator = PredicatedTileIteratorResidualLast<
1250
+ layout::PitchLinearShape<Shape::kRow, Shape::kColumn>,
1251
+ Element,
1252
+ layout::AffineRankN<2>,
1253
+ (kAdvanceRank == 0 ? 0 : 1),
1254
+ ThreadMap,
1255
+ AccessSize>;
1256
+
1257
+ using AccessType = typename UnderlyingIterator::AccessType;
1258
+
1259
+ /// Fragment object to be loaded or stored
1260
+ using Fragment = cutlass::Array<
1261
+ Element,
1262
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
1263
+
1264
+ /// Predicate vector stores mask to guard accesses
1265
+ using Mask = typename UnderlyingIterator::Mask;
1266
+
1267
+ /// Parameters object is precomputed state and is host-constructible
1268
+ class Params {
1269
+ private:
1270
+ friend PredicatedTileIteratorResidualLast;
1271
+
1272
+ /// Parameters object
1273
+ typename UnderlyingIterator::Params params_;
1274
+
1275
+ public:
1276
+ CUTLASS_HOST_DEVICE
1277
+ Params() {}
1278
+
1279
+ /// Construct the Params object given an AffineRankN<2> tensor's layout
1280
+ CUTLASS_HOST_DEVICE
1281
+ Params(Layout const& layout)
1282
+ : params_(layout::AffineRankN<2>(layout.stride(0), layout.stride(1))) {}
1283
+ };
1284
+
1285
+ private:
1286
+ //
1287
+ // Data members
1288
+ //
1289
+
1290
+ /// Underlying AffineRankN<2> tile iterator
1291
+ UnderlyingIterator iterator_;
1292
+
1293
+ public:
1294
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1295
+ /// and thread ID
1296
+ CUTLASS_HOST_DEVICE
1297
+ PredicatedTileIteratorResidualLast(
1298
+ Params const& params, ///< Precomputed parameters object
1299
+ Pointer pointer, ///< Pointer to start of tensor
1300
+ TensorCoord extent, ///< Extent of tensor
1301
+ int thread_id, ///< ID of each participating thread
1302
+ TensorCoord const& threadblock_offset, ///< Initial offset of threadblock
1303
+ int const* indices =
1304
+ nullptr ///< gather/scatter indices, note no support for
1305
+ ///< gather/scatter at this specialization
1306
+ )
1307
+ : iterator_(
1308
+ params.params_,
1309
+ pointer,
1310
+ layout::PitchLinearCoord(extent.row(), extent.column()),
1311
+ thread_id,
1312
+ layout::PitchLinearCoord(
1313
+ threadblock_offset.row(),
1314
+ threadblock_offset.column())) {}
1315
+
1316
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
1317
+ /// offset
1318
+ CUTLASS_HOST_DEVICE
1319
+ PredicatedTileIteratorResidualLast(
1320
+ Params const& params, ///< Precomputed parameters object
1321
+ Pointer pointer, ///< Pointer to start of tensor
1322
+ TensorCoord extent, ///< Extent of tensor
1323
+ int thread_id ///< ID of each participating thread
1324
+ )
1325
+ : PredicatedTileIteratorResidualLast(
1326
+ params,
1327
+ pointer,
1328
+ extent,
1329
+ thread_id,
1330
+ make_Coord(0, 0)) {}
1331
+
1332
+ /// Adds a pointer offset in units of Element
1333
+ CUTLASS_HOST_DEVICE
1334
+ void add_pointer_offset(LongIndex pointer_offset) {
1335
+ iterator_.add_pointer_offset(pointer_offset);
1336
+ }
1337
+
1338
+ /// Advances to the next tile in memory.
1339
+ ///
1340
+ /// The first time this method is called, predicates are updated, and the
1341
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1342
+ /// Subsequent calls are lightweight and must only update the internal
1343
+ /// pointer.
1344
+ CUTLASS_HOST_DEVICE
1345
+ PredicatedTileIteratorResidualLast& operator++() {
1346
+ ++iterator_;
1347
+ return *this;
1348
+ }
1349
+
1350
+ /// Advances to the next tile in memory.
1351
+ ///
1352
+ /// The first time this method is called, predicates are updated, and the
1353
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1354
+ /// Subsequent calls are lightweight and must only update the internal
1355
+ /// pointer.
1356
+ CUTLASS_HOST_DEVICE
1357
+ PredicatedTileIteratorResidualLast operator++(int) {
1358
+ PredicatedTileIteratorResidualLast self(*this);
1359
+ operator++();
1360
+ return self;
1361
+ }
1362
+
1363
+ /// Clears the predicate set efficiently
1364
+ CUTLASS_HOST_DEVICE
1365
+ void clear_mask(bool enable = true) {
1366
+ iterator_.clear_mask(enable);
1367
+ }
1368
+
1369
+ CUTLASS_HOST_DEVICE
1370
+ void set_residual_tile(bool enable) {
1371
+ iterator_.set_residual_tile(enable);
1372
+ }
1373
+
1374
+ /// Clears the predicate set efficiently
1375
+ CUTLASS_HOST_DEVICE
1376
+ void enable_mask() {
1377
+ iterator_.enable_mask();
1378
+ }
1379
+
1380
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1381
+ CUTLASS_HOST_DEVICE
1382
+ void set_mask(Mask const& mask) {
1383
+ iterator_.set_mask(mask);
1384
+ }
1385
+
1386
+ /// Gets the mask
1387
+ CUTLASS_HOST_DEVICE
1388
+ void get_mask(Mask& mask) {
1389
+ iterator_.get_mask(mask);
1390
+ }
1391
+
1392
+ /// Loads a fragment from memory
1393
+ CUTLASS_DEVICE
1394
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
1395
+ iterator_.load_with_pointer_offset(frag, pointer_offset);
1396
+ }
1397
+
1398
+ /// Loads a fragment from memory
1399
+ CUTLASS_DEVICE
1400
+ void load_with_byte_offset(Fragment& frag, LongIndex byte_offset) {
1401
+ iterator_.load_with_byte_offset(frag, byte_offset);
1402
+ }
1403
+
1404
+ /// Loads a fragment from memory
1405
+ CUTLASS_DEVICE
1406
+ void load(Fragment& frag) {
1407
+ load_with_pointer_offset(frag, 0);
1408
+ }
1409
+
1410
+ /// Store a fragment to memory
1411
+ CUTLASS_DEVICE
1412
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
1413
+ iterator_.store_with_pointer_offset(frag, pointer_offset);
1414
+ }
1415
+
1416
+ /// Store a fragment to memory
1417
+ CUTLASS_DEVICE
1418
+ void store_with_byte_offset(Fragment const& frag, LongIndex byte_offset) {
1419
+ iterator_.store_with_byte_offset(frag, byte_offset);
1420
+ }
1421
+
1422
+ /// Store a fragment to memory
1423
+ CUTLASS_DEVICE
1424
+ void store(Fragment const& frag) {
1425
+ store_with_pointer_offset(frag, 0);
1426
+ }
1427
+ };
1428
+
1429
+ ////////////////////////////////////////////////////////////////////////////////
1430
+
1431
+ /// Specialization of PredicatedTileIteratorResidualLast for affine rank 2
1432
+ /// row-major data.
1433
+ ///
1434
+ /// Satisfies: ForwardTileIteratorConcept |
1435
+ /// ReadableContiguousTileIteratorConcept |
1436
+ /// WriteableContiguousTileIteratorConcept |
1437
+ /// MaskedTileIteratorConcept
1438
+ ///
1439
+ template <
1440
+ typename Shape_,
1441
+ typename Element_,
1442
+ int AdvanceRank,
1443
+ typename ThreadMap_,
1444
+ int AccessSize>
1445
+ class PredicatedTileIteratorResidualLast<
1446
+ Shape_,
1447
+ Element_,
1448
+ layout::AffineRank2RowMajor,
1449
+ AdvanceRank,
1450
+ ThreadMap_,
1451
+ AccessSize,
1452
+ false> {
1453
+ public:
1454
+ static_assert(
1455
+ AdvanceRank == 0 || AdvanceRank == 1,
1456
+ "Specialization for pitch-linear iterator may along advance along the "
1457
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1458
+
1459
+ using Shape = Shape_;
1460
+ using Element = Element_;
1461
+ using Layout = layout::AffineRank2RowMajor;
1462
+ static int const kAdvanceRank = AdvanceRank;
1463
+ using ThreadMap = ThreadMap_;
1464
+
1465
+ using Index = typename Layout::Index;
1466
+ using LongIndex = typename Layout::LongIndex;
1467
+
1468
+ using TensorRef = TensorRef<Element, Layout>;
1469
+ using TensorView = TensorView<Element, Layout>;
1470
+ using TensorCoord = typename Layout::TensorCoord;
1471
+
1472
+ using Pointer = Element*;
1473
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1474
+
1475
+ // Map to the underlying AffineRankN<2> layout
1476
+ using UnderlyingIterator = PredicatedTileIteratorResidualLast<
1477
+ layout::PitchLinearShape<Shape::kColumn, Shape::kRow>,
1478
+ Element,
1479
+ layout::AffineRankN<2>,
1480
+ (kAdvanceRank == 0 ? 1 : 0),
1481
+ ThreadMap,
1482
+ AccessSize>;
1483
+
1484
+ using AccessType = typename UnderlyingIterator::AccessType;
1485
+
1486
+ /// Fragment object to be loaded or stored
1487
+ using Fragment = cutlass::Array<
1488
+ Element,
1489
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
1490
+
1491
+ /// Predicate vector stores mask to guard accesses
1492
+ using Mask = typename UnderlyingIterator::Mask;
1493
+
1494
+ /// Parameters object is precomputed state and is host-constructible
1495
+ class Params {
1496
+ private:
1497
+ friend PredicatedTileIteratorResidualLast;
1498
+
1499
+ /// Parameters object
1500
+ typename UnderlyingIterator::Params params_;
1501
+
1502
+ public:
1503
+ CUTLASS_HOST_DEVICE
1504
+ Params() {}
1505
+
1506
+ /// Construct the Params object given an AffineRankN<2> tensor's layout
1507
+ CUTLASS_HOST_DEVICE
1508
+ Params(Layout const& layout)
1509
+ : params_(layout::AffineRankN<2>(layout.stride(1), layout.stride(0))) {}
1510
+ };
1511
+
1512
+ private:
1513
+ //
1514
+ // Data members
1515
+ //
1516
+
1517
+ /// Underlying AffineRankN<2> tile iterator
1518
+ UnderlyingIterator iterator_;
1519
+
1520
+ public:
1521
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1522
+ /// and thread ID
1523
+ CUTLASS_HOST_DEVICE
1524
+ PredicatedTileIteratorResidualLast(
1525
+ Params const& params, ///< Precomputed parameters object
1526
+ Pointer pointer, ///< Pointer to start of tensor
1527
+ TensorCoord extent, ///< Extent of tensor
1528
+ int thread_id, ///< ID of each participating thread
1529
+ TensorCoord const& threadblock_offset, ///< Initial offset of threadblock
1530
+ int const* indices =
1531
+ nullptr ///< gather/scatter indices, note no support for
1532
+ ///< gather/scatter at this specialization
1533
+ )
1534
+ : iterator_(
1535
+ params.params_,
1536
+ pointer,
1537
+ layout::PitchLinearCoord(extent.column(), extent.row()),
1538
+ thread_id,
1539
+ layout::PitchLinearCoord(
1540
+ threadblock_offset.column(),
1541
+ threadblock_offset.row())) {}
1542
+
1543
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
1544
+ /// offset
1545
+ CUTLASS_HOST_DEVICE
1546
+ PredicatedTileIteratorResidualLast(
1547
+ Params const& params, ///< Precomputed parameters object
1548
+ Pointer pointer, ///< Pointer to start of tensor
1549
+ TensorCoord extent, ///< Extent of tensor
1550
+ int thread_id ///< ID of each participating thread
1551
+ )
1552
+ : PredicatedTileIteratorResidualLast(
1553
+ params,
1554
+ pointer,
1555
+ extent,
1556
+ thread_id,
1557
+ make_Coord(0, 0)) {}
1558
+
1559
+ /// Adds a pointer offset in units of Element
1560
+ CUTLASS_HOST_DEVICE
1561
+ void add_pointer_offset(LongIndex pointer_offset) {
1562
+ iterator_.add_pointer_offset(pointer_offset);
1563
+ }
1564
+
1565
+ /// Advances to the next tile in memory.
1566
+ ///
1567
+ /// The first time this method is called, predicates are updated, and the
1568
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1569
+ /// Subsequent calls are lightweight and must only update the internal
1570
+ /// pointer.
1571
+ CUTLASS_HOST_DEVICE
1572
+ PredicatedTileIteratorResidualLast& operator++() {
1573
+ ++iterator_;
1574
+ return *this;
1575
+ }
1576
+
1577
+ /// Advances to the next tile in memory.
1578
+ ///
1579
+ /// The first time this method is called, predicates are updated, and the
1580
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1581
+ /// Subsequent calls are lightweight and must only update the internal
1582
+ /// pointer.
1583
+ CUTLASS_HOST_DEVICE
1584
+ PredicatedTileIteratorResidualLast operator++(int) {
1585
+ PredicatedTileIteratorResidualLast self(*this);
1586
+ operator++();
1587
+ return self;
1588
+ }
1589
+
1590
+ /// Clears the predicate set efficiently
1591
+ CUTLASS_HOST_DEVICE
1592
+ void clear_mask(bool enable = true) {
1593
+ iterator_.clear_mask(enable);
1594
+ }
1595
+
1596
+ CUTLASS_HOST_DEVICE
1597
+ void set_residual_tile(bool enable) {
1598
+ iterator_.set_residual_tile(enable);
1599
+ }
1600
+
1601
+ /// Clears the predicate set efficiently
1602
+ CUTLASS_HOST_DEVICE
1603
+ void enable_mask() {
1604
+ iterator_.enable_mask();
1605
+ }
1606
+
1607
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1608
+ CUTLASS_HOST_DEVICE
1609
+ void set_mask(Mask const& mask) {
1610
+ iterator_.set_mask(mask);
1611
+ }
1612
+
1613
+ /// Gets the mask
1614
+ CUTLASS_HOST_DEVICE
1615
+ void get_mask(Mask& mask) {
1616
+ iterator_.get_mask(mask);
1617
+ }
1618
+
1619
+ /// Loads a fragment from memory
1620
+ CUTLASS_DEVICE
1621
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
1622
+ iterator_.load_with_pointer_offset(frag, pointer_offset);
1623
+ }
1624
+
1625
+ /// Loads a fragment from memory
1626
+ CUTLASS_DEVICE
1627
+ void load_with_byte_offset(Fragment& frag, LongIndex byte_offset) {
1628
+ iterator_.load_with_byte_offset(frag, byte_offset);
1629
+ }
1630
+
1631
+ /// Loads a fragment from memory
1632
+ CUTLASS_DEVICE
1633
+ void load(Fragment& frag) {
1634
+ load_with_pointer_offset(frag, 0);
1635
+ }
1636
+
1637
+ /// Store a fragment to memory
1638
+ CUTLASS_DEVICE
1639
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
1640
+ iterator_.store_with_pointer_offset(frag, pointer_offset);
1641
+ }
1642
+
1643
+ /// Store a fragment to memory
1644
+ CUTLASS_DEVICE
1645
+ void store_with_byte_offset(Fragment const& frag, LongIndex byte_offset) {
1646
+ iterator_.store_with_byte_offset(frag, byte_offset);
1647
+ }
1648
+
1649
+ /// Store a fragment to memory
1650
+ CUTLASS_DEVICE
1651
+ void store(Fragment const& frag) {
1652
+ store_with_pointer_offset(frag, 0);
1653
+ }
1654
+ };
1655
+
1656
+ ////////////////////////////////////////////////////////////////////////////////
1657
+
1658
+ /// Specialization of PredicatedTileIteratorResidualLast for interleaved data.
1659
+ /// It is mapped to the congruous layout.
1660
+ ///
1661
+ /// Satisfies: ForwardTileIteratorConcept |
1662
+ /// ReadableContiguousTileIteratorConcept |
1663
+ /// WriteableContiguousTileIteratorConcept |
1664
+ /// MaskedTileIteratorConcept
1665
+ ///
1666
+
1667
+ template <
1668
+ typename Shape_,
1669
+ typename Element_,
1670
+ int AdvanceRank,
1671
+ typename ThreadMap_,
1672
+ int AccessSize,
1673
+ int InterleavedK>
1674
+ class PredicatedTileIteratorResidualLast<
1675
+ Shape_,
1676
+ Element_,
1677
+ layout::ColumnMajorInterleaved<InterleavedK>,
1678
+ AdvanceRank,
1679
+ ThreadMap_,
1680
+ AccessSize,
1681
+ false> {
1682
+ public:
1683
+ static_assert(
1684
+ AdvanceRank == 0 || AdvanceRank == 1,
1685
+ "Specialization for pitch-linear iterator may along advance along the "
1686
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1687
+
1688
+ using Shape = Shape_;
1689
+ using Element = Element_;
1690
+ static int const kInterleavedK = InterleavedK;
1691
+ using Layout = layout::ColumnMajorInterleaved<kInterleavedK>;
1692
+ static int const kAdvanceRank = AdvanceRank;
1693
+ using ThreadMap = ThreadMap_;
1694
+
1695
+ using Index = typename Layout::Index;
1696
+ using LongIndex = typename Layout::LongIndex;
1697
+
1698
+ using TensorRef = TensorRef<Element, Layout>;
1699
+ using TensorView = TensorView<Element, Layout>;
1700
+ using TensorCoord = typename Layout::TensorCoord;
1701
+
1702
+ using Pointer = Element*;
1703
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1704
+
1705
+ using UnderlyingIterator = PredicatedTileIteratorResidualLast<
1706
+ layout::PitchLinearShape<
1707
+ Shape::kRow * kInterleavedK,
1708
+ Shape::kColumn / kInterleavedK>,
1709
+ Element,
1710
+ layout::PitchLinear,
1711
+ (kAdvanceRank == 0 ? 0 : 1),
1712
+ ThreadMap,
1713
+ AccessSize>;
1714
+
1715
+ using AccessType = typename UnderlyingIterator::AccessType;
1716
+
1717
+ /// Fragment object to be loaded or stored
1718
+ using Fragment = cutlass::Array<
1719
+ Element,
1720
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
1721
+
1722
+ /// Predicate vector stores mask to guard accesses
1723
+ using Mask = typename UnderlyingIterator::Mask;
1724
+
1725
+ /// Parameters object is precomputed state and is host-constructible
1726
+ class Params {
1727
+ private:
1728
+ friend PredicatedTileIteratorResidualLast;
1729
+
1730
+ /// Parameters object
1731
+ typename UnderlyingIterator::Params params_;
1732
+
1733
+ public:
1734
+ CUTLASS_HOST_DEVICE
1735
+ Params() {}
1736
+
1737
+ /// Construct the Params object given a pitch-linear tensor's layout
1738
+ CUTLASS_HOST_DEVICE
1739
+ Params(Layout const& layout)
1740
+ : params_(layout::PitchLinear(layout.stride(0))) {}
1741
+
1742
+ CUTLASS_HOST_DEVICE
1743
+ Params(typename UnderlyingIterator::Params::Base const& base)
1744
+ : params_(base) {}
1745
+ };
1746
+
1747
+ private:
1748
+ //
1749
+ // Data members
1750
+ //
1751
+
1752
+ /// Underlying pitch-linear tile iterator
1753
+ UnderlyingIterator iterator_;
1754
+
1755
+ public:
1756
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1757
+ /// and thread ID
1758
+ CUTLASS_HOST_DEVICE
1759
+ PredicatedTileIteratorResidualLast(
1760
+ /// Precomputed parameters object
1761
+ Params const& params,
1762
+ /// Pointer to start of tensor
1763
+ Pointer pointer,
1764
+ /// Extent of tensor
1765
+ TensorCoord extent,
1766
+ /// ID of each participating thread
1767
+ int thread_id,
1768
+ /// Initial offset of threadblock
1769
+ TensorCoord const& threadblock_offset,
1770
+ int const* indices =
1771
+ nullptr ///< gather/scatter indices, note no support for
1772
+ ///< gather/scatter at this specialization
1773
+ )
1774
+ : iterator_(
1775
+ params.params_,
1776
+ pointer,
1777
+ layout::PitchLinearCoord(
1778
+ extent.row() * kInterleavedK,
1779
+ extent.column() / kInterleavedK),
1780
+ thread_id,
1781
+ layout::PitchLinearCoord(
1782
+ threadblock_offset.row() * kInterleavedK,
1783
+ threadblock_offset.column() / kInterleavedK)) {}
1784
+
1785
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
1786
+ /// offset
1787
+ CUTLASS_HOST_DEVICE
1788
+ PredicatedTileIteratorResidualLast(
1789
+ Params const& params, ///< Precomputed parameters object
1790
+ Pointer pointer, ///< Pointer to start of tensor
1791
+ TensorCoord extent, ///< Extent of tensor
1792
+ int thread_id ///< ID of each participating thread
1793
+ )
1794
+ : PredicatedTileIteratorResidualLast(
1795
+ params,
1796
+ pointer,
1797
+ extent,
1798
+ thread_id,
1799
+ make_Coord(0, 0)) {}
1800
+
1801
+ /// Adds a pointer offset in units of Element
1802
+ CUTLASS_HOST_DEVICE
1803
+ void add_pointer_offset(LongIndex pointer_offset) {
1804
+ iterator_.add_pointer_offset(pointer_offset);
1805
+ }
1806
+
1807
+ /// Advances to the next tile in memory.
1808
+ ///
1809
+ /// The first time this method is called, predicates are updated, and the
1810
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1811
+ /// Subsequent calls are lightweight and must only update the internal
1812
+ /// pointer.
1813
+ CUTLASS_HOST_DEVICE
1814
+ PredicatedTileIteratorResidualLast& operator++() {
1815
+ ++iterator_;
1816
+ return *this;
1817
+ }
1818
+
1819
+ /// Advances to the next tile in memory.
1820
+ ///
1821
+ /// The first time this method is called, predicates are updated, and the
1822
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
1823
+ /// Subsequent calls are lightweight and must only update the internal
1824
+ /// pointer.
1825
+ CUTLASS_HOST_DEVICE
1826
+ PredicatedTileIteratorResidualLast operator++(int) {
1827
+ PredicatedTileIteratorResidualLast self(*this);
1828
+ operator++();
1829
+ return self;
1830
+ }
1831
+
1832
+ /// Clears the predicate set efficiently
1833
+ CUTLASS_HOST_DEVICE
1834
+ void clear_mask(bool enable = true) {
1835
+ iterator_.clear_mask(enable);
1836
+ }
1837
+
1838
+ CUTLASS_HOST_DEVICE
1839
+ void set_residual_tile(bool enable) {
1840
+ iterator_.set_residual_tile(enable);
1841
+ }
1842
+
1843
+ /// Clears the predicate set efficiently
1844
+ CUTLASS_HOST_DEVICE
1845
+ void enable_mask() {
1846
+ iterator_.enable_mask();
1847
+ }
1848
+
1849
+ /// Sets the predicate mask, overriding value stored in predicate iterator
1850
+ CUTLASS_HOST_DEVICE
1851
+ void set_mask(Mask const& mask) {
1852
+ iterator_.set_mask(mask);
1853
+ }
1854
+
1855
+ /// Gets the mask
1856
+ CUTLASS_HOST_DEVICE
1857
+ void get_mask(Mask& mask) {
1858
+ iterator_.get_mask(mask);
1859
+ }
1860
+
1861
+ /// Loads a fragment from memory
1862
+ CUTLASS_DEVICE
1863
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
1864
+ iterator_.load_with_pointer_offset(frag, pointer_offset);
1865
+ }
1866
+
1867
+ /// Loads a fragment from memory
1868
+ CUTLASS_DEVICE
1869
+ void load(Fragment& frag) {
1870
+ load_with_pointer_offset(frag, 0);
1871
+ }
1872
+
1873
+ /// Store a fragment to memory
1874
+ CUTLASS_DEVICE
1875
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
1876
+ iterator_.store_with_pointer_offset(frag, pointer_offset);
1877
+ }
1878
+
1879
+ /// Store a fragment to memory
1880
+ CUTLASS_DEVICE
1881
+ void store(Fragment const& frag) {
1882
+ store_with_pointer_offset(frag, 0);
1883
+ }
1884
+ };
1885
+
1886
+ ////////////////////////////////////////////////////////////////////////////////
1887
+
1888
+ /// Specialization of PredicatedTileIteratorResidualLast for interleaved-32
1889
+ /// data. It is mapped to the congruous layout.
1890
+ ///
1891
+ /// Satisfies: ForwardTileIteratorConcept |
1892
+ /// ReadableContiguousTileIteratorConcept |
1893
+ /// WriteableContiguousTileIteratorConcept |
1894
+ /// MaskedTileIteratorConcept
1895
+ ///
1896
+ template <
1897
+ typename Shape_,
1898
+ typename Element_,
1899
+ int AdvanceRank,
1900
+ typename ThreadMap_,
1901
+ int AccessSize,
1902
+ int InterleavedK>
1903
+ class PredicatedTileIteratorResidualLast<
1904
+ Shape_,
1905
+ Element_,
1906
+ layout::RowMajorInterleaved<InterleavedK>,
1907
+ AdvanceRank,
1908
+ ThreadMap_,
1909
+ AccessSize,
1910
+ false> {
1911
+ public:
1912
+ static_assert(
1913
+ AdvanceRank == 0 || AdvanceRank == 1,
1914
+ "Specialization for pitch-linear iterator may along advance along the "
1915
+ "contiguous(rank=0) or strided(rank=1) dimension.");
1916
+
1917
+ using Shape = Shape_;
1918
+ using Element = Element_;
1919
+ static int const kInterleavedK = InterleavedK;
1920
+ using Layout = layout::RowMajorInterleaved<kInterleavedK>;
1921
+ static int const kAdvanceRank = AdvanceRank;
1922
+ using ThreadMap = ThreadMap_;
1923
+
1924
+ using Index = typename Layout::Index;
1925
+ using LongIndex = typename Layout::LongIndex;
1926
+
1927
+ using TensorRef = TensorRef<Element, Layout>;
1928
+ using TensorView = TensorView<Element, Layout>;
1929
+ using TensorCoord = typename Layout::TensorCoord;
1930
+
1931
+ using Pointer = Element*;
1932
+ using NonConstPointer = typename platform::remove_const<Element>::type*;
1933
+
1934
+ using UnderlyingIterator = PredicatedTileIteratorResidualLast<
1935
+ layout::PitchLinearShape<
1936
+ Shape::kColumn * kInterleavedK,
1937
+ Shape::kRow / kInterleavedK>,
1938
+ Element,
1939
+ layout::PitchLinear,
1940
+ (kAdvanceRank == 0 ? 1 : 0),
1941
+ ThreadMap,
1942
+ AccessSize>;
1943
+
1944
+ using AccessType = typename UnderlyingIterator::AccessType;
1945
+
1946
+ /// Fragment object to be loaded or stored
1947
+ using Fragment = cutlass::Array<
1948
+ Element,
1949
+ ThreadMap::Iterations::kCount * ThreadMap::kElementsPerAccess>;
1950
+
1951
+ /// Predicate vector stores mask to guard accesses
1952
+ using Mask = typename UnderlyingIterator::Mask;
1953
+
1954
+ /// Parameters object is precomputed state and is host-constructible
1955
+ class Params {
1956
+ private:
1957
+ friend PredicatedTileIteratorResidualLast;
1958
+
1959
+ /// Parameters object
1960
+ typename UnderlyingIterator::Params params_;
1961
+
1962
+ public:
1963
+ CUTLASS_HOST_DEVICE
1964
+ Params() {}
1965
+
1966
+ /// Construct the Params object given a pitch-linear tensor's layout
1967
+ CUTLASS_HOST_DEVICE
1968
+ Params(Layout const& layout)
1969
+ : params_(layout::PitchLinear(layout.stride(0))) {}
1970
+
1971
+ CUTLASS_HOST_DEVICE
1972
+ Params(typename UnderlyingIterator::Params::Base const& base)
1973
+ : params_(base) {}
1974
+ };
1975
+
1976
+ private:
1977
+ //
1978
+ // Data members
1979
+ //
1980
+
1981
+ /// Underlying pitch-linear tile iterator
1982
+ UnderlyingIterator iterator_;
1983
+
1984
+ public:
1985
+ /// Constructs a TileIterator from its precomputed state, threadblock offset,
1986
+ /// and thread ID
1987
+ CUTLASS_HOST_DEVICE
1988
+ PredicatedTileIteratorResidualLast(
1989
+ /// Precomputed parameters object
1990
+ Params const& params,
1991
+ /// Pointer to start of tensor
1992
+ Pointer pointer,
1993
+ /// Extent of tensor
1994
+ TensorCoord extent,
1995
+ /// ID of each participating thread
1996
+ int thread_id,
1997
+ /// Initial offset of threadblock
1998
+ TensorCoord const& threadblock_offset,
1999
+ int const* indices =
2000
+ nullptr ///< gather/scatter indices, note no support for
2001
+ ///< gather/scatter at this specialization
2002
+ )
2003
+ : iterator_(
2004
+ params.params_,
2005
+ pointer,
2006
+ layout::PitchLinearCoord(
2007
+ extent.column() * kInterleavedK,
2008
+ extent.row() / kInterleavedK),
2009
+ thread_id,
2010
+ layout::PitchLinearCoord(
2011
+ threadblock_offset.column() * kInterleavedK,
2012
+ threadblock_offset.row() / kInterleavedK)) {}
2013
+
2014
+ /// Construct a PredicatedTileIteratorResidualLast with zero threadblock
2015
+ /// offset
2016
+ CUTLASS_HOST_DEVICE
2017
+ PredicatedTileIteratorResidualLast(
2018
+ Params const& params, ///< Precomputed parameters object
2019
+ Pointer pointer, ///< Pointer to start of tensor
2020
+ TensorCoord extent, ///< Extent of tensor
2021
+ int thread_id ///< ID of each participating thread
2022
+ )
2023
+ : PredicatedTileIteratorResidualLast(
2024
+ params,
2025
+ pointer,
2026
+ extent,
2027
+ thread_id,
2028
+ make_Coord(0, 0)) {}
2029
+
2030
+ /// Adds a pointer offset in units of Element
2031
+ CUTLASS_HOST_DEVICE
2032
+ void add_pointer_offset(LongIndex pointer_offset) {
2033
+ iterator_.add_pointer_offset(pointer_offset);
2034
+ }
2035
+
2036
+ /// Advances to the next tile in memory.
2037
+ ///
2038
+ /// The first time this method is called, predicates are updated, and the
2039
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
2040
+ /// Subsequent calls are lightweight and must only update the internal
2041
+ /// pointer.
2042
+ CUTLASS_HOST_DEVICE
2043
+ PredicatedTileIteratorResidualLast& operator++() {
2044
+ ++iterator_;
2045
+ return *this;
2046
+ }
2047
+
2048
+ /// Advances to the next tile in memory.
2049
+ ///
2050
+ /// The first time this method is called, predicates are updated, and the
2051
+ /// iterator's internal pointer is reverted to the first "steady state" tile.
2052
+ /// Subsequent calls are lightweight and must only update the internal
2053
+ /// pointer.
2054
+ CUTLASS_HOST_DEVICE
2055
+ PredicatedTileIteratorResidualLast operator++(int) {
2056
+ PredicatedTileIteratorResidualLast self(*this);
2057
+ operator++();
2058
+ return self;
2059
+ }
2060
+
2061
+ /// Clears the predicate set efficiently
2062
+ CUTLASS_HOST_DEVICE
2063
+ void clear_mask(bool enable = true) {
2064
+ iterator_.clear_mask(enable);
2065
+ }
2066
+
2067
+ CUTLASS_HOST_DEVICE
2068
+ void set_residual_tile(bool enable) {
2069
+ iterator_.set_residual_tile(enable);
2070
+ }
2071
+
2072
+ /// Clears the predicate set efficiently
2073
+ CUTLASS_HOST_DEVICE
2074
+ void enable_mask() {
2075
+ iterator_.enable_mask();
2076
+ }
2077
+
2078
+ /// Sets the predicate mask, overriding value stored in predicate iterator
2079
+ CUTLASS_HOST_DEVICE
2080
+ void set_mask(Mask const& mask) {
2081
+ iterator_.set_mask(mask);
2082
+ }
2083
+
2084
+ /// Gets the mask
2085
+ CUTLASS_HOST_DEVICE
2086
+ void get_mask(Mask& mask) {
2087
+ iterator_.get_mask(mask);
2088
+ }
2089
+
2090
+ /// Loads a fragment from memory
2091
+ CUTLASS_DEVICE
2092
+ void load_with_pointer_offset(Fragment& frag, Index pointer_offset) {
2093
+ iterator_.load_with_pointer_offset(frag, pointer_offset);
2094
+ }
2095
+
2096
+ /// Loads a fragment from memory
2097
+ CUTLASS_DEVICE
2098
+ void load(Fragment& frag) {
2099
+ load_with_pointer_offset(frag, 0);
2100
+ }
2101
+
2102
+ /// Store a fragment to memory
2103
+ CUTLASS_DEVICE
2104
+ void store_with_pointer_offset(Fragment const& frag, Index pointer_offset) {
2105
+ iterator_.store_with_pointer_offset(frag, pointer_offset);
2106
+ }
2107
+
2108
+ /// Store a fragment to memory
2109
+ CUTLASS_DEVICE
2110
+ void store(Fragment const& frag) {
2111
+ store_with_pointer_offset(frag, 0);
2112
+ }
2113
+ };
2114
+
2115
+ ////////////////////////////////////////////////////////////////////////////////
2116
+
2117
+ } // namespace threadblock
2118
+ } // namespace transform
2119
+ } // namespace cutlass
2120
+
2121
+ ////////////////////////////////////////////////////////////////////////////////
2122
+
2123
+ #else
2124
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
2125
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/transpose_warp_iterator.h ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ #pragma once
10
+
11
+ #include <ATen/native/transformers/cuda/mem_eff_attention/iterators/warp_iterator_from_smem.h>
12
+
13
+ template <typename WarpIterator>
14
+ struct TransposeWarpIterator {
15
+ using Iterator = char;
16
+ static bool constexpr kSupportsTranspose = false;
17
+ };
18
+
19
+ template <
20
+ /// Operand identity
21
+ cutlass::gemm::Operand Operand,
22
+ /// Data type of A elements
23
+ typename Element,
24
+ typename InstructionShape,
25
+ bool kTranspose>
26
+ struct TransposeWarpIterator<
27
+ cutlass::gemm::warp::
28
+ WarpIteratorFromSmem<Operand, Element, InstructionShape, kTranspose>> {
29
+ using Iterator = cutlass::gemm::warp::
30
+ WarpIteratorFromSmem<Operand, Element, InstructionShape, !kTranspose>;
31
+ static bool constexpr kSupportsTranspose = true;
32
+ };
33
+
34
+ #else
35
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
36
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/iterators/warp_iterator_from_smem.h ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /***************************************************************************************************
3
+ * Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights
4
+ *reserved. SPDX-License-Identifier: BSD-3-Clause
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ *this list of conditions and the following disclaimer.
11
+ *
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ * this list of conditions and the following disclaimer in the documentation
14
+ * and/or other materials provided with the distribution.
15
+ *
16
+ * 3. Neither the name of the copyright holder nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ *ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+ *LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ *INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ *CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ *ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ *POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ **************************************************************************************************/
33
+ /*! \file
34
+ \brief Inspired from
35
+ "cutlass/gemm/warp/mma_tensor_op_tile_access_iterator.h" Loads tiles of GEMM
36
+ operands from a RowMajor shared-memory layout into registers to use by A100
37
+ TensorCores.
38
+
39
+ The difference with "mma_tensor_op_tile_access_iterator.h" is that:
40
+ (1) We use "ldmatrix" to load tiles, rather than manual loads (slightly
41
+ faster) (2) We support to transpose the operand (eg read `A.transpose()` when
42
+ the shared memory holds `A`)
43
+
44
+ This is only implemented for the specific shapes.
45
+ */
46
+ #pragma once
47
+
48
+ #include <cutlass/gemm/gemm.h>
49
+
50
+ ////////////////////////////////////////////////////////////////////////////////
51
+ namespace cutlass {
52
+ namespace gemm {
53
+ namespace warp {
54
+
55
+ template <
56
+ /// Operand identity
57
+ Operand Operand_,
58
+ /// Data type of A elements
59
+ typename Element_,
60
+ typename InstructionShape_,
61
+ bool kTranspose = false>
62
+ class WarpIteratorFromSmem {
63
+ public:
64
+ /// Shape of tile to load (concept: MatrixShape)
65
+ using Shape = cutlass::MatrixShape<32, 32>;
66
+
67
+ /// Operand tag
68
+ static Operand const kOperand = Operand_;
69
+ static_assert(
70
+ kOperand == Operand::kA,
71
+ "No support for OperandB at the moment");
72
+
73
+ /// Basic check
74
+ static_assert(
75
+ kOperand == Operand::kA || kOperand == Operand::kB,
76
+ "WarpIteratorFromSmem may only be instantiated for A or B operands to warp-level Mma.");
77
+
78
+ /// Element type
79
+ using Element = Element_;
80
+ static_assert(sizeof_bits<Element>::value == 16, "Only supported for half");
81
+
82
+ /// Layout of source tile
83
+ using Layout = cutlass::layout::RowMajor;
84
+
85
+ /// Shape of one matrix product operation (concept: MatrixShape)
86
+ using InstructionShape = InstructionShape_;
87
+ static_assert(InstructionShape::kRow == 16, "Only supports 16x8x8 / 16x8x16");
88
+ static_assert(
89
+ InstructionShape::kColumn == 8 || InstructionShape::kColumn == 16,
90
+ "Only supports 16x8x8 / 16x8x16");
91
+
92
+ /// Delta between *MMA operations (in units of *MMA operations, concept:
93
+ /// MatrixShape)
94
+ static int const kOpDelta = 1;
95
+
96
+ /// Number of participating threads
97
+ static int const kThreads = 32;
98
+
99
+ /// TensorRef type for loading element from a tensor
100
+ using TensorRef = TensorRef<Element, Layout>;
101
+
102
+ /// Index type
103
+ using Index = typename TensorRef::Index;
104
+
105
+ /// Long Index type
106
+ using LongIndex = typename TensorRef::LongIndex;
107
+
108
+ /// Coordinate for an element in the tensor
109
+ using TensorCoord = typename TensorRef::TensorCoord;
110
+
111
+ /// Number of elements accessed per Shared Memory load
112
+ static int const kElementsPerAccess =
113
+ (sizeof_bits<Element>::value >= 32 ? 1
114
+ : 32 / sizeof_bits<Element>::value);
115
+
116
+ using InstructionCount = MatrixShape<
117
+ Shape::kRow / InstructionShape::kRow,
118
+ Shape::kColumn / InstructionShape::kColumn>;
119
+
120
+ static int const kIterations = (kOperand == Operand::kA)
121
+ ? InstructionCount::kColumn
122
+ : InstructionCount::kRow;
123
+
124
+ public:
125
+ //
126
+ // Derived quantities
127
+ //
128
+
129
+ /// Fragment object holding a thread's part of a tile
130
+ using Fragment = Array<
131
+ Element,
132
+ (kOperand == Operand::kA)
133
+ ? (Shape::kRow* InstructionShape::kColumn / kThreads)
134
+ : (Shape::kColumn* InstructionShape::kRow / kThreads)>;
135
+
136
+ /// Memory access type
137
+ // using AccessType = AlignedArray<Element, kElementsPerAccess>;
138
+ using AccessType = Array<unsigned, 4>;
139
+
140
+ static int constexpr kWarpShapeDivisibleInner =
141
+ (kOperand == Operand::kA ? InstructionShape::kColumn
142
+ : InstructionShape::kRow);
143
+ static int constexpr kAccessesInner =
144
+ (kWarpShapeDivisibleInner / kElementsPerAccess) / 4;
145
+ // Number of 32bits tiles to load per `ldmatrix`
146
+ static int const kTilesPerInstruction = InstructionShape::kRow / 8;
147
+ static_assert(kTilesPerInstruction == 2, "Only supports 16x8x16 and 16x8x8");
148
+
149
+ private:
150
+ /// Underlying tensor reference
151
+ TensorRef ref_;
152
+
153
+ /// Origin
154
+ MatrixCoord origin_;
155
+
156
+ /// Iterations in a tile
157
+ int iterations_;
158
+
159
+ public:
160
+ /// Constructor from TensorRef
161
+ CUTLASS_HOST_DEVICE
162
+ WarpIteratorFromSmem(TensorRef const& ref, int lane_id)
163
+ : WarpIteratorFromSmem(ref, {Shape::kRow, Shape::kColumn}, lane_id) {}
164
+ CUTLASS_HOST_DEVICE
165
+ WarpIteratorFromSmem(TensorRef const& ref, TensorCoord extent, int lane_id)
166
+ : ref_(ref), iterations_(0) {
167
+ // See also:
168
+ // https://docs.nvidia.com/cuda/archive/11.7.1/parallel-thread-execution/index.html#warp-level-matrix-fragment-mma-1688
169
+ // 16x8x8: kAccessesInner = 1 (1 ldmatrix.x4)
170
+ // 16x8x16: kAccessesInner = 2 (2 ldmatrix.x4)
171
+ int ldsm_vec_num = (lane_id >> 3);
172
+ if (kOperand == Operand::kA) {
173
+ origin_ = MatrixCoord(lane_id % 8, 0);
174
+ static_assert(
175
+ InstructionCount::kRow * kTilesPerInstruction == 4,
176
+ "can't use ldmatrix.x4");
177
+ int access_m_idx = ldsm_vec_num % kTilesPerInstruction;
178
+ int inner_idx = (ldsm_vec_num / kTilesPerInstruction) % kAccessesInner;
179
+ int inst_m_idx = ldsm_vec_num / (kTilesPerInstruction * kAccessesInner);
180
+ MatrixCoord offset(
181
+ access_m_idx * 8 + inst_m_idx * InstructionShape::kRow,
182
+ inner_idx * 4 * kElementsPerAccess);
183
+ if (kTranspose) {
184
+ offset = MatrixCoord(offset.column(), offset.row());
185
+ }
186
+ origin_ += offset;
187
+ } else {
188
+ // XXX: This is not tested or used
189
+ origin_ = MatrixCoord(0, lane_id % 8);
190
+ static_assert(InstructionCount::kColumn * kAccessesInner == 4, "");
191
+ CUTLASS_PRAGMA_UNROLL
192
+ for (int inst_n_idx = 0; inst_n_idx < InstructionCount::kColumn;
193
+ ++inst_n_idx) {
194
+ CUTLASS_PRAGMA_UNROLL
195
+ for (int inner_idx = 0; inner_idx < kAccessesInner; ++inner_idx) {
196
+ int access_idx = inner_idx + kAccessesInner * inst_n_idx;
197
+
198
+ MatrixCoord offset(
199
+ inner_idx * 4 * kElementsPerAccess, inst_n_idx * 8);
200
+
201
+ if (access_idx == ldsm_vec_num) {
202
+ if (kTranspose) {
203
+ offset = MatrixCoord(offset.column(), offset.row());
204
+ }
205
+ origin_ += offset;
206
+ }
207
+ }
208
+ }
209
+ }
210
+
211
+ ref_.add_coord_offset(origin_);
212
+ }
213
+
214
+ /// Advances an iterator along logical dimensions of matrix in units of whole
215
+ /// tiles
216
+ CUTLASS_HOST_DEVICE
217
+ WarpIteratorFromSmem& add_tile_offset(TensorCoord const& tile_offset) {
218
+ TensorCoord coord_offset(
219
+ tile_offset.row() * Shape::kRow, tile_offset.column() * Shape::kColumn);
220
+ if (kTranspose) {
221
+ coord_offset = TensorCoord{coord_offset.column(), coord_offset.row()};
222
+ }
223
+ origin_ += coord_offset;
224
+
225
+ ref_.add_coord_offset(coord_offset);
226
+
227
+ return *this;
228
+ }
229
+
230
+ /// Advances the iterator along the advance dimension
231
+ CUTLASS_DEVICE
232
+ void advance() {
233
+ if (kOperand == Operand::kA) {
234
+ add_tile_offset({0, 1});
235
+ } else {
236
+ add_tile_offset({1, 0});
237
+ }
238
+
239
+ iterations_ = 0;
240
+ }
241
+
242
+ /// increase iterations in a tile
243
+ CUTLASS_HOST_DEVICE
244
+ WarpIteratorFromSmem& operator++() {
245
+ iterations_++;
246
+
247
+ if (iterations_ >= kIterations)
248
+ advance();
249
+
250
+ return *this;
251
+ }
252
+
253
+ /// Loads a fragment from memory at the location pointed to by the iterator.
254
+ CUTLASS_DEVICE
255
+ void load(Fragment& frag) const {
256
+ AccessType* access_ptr = reinterpret_cast<AccessType*>(&frag);
257
+ using LoadLayout = typename platform::
258
+ conditional<kTranspose, layout::ColumnMajor, layout::RowMajor>::type;
259
+
260
+ CUTLASS_PRAGMA_UNROLL
261
+ for (int access_m_idx = 0; access_m_idx <
262
+ (InstructionCount::kRow * kTilesPerInstruction * kAccessesInner) / 4;
263
+ ++access_m_idx) {
264
+ MatrixCoord offset;
265
+ if (kOperand == Operand::kA) {
266
+ offset = MatrixCoord(
267
+ access_m_idx * 16, iterations_ * InstructionShape::kColumn);
268
+ } else {
269
+ offset = MatrixCoord(iterations_ * InstructionShape::kRow, 0);
270
+ }
271
+ if (kTranspose) {
272
+ offset = MatrixCoord(offset.column(), offset.row());
273
+ }
274
+ cutlass::arch::ldsm<LoadLayout, 4>(
275
+ access_ptr[access_m_idx], ref_.data() + ref_.offset(offset));
276
+ }
277
+ }
278
+ };
279
+
280
+ ////////////////////////////////////////////////////////////////////////////////
281
+
282
+ } // namespace warp
283
+ } // namespace gemm
284
+ } // namespace cutlass
285
+ ////////////////////////////////////////////////////////////////////////////////
286
+
287
+ #else
288
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
289
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/kernels/cutlassB.h ADDED
@@ -0,0 +1,919 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ // This file is auto-generated. See "generate_kernels.py"
10
+ #pragma once
11
+ #include <ATen/native/transformers/cuda/mem_eff_attention/kernel_backward.h>
12
+ using namespace PyTorchMemEffAttention;
13
+ // ======== f16 / sm70 ========
14
+ __global__ void __launch_bounds__(
15
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32, true>::kNumThreads,
16
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32, true>::kMinBlocksPerSm)
17
+ fmha_cutlassB_f16_aligned_64x64_k32_seqaligned_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32, true>::Params p);
18
+ __global__ void __launch_bounds__(
19
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32>::kNumThreads,
20
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32>::kMinBlocksPerSm)
21
+ fmha_cutlassB_f16_aligned_64x64_k32_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32>::Params p);
22
+ __global__ void __launch_bounds__(
23
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64, true>::kNumThreads,
24
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64, true>::kMinBlocksPerSm)
25
+ fmha_cutlassB_f16_aligned_64x64_k64_seqaligned_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64, true>::Params p);
26
+ __global__ void __launch_bounds__(
27
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64>::kNumThreads,
28
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64>::kMinBlocksPerSm)
29
+ fmha_cutlassB_f16_aligned_64x64_k64_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64>::Params p);
30
+ __global__ void __launch_bounds__(
31
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128, true>::kNumThreads,
32
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128, true>::kMinBlocksPerSm)
33
+ fmha_cutlassB_f16_aligned_128x64_k128_seqaligned_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128, true>::Params p);
34
+ __global__ void __launch_bounds__(
35
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128>::kNumThreads,
36
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128>::kMinBlocksPerSm)
37
+ fmha_cutlassB_f16_aligned_128x64_k128_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128>::Params p);
38
+ __global__ void __launch_bounds__(
39
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128, true>::kNumThreads,
40
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128, true>::kMinBlocksPerSm)
41
+ fmha_cutlassB_f16_aligned_64x64_k128_seqaligned_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128, true>::Params p);
42
+ __global__ void __launch_bounds__(
43
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128>::kNumThreads,
44
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
45
+ fmha_cutlassB_f16_aligned_64x64_k128_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128>::Params p);
46
+ __global__ void __launch_bounds__(
47
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 65536>::kNumThreads,
48
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 65536>::kMinBlocksPerSm)
49
+ fmha_cutlassB_f16_aligned_128x64_k65536_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 65536>::Params p);
50
+ __global__ void __launch_bounds__(
51
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 65536>::kNumThreads,
52
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
53
+ fmha_cutlassB_f16_aligned_64x64_k65536_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 65536>::Params p);
54
+ __global__ void __launch_bounds__(
55
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 32>::kNumThreads,
56
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 32>::kMinBlocksPerSm)
57
+ fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 32>::Params p);
58
+ __global__ void __launch_bounds__(
59
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 64>::kNumThreads,
60
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 64>::kMinBlocksPerSm)
61
+ fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 64>::Params p);
62
+ __global__ void __launch_bounds__(
63
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 128>::kNumThreads,
64
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 128>::kMinBlocksPerSm)
65
+ fmha_cutlassB_f16_aligned_128x64_k128_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 128>::Params p);
66
+ __global__ void __launch_bounds__(
67
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 128>::kNumThreads,
68
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
69
+ fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 128>::Params p);
70
+ __global__ void __launch_bounds__(
71
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 65536>::kNumThreads,
72
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 65536>::kMinBlocksPerSm)
73
+ fmha_cutlassB_f16_aligned_128x64_k65536_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 65536>::Params p);
74
+ __global__ void __launch_bounds__(
75
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 65536>::kNumThreads,
76
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
77
+ fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 65536>::Params p);
78
+ __global__ void __launch_bounds__(
79
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 32>::kNumThreads,
80
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 32>::kMinBlocksPerSm)
81
+ fmha_cutlassB_f16_notaligned_64x64_k32_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 32>::Params p);
82
+ __global__ void __launch_bounds__(
83
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 64>::kNumThreads,
84
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 64>::kMinBlocksPerSm)
85
+ fmha_cutlassB_f16_notaligned_64x64_k64_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 64>::Params p);
86
+ __global__ void __launch_bounds__(
87
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 128>::kNumThreads,
88
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 128>::kMinBlocksPerSm)
89
+ fmha_cutlassB_f16_notaligned_128x64_k128_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 128>::Params p);
90
+ __global__ void __launch_bounds__(
91
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 128>::kNumThreads,
92
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 128>::kMinBlocksPerSm)
93
+ fmha_cutlassB_f16_notaligned_64x64_k128_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 128>::Params p);
94
+ __global__ void __launch_bounds__(
95
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 65536>::kNumThreads,
96
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 65536>::kMinBlocksPerSm)
97
+ fmha_cutlassB_f16_notaligned_128x64_k65536_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 65536>::Params p);
98
+ __global__ void __launch_bounds__(
99
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 65536>::kNumThreads,
100
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 65536>::kMinBlocksPerSm)
101
+ fmha_cutlassB_f16_notaligned_64x64_k65536_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 65536>::Params p);
102
+ __global__ void __launch_bounds__(
103
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 32>::kNumThreads,
104
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 32>::kMinBlocksPerSm)
105
+ fmha_cutlassB_f16_notaligned_64x64_k32_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 32>::Params p);
106
+ __global__ void __launch_bounds__(
107
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 64>::kNumThreads,
108
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 64>::kMinBlocksPerSm)
109
+ fmha_cutlassB_f16_notaligned_64x64_k64_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 64>::Params p);
110
+ __global__ void __launch_bounds__(
111
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 128>::kNumThreads,
112
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 128>::kMinBlocksPerSm)
113
+ fmha_cutlassB_f16_notaligned_128x64_k128_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 128>::Params p);
114
+ __global__ void __launch_bounds__(
115
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 128>::kNumThreads,
116
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 128>::kMinBlocksPerSm)
117
+ fmha_cutlassB_f16_notaligned_64x64_k128_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 128>::Params p);
118
+ __global__ void __launch_bounds__(
119
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 65536>::kNumThreads,
120
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 65536>::kMinBlocksPerSm)
121
+ fmha_cutlassB_f16_notaligned_128x64_k65536_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 65536>::Params p);
122
+ __global__ void __launch_bounds__(
123
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 65536>::kNumThreads,
124
+ AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 65536>::kMinBlocksPerSm)
125
+ fmha_cutlassB_f16_notaligned_64x64_k65536_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 65536>::Params p);
126
+
127
+ template <typename T> void dispatch_cutlassB_f16_sm70(T cb, int cc) {
128
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32, true>(), fmha_cutlassB_f16_aligned_64x64_k32_seqaligned_sm70);
129
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_sm70);
130
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64, true>(), fmha_cutlassB_f16_aligned_64x64_k64_seqaligned_sm70);
131
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_sm70);
132
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128, true>(), fmha_cutlassB_f16_aligned_128x64_k128_seqaligned_sm70);
133
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 128>(), fmha_cutlassB_f16_aligned_128x64_k128_sm70);
134
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128, true>(), fmha_cutlassB_f16_aligned_64x64_k128_seqaligned_sm70);
135
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_sm70);
136
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 128, 64, 65536>(), fmha_cutlassB_f16_aligned_128x64_k65536_sm70);
137
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_sm70);
138
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm70);
139
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm70);
140
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 128>(), fmha_cutlassB_f16_aligned_128x64_k128_dropout_sm70);
141
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm70);
142
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 128, 64, 65536>(), fmha_cutlassB_f16_aligned_128x64_k65536_dropout_sm70);
143
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm70);
144
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 32>(), fmha_cutlassB_f16_notaligned_64x64_k32_sm70);
145
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 64>(), fmha_cutlassB_f16_notaligned_64x64_k64_sm70);
146
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 128>(), fmha_cutlassB_f16_notaligned_128x64_k128_sm70);
147
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 128>(), fmha_cutlassB_f16_notaligned_64x64_k128_sm70);
148
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 128, 64, 65536>(), fmha_cutlassB_f16_notaligned_128x64_k65536_sm70);
149
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, false, false, 64, 64, 65536>(), fmha_cutlassB_f16_notaligned_64x64_k65536_sm70);
150
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 32>(), fmha_cutlassB_f16_notaligned_64x64_k32_dropout_sm70);
151
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 64>(), fmha_cutlassB_f16_notaligned_64x64_k64_dropout_sm70);
152
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 128>(), fmha_cutlassB_f16_notaligned_128x64_k128_dropout_sm70);
153
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 128>(), fmha_cutlassB_f16_notaligned_64x64_k128_dropout_sm70);
154
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 128, 64, 65536>(), fmha_cutlassB_f16_notaligned_128x64_k65536_dropout_sm70);
155
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, cutlass::half_t, false, true, false, 64, 64, 65536>(), fmha_cutlassB_f16_notaligned_64x64_k65536_dropout_sm70);
156
+ }
157
+
158
+ // ======== bf16 / sm80 ========
159
+ __global__ void __launch_bounds__(
160
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32, true>::kNumThreads,
161
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32, true>::kMinBlocksPerSm)
162
+ fmha_cutlassB_bf16_aligned_64x64_k32_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32, true>::Params p);
163
+ __global__ void __launch_bounds__(
164
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32>::kNumThreads,
165
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32>::kMinBlocksPerSm)
166
+ fmha_cutlassB_bf16_aligned_64x64_k32_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32>::Params p);
167
+ __global__ void __launch_bounds__(
168
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64, true>::kNumThreads,
169
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64, true>::kMinBlocksPerSm)
170
+ fmha_cutlassB_bf16_aligned_64x64_k64_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64, true>::Params p);
171
+ __global__ void __launch_bounds__(
172
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64>::kNumThreads,
173
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64>::kMinBlocksPerSm)
174
+ fmha_cutlassB_bf16_aligned_64x64_k64_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64>::Params p);
175
+ __global__ void __launch_bounds__(
176
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 64, 96>::kNumThreads,
177
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 64, 96>::kMinBlocksPerSm)
178
+ fmha_cutlassB_bf16_aligned_128x64_k96_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 64, 96>::Params p);
179
+ __global__ void __launch_bounds__(
180
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128, true>::kNumThreads,
181
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128, true>::kMinBlocksPerSm)
182
+ fmha_cutlassB_bf16_aligned_128x128_k128_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128, true>::Params p);
183
+ __global__ void __launch_bounds__(
184
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128>::kNumThreads,
185
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128>::kMinBlocksPerSm)
186
+ fmha_cutlassB_bf16_aligned_128x128_k128_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128>::Params p);
187
+ __global__ void __launch_bounds__(
188
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128, true>::kNumThreads,
189
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128, true>::kMinBlocksPerSm)
190
+ fmha_cutlassB_bf16_aligned_64x64_k128_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128, true>::Params p);
191
+ __global__ void __launch_bounds__(
192
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128>::kNumThreads,
193
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
194
+ fmha_cutlassB_bf16_aligned_64x64_k128_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128>::Params p);
195
+ __global__ void __launch_bounds__(
196
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 128, 64, 65536>::kNumThreads,
197
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 128, 64, 65536>::kMinBlocksPerSm)
198
+ fmha_cutlassB_bf16_aligned_128x64_k65536_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 128, 64, 65536>::Params p);
199
+ __global__ void __launch_bounds__(
200
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 65536>::kNumThreads,
201
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
202
+ fmha_cutlassB_bf16_aligned_64x64_k65536_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 65536>::Params p);
203
+ __global__ void __launch_bounds__(
204
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 32>::kNumThreads,
205
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 32>::kMinBlocksPerSm)
206
+ fmha_cutlassB_bf16_aligned_64x64_k32_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 32>::Params p);
207
+ __global__ void __launch_bounds__(
208
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 64>::kNumThreads,
209
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 64>::kMinBlocksPerSm)
210
+ fmha_cutlassB_bf16_aligned_64x64_k64_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 64>::Params p);
211
+ __global__ void __launch_bounds__(
212
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 128, 128, 128>::kNumThreads,
213
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 128, 128, 128>::kMinBlocksPerSm)
214
+ fmha_cutlassB_bf16_aligned_128x128_k128_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 128, 128, 128>::Params p);
215
+ __global__ void __launch_bounds__(
216
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 128>::kNumThreads,
217
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
218
+ fmha_cutlassB_bf16_aligned_64x64_k128_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 128>::Params p);
219
+ __global__ void __launch_bounds__(
220
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 128, 64, 65536>::kNumThreads,
221
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 128, 64, 65536>::kMinBlocksPerSm)
222
+ fmha_cutlassB_bf16_aligned_128x64_k65536_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 128, 64, 65536>::Params p);
223
+ __global__ void __launch_bounds__(
224
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 65536>::kNumThreads,
225
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
226
+ fmha_cutlassB_bf16_aligned_64x64_k65536_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 65536>::Params p);
227
+
228
+ template <typename T> void dispatch_cutlassB_bf16_sm80(T cb, int cc) {
229
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32, true>(), fmha_cutlassB_bf16_aligned_64x64_k32_seqaligned_sm80);
230
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 32>(), fmha_cutlassB_bf16_aligned_64x64_k32_sm80);
231
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64, true>(), fmha_cutlassB_bf16_aligned_64x64_k64_seqaligned_sm80);
232
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 64, 64, 64>(), fmha_cutlassB_bf16_aligned_64x64_k64_sm80);
233
+ if (cc == 86 || cc == 89) cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 64, 96>(), fmha_cutlassB_bf16_aligned_128x64_k96_sm80);
234
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128, true>(), fmha_cutlassB_bf16_aligned_128x128_k128_seqaligned_sm80);
235
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, true, 128, 128, 128>(), fmha_cutlassB_bf16_aligned_128x128_k128_sm80);
236
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128, true>(), fmha_cutlassB_bf16_aligned_64x64_k128_seqaligned_sm80);
237
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 128>(), fmha_cutlassB_bf16_aligned_64x64_k128_sm80);
238
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 128, 64, 65536>(), fmha_cutlassB_bf16_aligned_128x64_k65536_sm80);
239
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, false, false, 64, 64, 65536>(), fmha_cutlassB_bf16_aligned_64x64_k65536_sm80);
240
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 32>(), fmha_cutlassB_bf16_aligned_64x64_k32_dropout_sm80);
241
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 64, 64, 64>(), fmha_cutlassB_bf16_aligned_64x64_k64_dropout_sm80);
242
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, true, 128, 128, 128>(), fmha_cutlassB_bf16_aligned_128x128_k128_dropout_sm80);
243
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 128>(), fmha_cutlassB_bf16_aligned_64x64_k128_dropout_sm80);
244
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 128, 64, 65536>(), fmha_cutlassB_bf16_aligned_128x64_k65536_dropout_sm80);
245
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::bfloat16_t, true, true, false, 64, 64, 65536>(), fmha_cutlassB_bf16_aligned_64x64_k65536_dropout_sm80);
246
+ }
247
+
248
+ // ======== f16 / sm80 ========
249
+ __global__ void __launch_bounds__(
250
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32, true>::kNumThreads,
251
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32, true>::kMinBlocksPerSm)
252
+ fmha_cutlassB_f16_aligned_64x64_k32_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32, true>::Params p);
253
+ __global__ void __launch_bounds__(
254
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32>::kNumThreads,
255
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32>::kMinBlocksPerSm)
256
+ fmha_cutlassB_f16_aligned_64x64_k32_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32>::Params p);
257
+ __global__ void __launch_bounds__(
258
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64, true>::kNumThreads,
259
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64, true>::kMinBlocksPerSm)
260
+ fmha_cutlassB_f16_aligned_64x64_k64_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64, true>::Params p);
261
+ __global__ void __launch_bounds__(
262
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64>::kNumThreads,
263
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64>::kMinBlocksPerSm)
264
+ fmha_cutlassB_f16_aligned_64x64_k64_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64>::Params p);
265
+ __global__ void __launch_bounds__(
266
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 64, 96>::kNumThreads,
267
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 64, 96>::kMinBlocksPerSm)
268
+ fmha_cutlassB_f16_aligned_128x64_k96_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 64, 96>::Params p);
269
+ __global__ void __launch_bounds__(
270
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128, true>::kNumThreads,
271
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128, true>::kMinBlocksPerSm)
272
+ fmha_cutlassB_f16_aligned_128x128_k128_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128, true>::Params p);
273
+ __global__ void __launch_bounds__(
274
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128>::kNumThreads,
275
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128>::kMinBlocksPerSm)
276
+ fmha_cutlassB_f16_aligned_128x128_k128_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128>::Params p);
277
+ __global__ void __launch_bounds__(
278
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128, true>::kNumThreads,
279
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128, true>::kMinBlocksPerSm)
280
+ fmha_cutlassB_f16_aligned_64x64_k128_seqaligned_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128, true>::Params p);
281
+ __global__ void __launch_bounds__(
282
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128>::kNumThreads,
283
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
284
+ fmha_cutlassB_f16_aligned_64x64_k128_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128>::Params p);
285
+ __global__ void __launch_bounds__(
286
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 128, 64, 65536>::kNumThreads,
287
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 128, 64, 65536>::kMinBlocksPerSm)
288
+ fmha_cutlassB_f16_aligned_128x64_k65536_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 128, 64, 65536>::Params p);
289
+ __global__ void __launch_bounds__(
290
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 65536>::kNumThreads,
291
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
292
+ fmha_cutlassB_f16_aligned_64x64_k65536_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 65536>::Params p);
293
+ __global__ void __launch_bounds__(
294
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 32>::kNumThreads,
295
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 32>::kMinBlocksPerSm)
296
+ fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 32>::Params p);
297
+ __global__ void __launch_bounds__(
298
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 64>::kNumThreads,
299
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 64>::kMinBlocksPerSm)
300
+ fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 64>::Params p);
301
+ __global__ void __launch_bounds__(
302
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 128, 128, 128>::kNumThreads,
303
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 128, 128, 128>::kMinBlocksPerSm)
304
+ fmha_cutlassB_f16_aligned_128x128_k128_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 128, 128, 128>::Params p);
305
+ __global__ void __launch_bounds__(
306
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 128>::kNumThreads,
307
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
308
+ fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 128>::Params p);
309
+ __global__ void __launch_bounds__(
310
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 128, 64, 65536>::kNumThreads,
311
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 128, 64, 65536>::kMinBlocksPerSm)
312
+ fmha_cutlassB_f16_aligned_128x64_k65536_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 128, 64, 65536>::Params p);
313
+ __global__ void __launch_bounds__(
314
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 65536>::kNumThreads,
315
+ AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
316
+ fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 65536>::Params p);
317
+
318
+ template <typename T> void dispatch_cutlassB_f16_sm80(T cb, int cc) {
319
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32, true>(), fmha_cutlassB_f16_aligned_64x64_k32_seqaligned_sm80);
320
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_sm80);
321
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64, true>(), fmha_cutlassB_f16_aligned_64x64_k64_seqaligned_sm80);
322
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_sm80);
323
+ if (cc == 86 || cc == 89) cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 64, 96>(), fmha_cutlassB_f16_aligned_128x64_k96_sm80);
324
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128, true>(), fmha_cutlassB_f16_aligned_128x128_k128_seqaligned_sm80);
325
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, true, 128, 128, 128>(), fmha_cutlassB_f16_aligned_128x128_k128_sm80);
326
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128, true>(), fmha_cutlassB_f16_aligned_64x64_k128_seqaligned_sm80);
327
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_sm80);
328
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 128, 64, 65536>(), fmha_cutlassB_f16_aligned_128x64_k65536_sm80);
329
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_sm80);
330
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm80);
331
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm80);
332
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, true, 128, 128, 128>(), fmha_cutlassB_f16_aligned_128x128_k128_dropout_sm80);
333
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm80);
334
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 128, 64, 65536>(), fmha_cutlassB_f16_aligned_128x64_k65536_dropout_sm80);
335
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, cutlass::half_t, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm80);
336
+ }
337
+
338
+ // ======== f16 / sm50 ========
339
+ __global__ void __launch_bounds__(
340
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 32>::kNumThreads,
341
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 32>::kMinBlocksPerSm)
342
+ fmha_cutlassB_f16_aligned_64x64_k32_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 32>::Params p);
343
+ __global__ void __launch_bounds__(
344
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 64>::kNumThreads,
345
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 64>::kMinBlocksPerSm)
346
+ fmha_cutlassB_f16_aligned_64x64_k64_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 64>::Params p);
347
+ __global__ void __launch_bounds__(
348
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 128>::kNumThreads,
349
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
350
+ fmha_cutlassB_f16_aligned_64x64_k128_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 128>::Params p);
351
+ __global__ void __launch_bounds__(
352
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 65536>::kNumThreads,
353
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
354
+ fmha_cutlassB_f16_aligned_64x64_k65536_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 65536>::Params p);
355
+ __global__ void __launch_bounds__(
356
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 32>::kNumThreads,
357
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 32>::kMinBlocksPerSm)
358
+ fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 32>::Params p);
359
+ __global__ void __launch_bounds__(
360
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 64>::kNumThreads,
361
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 64>::kMinBlocksPerSm)
362
+ fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 64>::Params p);
363
+ __global__ void __launch_bounds__(
364
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 128>::kNumThreads,
365
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
366
+ fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 128>::Params p);
367
+ __global__ void __launch_bounds__(
368
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 65536>::kNumThreads,
369
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
370
+ fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 65536>::Params p);
371
+ __global__ void __launch_bounds__(
372
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 32>::kNumThreads,
373
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 32>::kMinBlocksPerSm)
374
+ fmha_cutlassB_f16_notaligned_64x64_k32_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 32>::Params p);
375
+ __global__ void __launch_bounds__(
376
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 64>::kNumThreads,
377
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 64>::kMinBlocksPerSm)
378
+ fmha_cutlassB_f16_notaligned_64x64_k64_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 64>::Params p);
379
+ __global__ void __launch_bounds__(
380
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 128>::kNumThreads,
381
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 128>::kMinBlocksPerSm)
382
+ fmha_cutlassB_f16_notaligned_64x64_k128_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 128>::Params p);
383
+ __global__ void __launch_bounds__(
384
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 65536>::kNumThreads,
385
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 65536>::kMinBlocksPerSm)
386
+ fmha_cutlassB_f16_notaligned_64x64_k65536_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 65536>::Params p);
387
+ __global__ void __launch_bounds__(
388
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 32>::kNumThreads,
389
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 32>::kMinBlocksPerSm)
390
+ fmha_cutlassB_f16_notaligned_64x64_k32_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 32>::Params p);
391
+ __global__ void __launch_bounds__(
392
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 64>::kNumThreads,
393
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 64>::kMinBlocksPerSm)
394
+ fmha_cutlassB_f16_notaligned_64x64_k64_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 64>::Params p);
395
+ __global__ void __launch_bounds__(
396
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 128>::kNumThreads,
397
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 128>::kMinBlocksPerSm)
398
+ fmha_cutlassB_f16_notaligned_64x64_k128_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 128>::Params p);
399
+ __global__ void __launch_bounds__(
400
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 65536>::kNumThreads,
401
+ AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 65536>::kMinBlocksPerSm)
402
+ fmha_cutlassB_f16_notaligned_64x64_k65536_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 65536>::Params p);
403
+
404
+ template <typename T> void dispatch_cutlassB_f16_sm50(T cb, int cc) {
405
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_sm50);
406
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_sm50);
407
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_sm50);
408
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_sm50);
409
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm50);
410
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm50);
411
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm50);
412
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm50);
413
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 32>(), fmha_cutlassB_f16_notaligned_64x64_k32_sm50);
414
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 64>(), fmha_cutlassB_f16_notaligned_64x64_k64_sm50);
415
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 128>(), fmha_cutlassB_f16_notaligned_64x64_k128_sm50);
416
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, false, false, 64, 64, 65536>(), fmha_cutlassB_f16_notaligned_64x64_k65536_sm50);
417
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 32>(), fmha_cutlassB_f16_notaligned_64x64_k32_dropout_sm50);
418
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 64>(), fmha_cutlassB_f16_notaligned_64x64_k64_dropout_sm50);
419
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 128>(), fmha_cutlassB_f16_notaligned_64x64_k128_dropout_sm50);
420
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, cutlass::half_t, false, true, false, 64, 64, 65536>(), fmha_cutlassB_f16_notaligned_64x64_k65536_dropout_sm50);
421
+ }
422
+
423
+ // ======== f32 / sm50 ========
424
+ __global__ void __launch_bounds__(
425
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 32>::kNumThreads,
426
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 32>::kMinBlocksPerSm)
427
+ fmha_cutlassB_f32_aligned_64x64_k32_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 32>::Params p);
428
+ __global__ void __launch_bounds__(
429
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 64>::kNumThreads,
430
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 64>::kMinBlocksPerSm)
431
+ fmha_cutlassB_f32_aligned_64x64_k64_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 64>::Params p);
432
+ __global__ void __launch_bounds__(
433
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 128>::kNumThreads,
434
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
435
+ fmha_cutlassB_f32_aligned_64x64_k128_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 128>::Params p);
436
+ __global__ void __launch_bounds__(
437
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 65536>::kNumThreads,
438
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
439
+ fmha_cutlassB_f32_aligned_64x64_k65536_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 65536>::Params p);
440
+ #if defined(CUDA_VERSION) && CUDA_VERSION == 12040 && !defined(USE_ROCM)
441
+ __global__ void __launch_bounds__(
442
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 32>::kNumThreads,
443
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 32>::kMinBlocksPerSm)
444
+ fmha_cutlassB_f32_aligned_32x32_k32_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 32>::Params p);
445
+ __global__ void __launch_bounds__(
446
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 64>::kNumThreads,
447
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 64>::kMinBlocksPerSm)
448
+ fmha_cutlassB_f32_aligned_32x32_k64_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 64>::Params p);
449
+ #else
450
+ __global__ void __launch_bounds__(
451
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 32>::kNumThreads,
452
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 32>::kMinBlocksPerSm)
453
+ fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 32>::Params p);
454
+ __global__ void __launch_bounds__(
455
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 64>::kNumThreads,
456
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 64>::kMinBlocksPerSm)
457
+ fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 64>::Params p);
458
+ #endif
459
+ __global__ void __launch_bounds__(
460
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 128>::kNumThreads,
461
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
462
+ fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 128>::Params p);
463
+ __global__ void __launch_bounds__(
464
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 65536>::kNumThreads,
465
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
466
+ fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 65536>::Params p);
467
+ __global__ void __launch_bounds__(
468
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 32>::kNumThreads,
469
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 32>::kMinBlocksPerSm)
470
+ fmha_cutlassB_f32_notaligned_64x64_k32_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 32>::Params p);
471
+ __global__ void __launch_bounds__(
472
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 64>::kNumThreads,
473
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 64>::kMinBlocksPerSm)
474
+ fmha_cutlassB_f32_notaligned_64x64_k64_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 64>::Params p);
475
+ __global__ void __launch_bounds__(
476
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 128>::kNumThreads,
477
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 128>::kMinBlocksPerSm)
478
+ fmha_cutlassB_f32_notaligned_64x64_k128_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 128>::Params p);
479
+ __global__ void __launch_bounds__(
480
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 65536>::kNumThreads,
481
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 65536>::kMinBlocksPerSm)
482
+ fmha_cutlassB_f32_notaligned_64x64_k65536_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 65536>::Params p);
483
+ __global__ void __launch_bounds__(
484
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 32>::kNumThreads,
485
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 32>::kMinBlocksPerSm)
486
+ fmha_cutlassB_f32_notaligned_64x64_k32_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 32>::Params p);
487
+ __global__ void __launch_bounds__(
488
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 64>::kNumThreads,
489
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 64>::kMinBlocksPerSm)
490
+ fmha_cutlassB_f32_notaligned_64x64_k64_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 64>::Params p);
491
+ __global__ void __launch_bounds__(
492
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 128>::kNumThreads,
493
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 128>::kMinBlocksPerSm)
494
+ fmha_cutlassB_f32_notaligned_64x64_k128_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 128>::Params p);
495
+ __global__ void __launch_bounds__(
496
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 65536>::kNumThreads,
497
+ AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 65536>::kMinBlocksPerSm)
498
+ fmha_cutlassB_f32_notaligned_64x64_k65536_dropout_sm50(typename AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 65536>::Params p);
499
+
500
+ template <typename T> void dispatch_cutlassB_f32_sm50(T cb, int cc) {
501
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_sm50);
502
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_sm50);
503
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_sm50);
504
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_sm50);
505
+ #if defined(CUDA_VERSION) && CUDA_VERSION == 12040 && !defined(USE_ROCM)
506
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 32>(), fmha_cutlassB_f32_aligned_32x32_k32_dropout_sm50);
507
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 32, 32, 64>(), fmha_cutlassB_f32_aligned_32x32_k64_dropout_sm50);
508
+ #else
509
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm50);
510
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm50);
511
+ #endif
512
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm50);
513
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm50);
514
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 32>(), fmha_cutlassB_f32_notaligned_64x64_k32_sm50);
515
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 64>(), fmha_cutlassB_f32_notaligned_64x64_k64_sm50);
516
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 128>(), fmha_cutlassB_f32_notaligned_64x64_k128_sm50);
517
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, false, false, 64, 64, 65536>(), fmha_cutlassB_f32_notaligned_64x64_k65536_sm50);
518
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 32>(), fmha_cutlassB_f32_notaligned_64x64_k32_dropout_sm50);
519
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 64>(), fmha_cutlassB_f32_notaligned_64x64_k64_dropout_sm50);
520
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 128>(), fmha_cutlassB_f32_notaligned_64x64_k128_dropout_sm50);
521
+ cb(AttentionBackwardKernel<cutlass::arch::Sm50, float, false, true, false, 64, 64, 65536>(), fmha_cutlassB_f32_notaligned_64x64_k65536_dropout_sm50);
522
+ }
523
+
524
+ // ======== f32 / sm70 ========
525
+ __global__ void __launch_bounds__(
526
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 32>::kNumThreads,
527
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 32>::kMinBlocksPerSm)
528
+ fmha_cutlassB_f32_aligned_64x64_k32_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 32>::Params p);
529
+ __global__ void __launch_bounds__(
530
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 64>::kNumThreads,
531
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 64>::kMinBlocksPerSm)
532
+ fmha_cutlassB_f32_aligned_64x64_k64_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 64>::Params p);
533
+ __global__ void __launch_bounds__(
534
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 128>::kNumThreads,
535
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
536
+ fmha_cutlassB_f32_aligned_64x64_k128_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 128>::Params p);
537
+ __global__ void __launch_bounds__(
538
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 65536>::kNumThreads,
539
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
540
+ fmha_cutlassB_f32_aligned_64x64_k65536_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 65536>::Params p);
541
+ __global__ void __launch_bounds__(
542
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 32>::kNumThreads,
543
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 32>::kMinBlocksPerSm)
544
+ fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 32>::Params p);
545
+ __global__ void __launch_bounds__(
546
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 64>::kNumThreads,
547
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 64>::kMinBlocksPerSm)
548
+ fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 64>::Params p);
549
+ __global__ void __launch_bounds__(
550
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 128>::kNumThreads,
551
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
552
+ fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 128>::Params p);
553
+ __global__ void __launch_bounds__(
554
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 65536>::kNumThreads,
555
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
556
+ fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 65536>::Params p);
557
+ __global__ void __launch_bounds__(
558
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 32>::kNumThreads,
559
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 32>::kMinBlocksPerSm)
560
+ fmha_cutlassB_f32_notaligned_64x64_k32_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 32>::Params p);
561
+ __global__ void __launch_bounds__(
562
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 64>::kNumThreads,
563
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 64>::kMinBlocksPerSm)
564
+ fmha_cutlassB_f32_notaligned_64x64_k64_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 64>::Params p);
565
+ __global__ void __launch_bounds__(
566
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 128>::kNumThreads,
567
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 128>::kMinBlocksPerSm)
568
+ fmha_cutlassB_f32_notaligned_64x64_k128_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 128>::Params p);
569
+ __global__ void __launch_bounds__(
570
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 65536>::kNumThreads,
571
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 65536>::kMinBlocksPerSm)
572
+ fmha_cutlassB_f32_notaligned_64x64_k65536_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 65536>::Params p);
573
+ __global__ void __launch_bounds__(
574
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 32>::kNumThreads,
575
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 32>::kMinBlocksPerSm)
576
+ fmha_cutlassB_f32_notaligned_64x64_k32_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 32>::Params p);
577
+ __global__ void __launch_bounds__(
578
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 64>::kNumThreads,
579
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 64>::kMinBlocksPerSm)
580
+ fmha_cutlassB_f32_notaligned_64x64_k64_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 64>::Params p);
581
+ __global__ void __launch_bounds__(
582
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 128>::kNumThreads,
583
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 128>::kMinBlocksPerSm)
584
+ fmha_cutlassB_f32_notaligned_64x64_k128_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 128>::Params p);
585
+ __global__ void __launch_bounds__(
586
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 65536>::kNumThreads,
587
+ AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 65536>::kMinBlocksPerSm)
588
+ fmha_cutlassB_f32_notaligned_64x64_k65536_dropout_sm70(typename AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 65536>::Params p);
589
+
590
+ template <typename T> void dispatch_cutlassB_f32_sm70(T cb, int cc) {
591
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_sm70);
592
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_sm70);
593
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_sm70);
594
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_sm70);
595
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm70);
596
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm70);
597
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm70);
598
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm70);
599
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 32>(), fmha_cutlassB_f32_notaligned_64x64_k32_sm70);
600
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 64>(), fmha_cutlassB_f32_notaligned_64x64_k64_sm70);
601
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 128>(), fmha_cutlassB_f32_notaligned_64x64_k128_sm70);
602
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, false, false, 64, 64, 65536>(), fmha_cutlassB_f32_notaligned_64x64_k65536_sm70);
603
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 32>(), fmha_cutlassB_f32_notaligned_64x64_k32_dropout_sm70);
604
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 64>(), fmha_cutlassB_f32_notaligned_64x64_k64_dropout_sm70);
605
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 128>(), fmha_cutlassB_f32_notaligned_64x64_k128_dropout_sm70);
606
+ cb(AttentionBackwardKernel<cutlass::arch::Sm70, float, false, true, false, 64, 64, 65536>(), fmha_cutlassB_f32_notaligned_64x64_k65536_dropout_sm70);
607
+ }
608
+
609
+ // ======== f16 / sm75 ========
610
+ __global__ void __launch_bounds__(
611
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 32>::kNumThreads,
612
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 32>::kMinBlocksPerSm)
613
+ fmha_cutlassB_f16_aligned_64x64_k32_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 32>::Params p);
614
+ __global__ void __launch_bounds__(
615
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 64>::kNumThreads,
616
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 64>::kMinBlocksPerSm)
617
+ fmha_cutlassB_f16_aligned_64x64_k64_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 64>::Params p);
618
+ __global__ void __launch_bounds__(
619
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 128>::kNumThreads,
620
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 128>::kMinBlocksPerSm)
621
+ fmha_cutlassB_f16_aligned_128x64_k128_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 128>::Params p);
622
+ __global__ void __launch_bounds__(
623
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 128>::kNumThreads,
624
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
625
+ fmha_cutlassB_f16_aligned_64x64_k128_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 128>::Params p);
626
+ __global__ void __launch_bounds__(
627
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 65536>::kNumThreads,
628
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 65536>::kMinBlocksPerSm)
629
+ fmha_cutlassB_f16_aligned_128x64_k65536_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 65536>::Params p);
630
+ __global__ void __launch_bounds__(
631
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 65536>::kNumThreads,
632
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
633
+ fmha_cutlassB_f16_aligned_64x64_k65536_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 65536>::Params p);
634
+ __global__ void __launch_bounds__(
635
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 32>::kNumThreads,
636
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 32>::kMinBlocksPerSm)
637
+ fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 32>::Params p);
638
+ __global__ void __launch_bounds__(
639
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 64>::kNumThreads,
640
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 64>::kMinBlocksPerSm)
641
+ fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 64>::Params p);
642
+ __global__ void __launch_bounds__(
643
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 128>::kNumThreads,
644
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 128>::kMinBlocksPerSm)
645
+ fmha_cutlassB_f16_aligned_128x64_k128_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 128>::Params p);
646
+ __global__ void __launch_bounds__(
647
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 128>::kNumThreads,
648
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
649
+ fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 128>::Params p);
650
+ __global__ void __launch_bounds__(
651
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 65536>::kNumThreads,
652
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 65536>::kMinBlocksPerSm)
653
+ fmha_cutlassB_f16_aligned_128x64_k65536_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 65536>::Params p);
654
+ __global__ void __launch_bounds__(
655
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 65536>::kNumThreads,
656
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
657
+ fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 65536>::Params p);
658
+ __global__ void __launch_bounds__(
659
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 32>::kNumThreads,
660
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 32>::kMinBlocksPerSm)
661
+ fmha_cutlassB_f16_notaligned_64x64_k32_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 32>::Params p);
662
+ __global__ void __launch_bounds__(
663
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 64>::kNumThreads,
664
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 64>::kMinBlocksPerSm)
665
+ fmha_cutlassB_f16_notaligned_64x64_k64_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 64>::Params p);
666
+ __global__ void __launch_bounds__(
667
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 128>::kNumThreads,
668
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 128>::kMinBlocksPerSm)
669
+ fmha_cutlassB_f16_notaligned_128x64_k128_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 128>::Params p);
670
+ __global__ void __launch_bounds__(
671
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 128>::kNumThreads,
672
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 128>::kMinBlocksPerSm)
673
+ fmha_cutlassB_f16_notaligned_64x64_k128_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 128>::Params p);
674
+ __global__ void __launch_bounds__(
675
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 65536>::kNumThreads,
676
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 65536>::kMinBlocksPerSm)
677
+ fmha_cutlassB_f16_notaligned_128x64_k65536_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 65536>::Params p);
678
+ __global__ void __launch_bounds__(
679
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 65536>::kNumThreads,
680
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 65536>::kMinBlocksPerSm)
681
+ fmha_cutlassB_f16_notaligned_64x64_k65536_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 65536>::Params p);
682
+ __global__ void __launch_bounds__(
683
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 32>::kNumThreads,
684
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 32>::kMinBlocksPerSm)
685
+ fmha_cutlassB_f16_notaligned_64x64_k32_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 32>::Params p);
686
+ __global__ void __launch_bounds__(
687
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 64>::kNumThreads,
688
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 64>::kMinBlocksPerSm)
689
+ fmha_cutlassB_f16_notaligned_64x64_k64_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 64>::Params p);
690
+ __global__ void __launch_bounds__(
691
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 128>::kNumThreads,
692
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 128>::kMinBlocksPerSm)
693
+ fmha_cutlassB_f16_notaligned_128x64_k128_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 128>::Params p);
694
+ __global__ void __launch_bounds__(
695
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 128>::kNumThreads,
696
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 128>::kMinBlocksPerSm)
697
+ fmha_cutlassB_f16_notaligned_64x64_k128_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 128>::Params p);
698
+ __global__ void __launch_bounds__(
699
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 65536>::kNumThreads,
700
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 65536>::kMinBlocksPerSm)
701
+ fmha_cutlassB_f16_notaligned_128x64_k65536_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 65536>::Params p);
702
+ __global__ void __launch_bounds__(
703
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 65536>::kNumThreads,
704
+ AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 65536>::kMinBlocksPerSm)
705
+ fmha_cutlassB_f16_notaligned_64x64_k65536_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 65536>::Params p);
706
+
707
+ template <typename T> void dispatch_cutlassB_f16_sm75(T cb, int cc) {
708
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_sm75);
709
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_sm75);
710
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 128>(), fmha_cutlassB_f16_aligned_128x64_k128_sm75);
711
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_sm75);
712
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 128, 64, 65536>(), fmha_cutlassB_f16_aligned_128x64_k65536_sm75);
713
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_sm75);
714
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 32>(), fmha_cutlassB_f16_aligned_64x64_k32_dropout_sm75);
715
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 64>(), fmha_cutlassB_f16_aligned_64x64_k64_dropout_sm75);
716
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 128>(), fmha_cutlassB_f16_aligned_128x64_k128_dropout_sm75);
717
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 128>(), fmha_cutlassB_f16_aligned_64x64_k128_dropout_sm75);
718
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 128, 64, 65536>(), fmha_cutlassB_f16_aligned_128x64_k65536_dropout_sm75);
719
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f16_aligned_64x64_k65536_dropout_sm75);
720
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 32>(), fmha_cutlassB_f16_notaligned_64x64_k32_sm75);
721
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 64>(), fmha_cutlassB_f16_notaligned_64x64_k64_sm75);
722
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 128>(), fmha_cutlassB_f16_notaligned_128x64_k128_sm75);
723
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 128>(), fmha_cutlassB_f16_notaligned_64x64_k128_sm75);
724
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 128, 64, 65536>(), fmha_cutlassB_f16_notaligned_128x64_k65536_sm75);
725
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, false, false, 64, 64, 65536>(), fmha_cutlassB_f16_notaligned_64x64_k65536_sm75);
726
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 32>(), fmha_cutlassB_f16_notaligned_64x64_k32_dropout_sm75);
727
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 64>(), fmha_cutlassB_f16_notaligned_64x64_k64_dropout_sm75);
728
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 128>(), fmha_cutlassB_f16_notaligned_128x64_k128_dropout_sm75);
729
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 128>(), fmha_cutlassB_f16_notaligned_64x64_k128_dropout_sm75);
730
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 128, 64, 65536>(), fmha_cutlassB_f16_notaligned_128x64_k65536_dropout_sm75);
731
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, cutlass::half_t, false, true, false, 64, 64, 65536>(), fmha_cutlassB_f16_notaligned_64x64_k65536_dropout_sm75);
732
+ }
733
+
734
+ // ======== f32 / sm75 ========
735
+ __global__ void __launch_bounds__(
736
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 32>::kNumThreads,
737
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 32>::kMinBlocksPerSm)
738
+ fmha_cutlassB_f32_aligned_64x64_k32_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 32>::Params p);
739
+ __global__ void __launch_bounds__(
740
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 64>::kNumThreads,
741
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 64>::kMinBlocksPerSm)
742
+ fmha_cutlassB_f32_aligned_64x64_k64_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 64>::Params p);
743
+ __global__ void __launch_bounds__(
744
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 128>::kNumThreads,
745
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
746
+ fmha_cutlassB_f32_aligned_64x64_k128_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 128>::Params p);
747
+ __global__ void __launch_bounds__(
748
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 65536>::kNumThreads,
749
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
750
+ fmha_cutlassB_f32_aligned_64x64_k65536_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 65536>::Params p);
751
+ __global__ void __launch_bounds__(
752
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 32>::kNumThreads,
753
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 32>::kMinBlocksPerSm)
754
+ fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 32>::Params p);
755
+ __global__ void __launch_bounds__(
756
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 64>::kNumThreads,
757
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 64>::kMinBlocksPerSm)
758
+ fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 64>::Params p);
759
+ __global__ void __launch_bounds__(
760
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 128>::kNumThreads,
761
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
762
+ fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 128>::Params p);
763
+ __global__ void __launch_bounds__(
764
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 65536>::kNumThreads,
765
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
766
+ fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 65536>::Params p);
767
+ __global__ void __launch_bounds__(
768
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 32>::kNumThreads,
769
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 32>::kMinBlocksPerSm)
770
+ fmha_cutlassB_f32_notaligned_64x64_k32_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 32>::Params p);
771
+ __global__ void __launch_bounds__(
772
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 64>::kNumThreads,
773
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 64>::kMinBlocksPerSm)
774
+ fmha_cutlassB_f32_notaligned_64x64_k64_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 64>::Params p);
775
+ __global__ void __launch_bounds__(
776
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 128>::kNumThreads,
777
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 128>::kMinBlocksPerSm)
778
+ fmha_cutlassB_f32_notaligned_64x64_k128_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 128>::Params p);
779
+ __global__ void __launch_bounds__(
780
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 65536>::kNumThreads,
781
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 65536>::kMinBlocksPerSm)
782
+ fmha_cutlassB_f32_notaligned_64x64_k65536_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 65536>::Params p);
783
+ __global__ void __launch_bounds__(
784
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 32>::kNumThreads,
785
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 32>::kMinBlocksPerSm)
786
+ fmha_cutlassB_f32_notaligned_64x64_k32_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 32>::Params p);
787
+ __global__ void __launch_bounds__(
788
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 64>::kNumThreads,
789
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 64>::kMinBlocksPerSm)
790
+ fmha_cutlassB_f32_notaligned_64x64_k64_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 64>::Params p);
791
+ __global__ void __launch_bounds__(
792
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 128>::kNumThreads,
793
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 128>::kMinBlocksPerSm)
794
+ fmha_cutlassB_f32_notaligned_64x64_k128_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 128>::Params p);
795
+ __global__ void __launch_bounds__(
796
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 65536>::kNumThreads,
797
+ AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 65536>::kMinBlocksPerSm)
798
+ fmha_cutlassB_f32_notaligned_64x64_k65536_dropout_sm75(typename AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 65536>::Params p);
799
+
800
+ template <typename T> void dispatch_cutlassB_f32_sm75(T cb, int cc) {
801
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_sm75);
802
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_sm75);
803
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_sm75);
804
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_sm75);
805
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm75);
806
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm75);
807
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm75);
808
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm75);
809
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 32>(), fmha_cutlassB_f32_notaligned_64x64_k32_sm75);
810
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 64>(), fmha_cutlassB_f32_notaligned_64x64_k64_sm75);
811
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 128>(), fmha_cutlassB_f32_notaligned_64x64_k128_sm75);
812
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, false, false, 64, 64, 65536>(), fmha_cutlassB_f32_notaligned_64x64_k65536_sm75);
813
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 32>(), fmha_cutlassB_f32_notaligned_64x64_k32_dropout_sm75);
814
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 64>(), fmha_cutlassB_f32_notaligned_64x64_k64_dropout_sm75);
815
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 128>(), fmha_cutlassB_f32_notaligned_64x64_k128_dropout_sm75);
816
+ cb(AttentionBackwardKernel<cutlass::arch::Sm75, float, false, true, false, 64, 64, 65536>(), fmha_cutlassB_f32_notaligned_64x64_k65536_dropout_sm75);
817
+ }
818
+
819
+ // ======== f32 / sm80 ========
820
+ __global__ void __launch_bounds__(
821
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 32>::kNumThreads,
822
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 32>::kMinBlocksPerSm)
823
+ fmha_cutlassB_f32_aligned_64x64_k32_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 32>::Params p);
824
+ __global__ void __launch_bounds__(
825
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 64>::kNumThreads,
826
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 64>::kMinBlocksPerSm)
827
+ fmha_cutlassB_f32_aligned_64x64_k64_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 64>::Params p);
828
+ __global__ void __launch_bounds__(
829
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 128>::kNumThreads,
830
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 128>::kMinBlocksPerSm)
831
+ fmha_cutlassB_f32_aligned_128x64_k128_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 128>::Params p);
832
+ __global__ void __launch_bounds__(
833
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 128>::kNumThreads,
834
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 128>::kMinBlocksPerSm)
835
+ fmha_cutlassB_f32_aligned_64x64_k128_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 128>::Params p);
836
+ __global__ void __launch_bounds__(
837
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 65536>::kNumThreads,
838
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 65536>::kMinBlocksPerSm)
839
+ fmha_cutlassB_f32_aligned_128x64_k65536_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 65536>::Params p);
840
+ __global__ void __launch_bounds__(
841
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 65536>::kNumThreads,
842
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 65536>::kMinBlocksPerSm)
843
+ fmha_cutlassB_f32_aligned_64x64_k65536_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 65536>::Params p);
844
+ __global__ void __launch_bounds__(
845
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 32>::kNumThreads,
846
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 32>::kMinBlocksPerSm)
847
+ fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 32>::Params p);
848
+ __global__ void __launch_bounds__(
849
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 64>::kNumThreads,
850
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 64>::kMinBlocksPerSm)
851
+ fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 64>::Params p);
852
+ __global__ void __launch_bounds__(
853
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 128>::kNumThreads,
854
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 128>::kMinBlocksPerSm)
855
+ fmha_cutlassB_f32_aligned_128x64_k128_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 128>::Params p);
856
+ __global__ void __launch_bounds__(
857
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 128>::kNumThreads,
858
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 128>::kMinBlocksPerSm)
859
+ fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 128>::Params p);
860
+ __global__ void __launch_bounds__(
861
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 65536>::kNumThreads,
862
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 65536>::kMinBlocksPerSm)
863
+ fmha_cutlassB_f32_aligned_128x64_k65536_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 65536>::Params p);
864
+ __global__ void __launch_bounds__(
865
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 65536>::kNumThreads,
866
+ AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 65536>::kMinBlocksPerSm)
867
+ fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm80(typename AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 65536>::Params p);
868
+
869
+ template <typename T> void dispatch_cutlassB_f32_sm80(T cb, int cc) {
870
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_sm80);
871
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_sm80);
872
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 128>(), fmha_cutlassB_f32_aligned_128x64_k128_sm80);
873
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_sm80);
874
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 128, 64, 65536>(), fmha_cutlassB_f32_aligned_128x64_k65536_sm80);
875
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, false, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_sm80);
876
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 32>(), fmha_cutlassB_f32_aligned_64x64_k32_dropout_sm80);
877
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 64>(), fmha_cutlassB_f32_aligned_64x64_k64_dropout_sm80);
878
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 128>(), fmha_cutlassB_f32_aligned_128x64_k128_dropout_sm80);
879
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 128>(), fmha_cutlassB_f32_aligned_64x64_k128_dropout_sm80);
880
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 128, 64, 65536>(), fmha_cutlassB_f32_aligned_128x64_k65536_dropout_sm80);
881
+ cb(AttentionBackwardKernel<cutlass::arch::Sm80, float, true, true, false, 64, 64, 65536>(), fmha_cutlassB_f32_aligned_64x64_k65536_dropout_sm80);
882
+ }
883
+
884
+
885
+ template <typename DT, typename T>
886
+ void dispatch_cutlassB(T cb, int cc = 0) {
887
+
888
+ if (std::is_same_v<DT, cutlass::half_t> && 70 <= cc && cc < 75) {
889
+ dispatch_cutlassB_f16_sm70(cb, cc);
890
+ }
891
+ if (std::is_same_v<DT, cutlass::bfloat16_t> && 80 <= cc && cc <= 120) {
892
+ dispatch_cutlassB_bf16_sm80(cb, cc);
893
+ }
894
+ if (std::is_same_v<DT, cutlass::half_t> && 80 <= cc && cc <= 120) {
895
+ dispatch_cutlassB_f16_sm80(cb, cc);
896
+ }
897
+ if (std::is_same_v<DT, cutlass::half_t> && 50 <= cc && cc < 70) {
898
+ dispatch_cutlassB_f16_sm50(cb, cc);
899
+ }
900
+ if (std::is_same_v<DT, float> && 50 <= cc && cc < 70) {
901
+ dispatch_cutlassB_f32_sm50(cb, cc);
902
+ }
903
+ if (std::is_same_v<DT, float> && 70 <= cc && cc < 75) {
904
+ dispatch_cutlassB_f32_sm70(cb, cc);
905
+ }
906
+ if (std::is_same_v<DT, cutlass::half_t> && 75 <= cc && cc < 80) {
907
+ dispatch_cutlassB_f16_sm75(cb, cc);
908
+ }
909
+ if (std::is_same_v<DT, float> && 75 <= cc && cc < 80) {
910
+ dispatch_cutlassB_f32_sm75(cb, cc);
911
+ }
912
+ if (std::is_same_v<DT, float> && 80 <= cc && cc <= 120) {
913
+ dispatch_cutlassB_f32_sm80(cb, cc);
914
+ }
915
+ }
916
+
917
+ #else
918
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
919
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/kernels/cutlassF.h ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ // This file is auto-generated. See "generate_kernels.py"
10
+ #pragma once
11
+ #include <ATen/native/transformers/cuda/mem_eff_attention/kernel_forward.h>
12
+ using namespace PyTorchMemEffAttention;
13
+ // ======== bf16 / sm80 ========
14
+ __global__ void __launch_bounds__(
15
+ AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::kNumThreads,
16
+ AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
17
+ fmha_cutlassF_bf16_aligned_64x64_rf_sm80(typename AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::Params p);
18
+ __global__ void __launch_bounds__(
19
+ AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::kNumThreads,
20
+ AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::kMinBlocksPerSm)
21
+ fmha_cutlassF_bf16_aligned_64x128_rf_sm80(typename AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::Params p);
22
+ __global__ void __launch_bounds__(
23
+ AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::kNumThreads,
24
+ AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
25
+ fmha_cutlassF_bf16_aligned_32x128_gmem_sm80(typename AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::Params p);
26
+
27
+ template <typename T> void dispatch_cutlassF_bf16_sm80(T cb, int cc) {
28
+ cb(AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>(), fmha_cutlassF_bf16_aligned_64x64_rf_sm80);
29
+ cb(AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>(), fmha_cutlassF_bf16_aligned_64x128_rf_sm80);
30
+ cb(AttentionKernel<cutlass::bfloat16_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>(), fmha_cutlassF_bf16_aligned_32x128_gmem_sm80);
31
+ }
32
+
33
+ // ======== f16 / sm50 ========
34
+ __global__ void __launch_bounds__(
35
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 64, 64, 64, true, true>::kNumThreads,
36
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
37
+ fmha_cutlassF_f16_aligned_64x64_rf_sm50(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 64, 64, 64, true, true>::Params p);
38
+ __global__ void __launch_bounds__(
39
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 128, true, true>::kNumThreads,
40
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 128, true, true>::kMinBlocksPerSm)
41
+ fmha_cutlassF_f16_aligned_32x128_rf_sm50(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 128, true, true>::Params p);
42
+ __global__ void __launch_bounds__(
43
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>::kNumThreads,
44
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
45
+ fmha_cutlassF_f16_aligned_32x128_gmem_sm50(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>::Params p);
46
+ __global__ void __launch_bounds__(
47
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 64, 64, 64, true, true>::kNumThreads,
48
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 64, 64, 64, true, true>::kMinBlocksPerSm)
49
+ fmha_cutlassF_f16_notaligned_64x64_rf_sm50(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 64, 64, 64, true, true>::Params p);
50
+ __global__ void __launch_bounds__(
51
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 128, true, true>::kNumThreads,
52
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 128, true, true>::kMinBlocksPerSm)
53
+ fmha_cutlassF_f16_notaligned_32x128_rf_sm50(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 128, true, true>::Params p);
54
+ __global__ void __launch_bounds__(
55
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>::kNumThreads,
56
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>::kMinBlocksPerSm)
57
+ fmha_cutlassF_f16_notaligned_32x128_gmem_sm50(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>::Params p);
58
+
59
+ template <typename T> void dispatch_cutlassF_f16_sm50(T cb, int cc) {
60
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 64, 64, 64, true, true>(), fmha_cutlassF_f16_aligned_64x64_rf_sm50);
61
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 128, true, true>(), fmha_cutlassF_f16_aligned_32x128_rf_sm50);
62
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f16_aligned_32x128_gmem_sm50);
63
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 64, 64, 64, true, true>(), fmha_cutlassF_f16_notaligned_64x64_rf_sm50);
64
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 128, true, true>(), fmha_cutlassF_f16_notaligned_32x128_rf_sm50);
65
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>(), fmha_cutlassF_f16_notaligned_32x128_gmem_sm50);
66
+ }
67
+
68
+ // ======== f16 / sm70 ========
69
+ __global__ void __launch_bounds__(
70
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 64, 64, 64, true, true>::kNumThreads,
71
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
72
+ fmha_cutlassF_f16_aligned_64x64_rf_sm70(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 64, 64, 64, true, true>::Params p);
73
+ __global__ void __launch_bounds__(
74
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 128, true, true>::kNumThreads,
75
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 128, true, true>::kMinBlocksPerSm)
76
+ fmha_cutlassF_f16_aligned_32x128_rf_sm70(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 128, true, true>::Params p);
77
+ __global__ void __launch_bounds__(
78
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>::kNumThreads,
79
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
80
+ fmha_cutlassF_f16_aligned_32x128_gmem_sm70(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>::Params p);
81
+ __global__ void __launch_bounds__(
82
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 64, 64, 64, true, true>::kNumThreads,
83
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 64, 64, 64, true, true>::kMinBlocksPerSm)
84
+ fmha_cutlassF_f16_notaligned_64x64_rf_sm70(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 64, 64, 64, true, true>::Params p);
85
+ __global__ void __launch_bounds__(
86
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 128, true, true>::kNumThreads,
87
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 128, true, true>::kMinBlocksPerSm)
88
+ fmha_cutlassF_f16_notaligned_32x128_rf_sm70(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 128, true, true>::Params p);
89
+ __global__ void __launch_bounds__(
90
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>::kNumThreads,
91
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>::kMinBlocksPerSm)
92
+ fmha_cutlassF_f16_notaligned_32x128_gmem_sm70(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>::Params p);
93
+
94
+ template <typename T> void dispatch_cutlassF_f16_sm70(T cb, int cc) {
95
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 64, 64, 64, true, true>(), fmha_cutlassF_f16_aligned_64x64_rf_sm70);
96
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 128, true, true>(), fmha_cutlassF_f16_aligned_32x128_rf_sm70);
97
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f16_aligned_32x128_gmem_sm70);
98
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 64, 64, 64, true, true>(), fmha_cutlassF_f16_notaligned_64x64_rf_sm70);
99
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 128, true, true>(), fmha_cutlassF_f16_notaligned_32x128_rf_sm70);
100
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>(), fmha_cutlassF_f16_notaligned_32x128_gmem_sm70);
101
+ }
102
+
103
+ // ======== f16 / sm75 ========
104
+ __global__ void __launch_bounds__(
105
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 64, 64, 64, true, true>::kNumThreads,
106
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
107
+ fmha_cutlassF_f16_aligned_64x64_rf_sm75(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 64, 64, 64, true, true>::Params p);
108
+ __global__ void __launch_bounds__(
109
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 128, true, true>::kNumThreads,
110
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 128, true, true>::kMinBlocksPerSm)
111
+ fmha_cutlassF_f16_aligned_32x128_rf_sm75(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 128, true, true>::Params p);
112
+ __global__ void __launch_bounds__(
113
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>::kNumThreads,
114
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
115
+ fmha_cutlassF_f16_aligned_32x128_gmem_sm75(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>::Params p);
116
+ __global__ void __launch_bounds__(
117
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 64, 64, 64, true, true>::kNumThreads,
118
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 64, 64, 64, true, true>::kMinBlocksPerSm)
119
+ fmha_cutlassF_f16_notaligned_64x64_rf_sm75(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 64, 64, 64, true, true>::Params p);
120
+ __global__ void __launch_bounds__(
121
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 128, true, true>::kNumThreads,
122
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 128, true, true>::kMinBlocksPerSm)
123
+ fmha_cutlassF_f16_notaligned_32x128_rf_sm75(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 128, true, true>::Params p);
124
+ __global__ void __launch_bounds__(
125
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>::kNumThreads,
126
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>::kMinBlocksPerSm)
127
+ fmha_cutlassF_f16_notaligned_32x128_gmem_sm75(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>::Params p);
128
+
129
+ template <typename T> void dispatch_cutlassF_f16_sm75(T cb, int cc) {
130
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 64, 64, 64, true, true>(), fmha_cutlassF_f16_aligned_64x64_rf_sm75);
131
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 128, true, true>(), fmha_cutlassF_f16_aligned_32x128_rf_sm75);
132
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f16_aligned_32x128_gmem_sm75);
133
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 64, 64, 64, true, true>(), fmha_cutlassF_f16_notaligned_64x64_rf_sm75);
134
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 128, true, true>(), fmha_cutlassF_f16_notaligned_32x128_rf_sm75);
135
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>(), fmha_cutlassF_f16_notaligned_32x128_gmem_sm75);
136
+ }
137
+
138
+ // ======== f16 / sm80 ========
139
+ __global__ void __launch_bounds__(
140
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::kNumThreads,
141
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
142
+ fmha_cutlassF_f16_aligned_64x64_rf_sm80(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::Params p);
143
+ __global__ void __launch_bounds__(
144
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::kNumThreads,
145
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::kMinBlocksPerSm)
146
+ fmha_cutlassF_f16_aligned_64x128_rf_sm80(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::Params p);
147
+ __global__ void __launch_bounds__(
148
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::kNumThreads,
149
+ AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
150
+ fmha_cutlassF_f16_aligned_32x128_gmem_sm80(typename AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::Params p);
151
+
152
+ template <typename T> void dispatch_cutlassF_f16_sm80(T cb, int cc) {
153
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 64, 64, true, true>(), fmha_cutlassF_f16_aligned_64x64_rf_sm80);
154
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 64, 128, 128, true, true>(), fmha_cutlassF_f16_aligned_64x128_rf_sm80);
155
+ cb(AttentionKernel<cutlass::half_t, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f16_aligned_32x128_gmem_sm80);
156
+ }
157
+
158
+ // ======== f32 / sm50 ========
159
+ __global__ void __launch_bounds__(
160
+ AttentionKernel<float, cutlass::arch::Sm50, true, 64, 64, 64, true, true>::kNumThreads,
161
+ AttentionKernel<float, cutlass::arch::Sm50, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
162
+ fmha_cutlassF_f32_aligned_64x64_rf_sm50(typename AttentionKernel<float, cutlass::arch::Sm50, true, 64, 64, 64, true, true>::Params p);
163
+ __global__ void __launch_bounds__(
164
+ AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 128, true, true>::kNumThreads,
165
+ AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 128, true, true>::kMinBlocksPerSm)
166
+ fmha_cutlassF_f32_aligned_32x128_rf_sm50(typename AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 128, true, true>::Params p);
167
+ __global__ void __launch_bounds__(
168
+ AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>::kNumThreads,
169
+ AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
170
+ fmha_cutlassF_f32_aligned_32x128_gmem_sm50(typename AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>::Params p);
171
+ __global__ void __launch_bounds__(
172
+ AttentionKernel<float, cutlass::arch::Sm50, false, 64, 64, 64, true, true>::kNumThreads,
173
+ AttentionKernel<float, cutlass::arch::Sm50, false, 64, 64, 64, true, true>::kMinBlocksPerSm)
174
+ fmha_cutlassF_f32_notaligned_64x64_rf_sm50(typename AttentionKernel<float, cutlass::arch::Sm50, false, 64, 64, 64, true, true>::Params p);
175
+ __global__ void __launch_bounds__(
176
+ AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 128, true, true>::kNumThreads,
177
+ AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 128, true, true>::kMinBlocksPerSm)
178
+ fmha_cutlassF_f32_notaligned_32x128_rf_sm50(typename AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 128, true, true>::Params p);
179
+ __global__ void __launch_bounds__(
180
+ AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>::kNumThreads,
181
+ AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>::kMinBlocksPerSm)
182
+ fmha_cutlassF_f32_notaligned_32x128_gmem_sm50(typename AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>::Params p);
183
+
184
+ template <typename T> void dispatch_cutlassF_f32_sm50(T cb, int cc) {
185
+ cb(AttentionKernel<float, cutlass::arch::Sm50, true, 64, 64, 64, true, true>(), fmha_cutlassF_f32_aligned_64x64_rf_sm50);
186
+ cb(AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 128, true, true>(), fmha_cutlassF_f32_aligned_32x128_rf_sm50);
187
+ cb(AttentionKernel<float, cutlass::arch::Sm50, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f32_aligned_32x128_gmem_sm50);
188
+ cb(AttentionKernel<float, cutlass::arch::Sm50, false, 64, 64, 64, true, true>(), fmha_cutlassF_f32_notaligned_64x64_rf_sm50);
189
+ cb(AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 128, true, true>(), fmha_cutlassF_f32_notaligned_32x128_rf_sm50);
190
+ cb(AttentionKernel<float, cutlass::arch::Sm50, false, 32, 128, 65536, true, true>(), fmha_cutlassF_f32_notaligned_32x128_gmem_sm50);
191
+ }
192
+
193
+ // ======== f32 / sm70 ========
194
+ __global__ void __launch_bounds__(
195
+ AttentionKernel<float, cutlass::arch::Sm70, true, 64, 64, 64, true, true>::kNumThreads,
196
+ AttentionKernel<float, cutlass::arch::Sm70, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
197
+ fmha_cutlassF_f32_aligned_64x64_rf_sm70(typename AttentionKernel<float, cutlass::arch::Sm70, true, 64, 64, 64, true, true>::Params p);
198
+ __global__ void __launch_bounds__(
199
+ AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 128, true, true>::kNumThreads,
200
+ AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 128, true, true>::kMinBlocksPerSm)
201
+ fmha_cutlassF_f32_aligned_32x128_rf_sm70(typename AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 128, true, true>::Params p);
202
+ __global__ void __launch_bounds__(
203
+ AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>::kNumThreads,
204
+ AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
205
+ fmha_cutlassF_f32_aligned_32x128_gmem_sm70(typename AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>::Params p);
206
+ __global__ void __launch_bounds__(
207
+ AttentionKernel<float, cutlass::arch::Sm70, false, 64, 64, 64, true, true>::kNumThreads,
208
+ AttentionKernel<float, cutlass::arch::Sm70, false, 64, 64, 64, true, true>::kMinBlocksPerSm)
209
+ fmha_cutlassF_f32_notaligned_64x64_rf_sm70(typename AttentionKernel<float, cutlass::arch::Sm70, false, 64, 64, 64, true, true>::Params p);
210
+ __global__ void __launch_bounds__(
211
+ AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 128, true, true>::kNumThreads,
212
+ AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 128, true, true>::kMinBlocksPerSm)
213
+ fmha_cutlassF_f32_notaligned_32x128_rf_sm70(typename AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 128, true, true>::Params p);
214
+ __global__ void __launch_bounds__(
215
+ AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>::kNumThreads,
216
+ AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>::kMinBlocksPerSm)
217
+ fmha_cutlassF_f32_notaligned_32x128_gmem_sm70(typename AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>::Params p);
218
+
219
+ template <typename T> void dispatch_cutlassF_f32_sm70(T cb, int cc) {
220
+ cb(AttentionKernel<float, cutlass::arch::Sm70, true, 64, 64, 64, true, true>(), fmha_cutlassF_f32_aligned_64x64_rf_sm70);
221
+ cb(AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 128, true, true>(), fmha_cutlassF_f32_aligned_32x128_rf_sm70);
222
+ cb(AttentionKernel<float, cutlass::arch::Sm70, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f32_aligned_32x128_gmem_sm70);
223
+ cb(AttentionKernel<float, cutlass::arch::Sm70, false, 64, 64, 64, true, true>(), fmha_cutlassF_f32_notaligned_64x64_rf_sm70);
224
+ cb(AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 128, true, true>(), fmha_cutlassF_f32_notaligned_32x128_rf_sm70);
225
+ cb(AttentionKernel<float, cutlass::arch::Sm70, false, 32, 128, 65536, true, true>(), fmha_cutlassF_f32_notaligned_32x128_gmem_sm70);
226
+ }
227
+
228
+ // ======== f32 / sm75 ========
229
+ __global__ void __launch_bounds__(
230
+ AttentionKernel<float, cutlass::arch::Sm75, true, 64, 64, 64, true, true>::kNumThreads,
231
+ AttentionKernel<float, cutlass::arch::Sm75, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
232
+ fmha_cutlassF_f32_aligned_64x64_rf_sm75(typename AttentionKernel<float, cutlass::arch::Sm75, true, 64, 64, 64, true, true>::Params p);
233
+ __global__ void __launch_bounds__(
234
+ AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 128, true, true>::kNumThreads,
235
+ AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 128, true, true>::kMinBlocksPerSm)
236
+ fmha_cutlassF_f32_aligned_32x128_rf_sm75(typename AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 128, true, true>::Params p);
237
+ __global__ void __launch_bounds__(
238
+ AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>::kNumThreads,
239
+ AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
240
+ fmha_cutlassF_f32_aligned_32x128_gmem_sm75(typename AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>::Params p);
241
+ __global__ void __launch_bounds__(
242
+ AttentionKernel<float, cutlass::arch::Sm75, false, 64, 64, 64, true, true>::kNumThreads,
243
+ AttentionKernel<float, cutlass::arch::Sm75, false, 64, 64, 64, true, true>::kMinBlocksPerSm)
244
+ fmha_cutlassF_f32_notaligned_64x64_rf_sm75(typename AttentionKernel<float, cutlass::arch::Sm75, false, 64, 64, 64, true, true>::Params p);
245
+ __global__ void __launch_bounds__(
246
+ AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 128, true, true>::kNumThreads,
247
+ AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 128, true, true>::kMinBlocksPerSm)
248
+ fmha_cutlassF_f32_notaligned_32x128_rf_sm75(typename AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 128, true, true>::Params p);
249
+ __global__ void __launch_bounds__(
250
+ AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>::kNumThreads,
251
+ AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>::kMinBlocksPerSm)
252
+ fmha_cutlassF_f32_notaligned_32x128_gmem_sm75(typename AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>::Params p);
253
+
254
+ template <typename T> void dispatch_cutlassF_f32_sm75(T cb, int cc) {
255
+ cb(AttentionKernel<float, cutlass::arch::Sm75, true, 64, 64, 64, true, true>(), fmha_cutlassF_f32_aligned_64x64_rf_sm75);
256
+ cb(AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 128, true, true>(), fmha_cutlassF_f32_aligned_32x128_rf_sm75);
257
+ cb(AttentionKernel<float, cutlass::arch::Sm75, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f32_aligned_32x128_gmem_sm75);
258
+ cb(AttentionKernel<float, cutlass::arch::Sm75, false, 64, 64, 64, true, true>(), fmha_cutlassF_f32_notaligned_64x64_rf_sm75);
259
+ cb(AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 128, true, true>(), fmha_cutlassF_f32_notaligned_32x128_rf_sm75);
260
+ cb(AttentionKernel<float, cutlass::arch::Sm75, false, 32, 128, 65536, true, true>(), fmha_cutlassF_f32_notaligned_32x128_gmem_sm75);
261
+ }
262
+
263
+ // ======== f32 / sm80 ========
264
+ __global__ void __launch_bounds__(
265
+ AttentionKernel<float, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::kNumThreads,
266
+ AttentionKernel<float, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::kMinBlocksPerSm)
267
+ fmha_cutlassF_f32_aligned_64x64_rf_sm80(typename AttentionKernel<float, cutlass::arch::Sm80, true, 64, 64, 64, true, true>::Params p);
268
+ __global__ void __launch_bounds__(
269
+ AttentionKernel<float, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::kNumThreads,
270
+ AttentionKernel<float, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::kMinBlocksPerSm)
271
+ fmha_cutlassF_f32_aligned_64x128_rf_sm80(typename AttentionKernel<float, cutlass::arch::Sm80, true, 64, 128, 128, true, true>::Params p);
272
+ __global__ void __launch_bounds__(
273
+ AttentionKernel<float, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::kNumThreads,
274
+ AttentionKernel<float, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::kMinBlocksPerSm)
275
+ fmha_cutlassF_f32_aligned_32x128_gmem_sm80(typename AttentionKernel<float, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>::Params p);
276
+
277
+ template <typename T> void dispatch_cutlassF_f32_sm80(T cb, int cc) {
278
+ cb(AttentionKernel<float, cutlass::arch::Sm80, true, 64, 64, 64, true, true>(), fmha_cutlassF_f32_aligned_64x64_rf_sm80);
279
+ cb(AttentionKernel<float, cutlass::arch::Sm80, true, 64, 128, 128, true, true>(), fmha_cutlassF_f32_aligned_64x128_rf_sm80);
280
+ cb(AttentionKernel<float, cutlass::arch::Sm80, true, 32, 128, 65536, true, true>(), fmha_cutlassF_f32_aligned_32x128_gmem_sm80);
281
+ }
282
+
283
+
284
+ template <typename DT, typename T>
285
+ void dispatch_cutlassF(T cb, int cc = 0) {
286
+
287
+ if (std::is_same_v<DT, cutlass::bfloat16_t> && 80 <= cc && cc <= 120) {
288
+ dispatch_cutlassF_bf16_sm80(cb, cc);
289
+ }
290
+ if (std::is_same_v<DT, cutlass::half_t> && 50 <= cc && cc < 70) {
291
+ dispatch_cutlassF_f16_sm50(cb, cc);
292
+ }
293
+ if (std::is_same_v<DT, cutlass::half_t> && 70 <= cc && cc < 75) {
294
+ dispatch_cutlassF_f16_sm70(cb, cc);
295
+ }
296
+ if (std::is_same_v<DT, cutlass::half_t> && 75 <= cc && cc < 80) {
297
+ dispatch_cutlassF_f16_sm75(cb, cc);
298
+ }
299
+ if (std::is_same_v<DT, cutlass::half_t> && 80 <= cc && cc <= 120) {
300
+ dispatch_cutlassF_f16_sm80(cb, cc);
301
+ }
302
+ if (std::is_same_v<DT, float> && 50 <= cc && cc < 70) {
303
+ dispatch_cutlassF_f32_sm50(cb, cc);
304
+ }
305
+ if (std::is_same_v<DT, float> && 70 <= cc && cc < 75) {
306
+ dispatch_cutlassF_f32_sm70(cb, cc);
307
+ }
308
+ if (std::is_same_v<DT, float> && 75 <= cc && cc < 80) {
309
+ dispatch_cutlassF_f32_sm75(cb, cc);
310
+ }
311
+ if (std::is_same_v<DT, float> && 80 <= cc && cc <= 120) {
312
+ dispatch_cutlassF_f32_sm80(cb, cc);
313
+ }
314
+ }
315
+
316
+ #else
317
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
318
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/cuda/mem_eff_attention/transform/tile_smem_loader.h ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ #pragma once
10
+
11
+ #include <cutlass/cutlass.h>
12
+ #include <cutlass/aligned_buffer.h>
13
+ #include <cutlass/array.h>
14
+ #include <cutlass/layout/matrix.h>
15
+ #include <cutlass/layout/pitch_linear.h>
16
+ #include <cutlass/numeric_types.h>
17
+ #include <cutlass/transform/pitch_linear_thread_map.h>
18
+ #include <cutlass/transform/threadblock/predicated_tile_iterator.h>
19
+ #include <cutlass/transform/threadblock/regular_tile_iterator.h>
20
+
21
+ template <
22
+ typename scalar_t, // scalar type
23
+ typename ThreadblockTileShape, // size of tile to load
24
+ int Threads, // number of participating threads
25
+ int ElementsPerAccess> // thread access width in elements
26
+ class TileSmemLoader {
27
+ public:
28
+ using SmemTile =
29
+ cutlass::AlignedBuffer<scalar_t, ThreadblockTileShape::kCount>;
30
+
31
+ using ThreadMap = cutlass::transform::PitchLinearStripminedThreadMap<
32
+ cutlass::layout::PitchLinearShape<
33
+ ThreadblockTileShape::kColumn, // contiguous
34
+ ThreadblockTileShape::kRow>, // strided
35
+ Threads, // Threads
36
+ ElementsPerAccess>; // ElementsPerAccess
37
+
38
+ using GmemTileIterator =
39
+ cutlass::transform::threadblock::PredicatedTileIterator<
40
+ ThreadblockTileShape, // Shape
41
+ scalar_t, // Element
42
+ cutlass::layout::RowMajor, // Layout
43
+ 0, // AdvanceRank
44
+ ThreadMap>; // ThreadMap
45
+
46
+ using SmemTileIterator = cutlass::transform::threadblock::RegularTileIterator<
47
+ ThreadblockTileShape, // Shape
48
+ scalar_t, // Element
49
+ cutlass::layout::RowMajor, // Layout
50
+ 0, // AdvanceRank
51
+ ThreadMap>; // ThreadMap
52
+
53
+ using Fragment = typename GmemTileIterator::Fragment;
54
+
55
+ /// load a tile from global memory into shared memory
56
+ CUTLASS_DEVICE
57
+ static void load(
58
+ GmemTileIterator tile_load_iter,
59
+ SmemTileIterator tile_store_iter) {
60
+ Fragment tb_frag;
61
+ tb_frag.clear();
62
+ tile_load_iter.load(tb_frag);
63
+ tile_store_iter.store(tb_frag);
64
+
65
+ __syncthreads();
66
+ }
67
+ };
68
+
69
+ #else
70
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
71
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/aotriton_adapter.h ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #ifdef USE_ROCM
5
+
6
+ // Expect to be included after headers of at::zeros_like and at::empty_like
7
+
8
+ #include <aotriton/dtypes.h>
9
+ #include <aotriton/util.h>
10
+ #include <aotriton/config.h>
11
+ #include <ATen/native/transformers/hip/aotriton_versions.h>
12
+
13
+ ////////////////////////////////////////////////////////////////////////////////
14
+ // Common macros copied from cuda/mem_eff_attention/gemm_kernel_utils.h
15
+ ////////////////////////////////////////////////////////////////////////////////
16
+
17
+ namespace sdp {
18
+
19
+ namespace aotriton_adapter {
20
+
21
+ inline aotriton::DType cast_dtype(caffe2::TypeMeta t_dtype)
22
+ {
23
+ #define CAST_TYPE(aname, dtname) if (t_dtype == at::aname) return aotriton::DType::dtname
24
+ CAST_TYPE(kByte, kUInt8);
25
+ CAST_TYPE(kUInt16, kUInt16);
26
+ CAST_TYPE(kUInt32, kUInt32);
27
+ CAST_TYPE(kUInt64, kUInt64);
28
+ CAST_TYPE(kChar, kInt8);
29
+ CAST_TYPE(kShort, kInt16);
30
+ CAST_TYPE(kInt, kInt32);
31
+ CAST_TYPE(kLong, kInt64);
32
+ CAST_TYPE(kHalf, kFloat16);
33
+ CAST_TYPE(kFloat, kFloat32);
34
+ CAST_TYPE(kBFloat16, kBFloat16);
35
+ return aotriton::DType::kUnknown;
36
+ #undef CAST_TYPE
37
+ }
38
+
39
+ template<typename TargetType, int Rank>
40
+ struct IntArrayRefCaster {
41
+ // std::array<TargetType, Rank> cast(IntArrayRef);
42
+ };
43
+
44
+ template<typename TargetType>
45
+ struct IntArrayRefCaster<TargetType, 1> {
46
+ static auto cast(at::IntArrayRef ref) {
47
+ return std::array<TargetType, 1>{{ static_cast<TargetType>(ref.at(0)) }};
48
+ }
49
+ };
50
+
51
+ template<typename TargetType>
52
+ struct IntArrayRefCaster<TargetType, 2> {
53
+ static auto cast(at::IntArrayRef ref) {
54
+ return std::array<TargetType, 2>{{
55
+ static_cast<TargetType>(ref.at(0)),
56
+ static_cast<TargetType>(ref.at(1))
57
+ }};
58
+ }
59
+ };
60
+
61
+ template<typename TargetType>
62
+ struct IntArrayRefCaster<TargetType, 3> {
63
+ static auto cast(at::IntArrayRef ref) {
64
+ return std::array<TargetType, 3>{{
65
+ static_cast<TargetType>(ref.at(0)),
66
+ static_cast<TargetType>(ref.at(1)),
67
+ static_cast<TargetType>(ref.at(2))
68
+ }};
69
+ }
70
+ };
71
+
72
+ template<typename TargetType>
73
+ struct IntArrayRefCaster<TargetType, 4> {
74
+ static auto cast(at::IntArrayRef ref) {
75
+ return std::array<TargetType, 4>{{
76
+ static_cast<TargetType>(ref.at(0)),
77
+ static_cast<TargetType>(ref.at(1)),
78
+ static_cast<TargetType>(ref.at(2)),
79
+ static_cast<TargetType>(ref.at(3))
80
+ }};
81
+ }
82
+ };
83
+
84
+
85
+ template<int Rank = 4>
86
+ aotriton::TensorView<Rank> mk_aotensor(const at::Tensor& q, std::string_view tensor_name)
87
+ {
88
+ const auto strides = q.strides();
89
+ int real_rank = strides.size();
90
+ if (real_rank != Rank) { // Lazy conversion of tensor_name
91
+ TORCH_CHECK(false,
92
+ std::string(tensor_name) + "'s rank should be " + std::to_string(Rank)
93
+ + " but is " + std::to_string(real_rank));
94
+ }
95
+ return aotriton::TensorView<Rank>(reinterpret_cast<intptr_t>(q.data_ptr()),
96
+ IntArrayRefCaster<uint64_t, Rank>::cast(q.sizes()),
97
+ IntArrayRefCaster<uint64_t, Rank>::cast(strides),
98
+ cast_dtype(q.dtype()));
99
+ }
100
+
101
+ inline aotriton::TensorView<0> mk_aoscalartensor(const at::Tensor& q)
102
+ {
103
+ return aotriton::TensorView<0>(reinterpret_cast<intptr_t>(q.data_ptr()),
104
+ cast_dtype(q.dtype()));
105
+ }
106
+
107
+ inline aotriton::TensorView<0> mk_philoxtensor(const int64_t* ptr)
108
+ {
109
+ return aotriton::TensorView<0>(reinterpret_cast<intptr_t>(ptr),
110
+ aotriton::DType::kUInt64); // AOTriton accepts unsigned int64
111
+ }
112
+
113
+ inline aotriton::TensorView<0> mk_atomictensor(const int32_t* ptr)
114
+ {
115
+ return aotriton::TensorView<0>(reinterpret_cast<intptr_t>(ptr),
116
+ aotriton::DType::kInt32);
117
+ }
118
+
119
+ #if AOTRITON_VERSION_CURRENT >= AOTRITON_VERSION_INT(0, 11)
120
+
121
+ struct LazyTensorContext {
122
+ at::Tensor like_tensor;
123
+ std::string_view tensor_name;
124
+ at::Tensor tensor;
125
+ };
126
+
127
+ template<int kRank, bool kRequireZeros>
128
+ struct LazyTensorFunctions : public LazyTensorContext {
129
+ static aotriton::TensorView<kRank> acquire(void* cookie) {
130
+ auto ctx = (LazyTensorContext*)cookie;
131
+ if (!ctx->tensor.defined()) {
132
+ auto q = ctx->like_tensor;
133
+ if constexpr (kRequireZeros) {
134
+ ctx->tensor = at::zeros(q.sizes(),
135
+ q.options().dtype(at::kFloat));
136
+ } else {
137
+ ctx->tensor = at::empty_like(q);
138
+ }
139
+ }
140
+ return mk_aotensor<kRank>(ctx->tensor, ctx->tensor_name);
141
+ }
142
+
143
+ static void dispose(void* cookie) {
144
+ }
145
+ };
146
+
147
+ template<int kRank, bool kRequireZeros>
148
+ aotriton::LazyTensor<kRank> mklazy_common(LazyTensorContext* cookie)
149
+ {
150
+ using LTF = LazyTensorFunctions<kRank, kRequireZeros>;
151
+ return aotriton::LazyTensor<kRank> {
152
+ .cookie = cookie,
153
+ .acquire = &LTF::acquire,
154
+ .dispose = &LTF::dispose
155
+ };
156
+ }
157
+
158
+ template<int kRank>
159
+ auto mklazy_empty_like(LazyTensorContext* cookie)
160
+ {
161
+ return mklazy_common<kRank, false>(cookie);
162
+ }
163
+
164
+
165
+ // Note: this will not keep the original strides
166
+ template<int kRank>
167
+ auto mklazy_fp32zeros(LazyTensorContext* cookie)
168
+ {
169
+ return mklazy_common<kRank, true>(cookie);
170
+ }
171
+
172
+ #endif // >= 0.11
173
+
174
+ } // namespace aotriton_adapter
175
+
176
+ } // namespace sdp
177
+
178
+ namespace at::native {
179
+
180
+ inline int64_t ceil_div(int64_t numerator, int64_t denominator) {
181
+ return (numerator + (denominator - 1)) / denominator;
182
+ }
183
+
184
+ }
185
+
186
+ #endif // USE_ROCM
187
+
188
+ #else
189
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
190
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/aotriton_versions.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #ifdef USE_ROCM
5
+
6
+ #define AOTRITON_VERSION_INT(x, y) (x * 100 + y)
7
+ #define AOTRITON_VERSION_CURRENT (AOTRITON_VERSION_MAJOR * 100 + AOTRITON_VERSION_MINOR)
8
+
9
+ #if AOTRITON_VERSION_CURRENT >= AOTRITON_VERSION_INT(0, 11)
10
+ #define AOTRITON_ALWAYS_V3_API 1
11
+ #else
12
+ #define AOTRITON_ALWAYS_V3_API 0
13
+ #endif
14
+
15
+ #if AOTRITON_VERSION_CURRENT >= AOTRITON_VERSION_INT(0, 10)
16
+ #define AOTRITON_V3_API 1
17
+ #else
18
+ #define AOTRITON_V3_API 0
19
+ #endif
20
+
21
+ #endif
22
+
23
+ #else
24
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
25
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/flash_attn/ck/me_ck_api.h ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ #include <cstddef>
4
+
5
+ #include <ATen/core/Tensor.h>
6
+
7
+ #if defined(USE_ROCM_CK_SDPA)
8
+ namespace pytorch_flash {
9
+
10
+ std::tuple<
11
+ at::Tensor, // output
12
+ at::Tensor, // q
13
+ at::Tensor, // k
14
+ at::Tensor, // v
15
+ at::Tensor, // lse
16
+ at::Tensor, // seed
17
+ at::Tensor, // offset
18
+ at::Tensor> // dropout randval
19
+ mem_eff_forward_ck(
20
+ const at::Tensor& q,
21
+ const at::Tensor& k,
22
+ const at::Tensor& v,
23
+ float p_dropout,
24
+ bool return_dropout_randval,
25
+ std::optional<bool> is_causal,
26
+ std::optional<float> scale,
27
+ const std::optional<at::Tensor>& attn_bias_,
28
+ std::optional<at::Tensor>& out_,
29
+ const std::optional<at::Tensor>& cu_seqlens_q,
30
+ const std::optional<at::Tensor>& cu_seqlens_k,
31
+ const std::optional<at::Tensor>& seqstart_q,
32
+ const std::optional<at::Tensor>& seqstart_k,
33
+ std::optional<at::Generator> gen_,
34
+ std::optional<at::Tensor>& seqused_k_
35
+ );
36
+
37
+ std::tuple<
38
+ at::Tensor, // dQ
39
+ at::Tensor, // dK
40
+ at::Tensor, // dV
41
+ at::Tensor> // dBias
42
+ mem_eff_backward_ck(
43
+ const at::Tensor &dout,
44
+ const at::Tensor &q,
45
+ const at::Tensor &k,
46
+ const at::Tensor &v,
47
+ const at::Tensor &out,
48
+ const at::Tensor &softmax_lse,
49
+ const at::Tensor &dq_,
50
+ const at::Tensor &dk_,
51
+ const at::Tensor &dv_,
52
+ std::optional<at::Tensor> &attn_bias,
53
+ bool bias_requires_grad,
54
+ std::optional<at::Tensor> &grad_bias,
55
+ std::optional<at::Tensor> &cu_seqlens_q,
56
+ std::optional<at::Tensor> &cu_seqlens_k,
57
+ int max_seqlen_q,
58
+ int max_seqlen_k,
59
+ float p_dropout,
60
+ float scale,
61
+ bool is_causal,
62
+ bool deterministic,
63
+ bool zero_tensors,
64
+ const at::Tensor philox_seed,
65
+ const at::Tensor philox_offset);
66
+
67
+ } // namespace pytorch_flash
68
+ #endif // USE_ROCM_CK_SDPA
69
+
70
+ #else
71
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
72
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/flash_attn/flash_api.h ADDED
@@ -0,0 +1,568 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ #include <cstddef>
4
+
5
+ #include <ATen/Context.h>
6
+ #include <ATen/core/Tensor.h>
7
+ #include <c10/util/Exception.h>
8
+
9
+ #define CHECK_NOSPARSE_CONTIGUOUS_CUDA(TENSOR) \
10
+ TORCH_CHECK(TENSOR.is_cuda(), #TENSOR " must be a CUDA tensor"); \
11
+ TORCH_CHECK(!TENSOR.is_sparse(), #TENSOR " must be a dense tensor"); \
12
+ TORCH_CHECK(TENSOR.is_contiguous());
13
+
14
+ #define CHECK_NOSPARSE_LASTCONTIGUOUS_CUDA(TENSOR) \
15
+ TORCH_CHECK(TENSOR.is_cuda(), #TENSOR " must be a CUDA tensor"); \
16
+ TORCH_CHECK(!TENSOR.is_sparse(), #TENSOR " must be a dense tensor"); \
17
+ TORCH_CHECK( \
18
+ TENSOR.stride(-1) == 1, #TENSOR ": last dimension must be contiguous");
19
+
20
+ #define CHECK_ALIGNED_PTR(PTR, ALIGNMENT) \
21
+ TORCH_CHECK( \
22
+ uint64_t(PTR) % ALIGNMENT == 0, #PTR " is not correctly aligned")
23
+
24
+ #define ASSIGN_CHECK_OVERFLOW(A, B) \
25
+ { \
26
+ A = B; \
27
+ TORCH_CHECK( \
28
+ B < std::numeric_limits<decltype(A)>::max(), #B " overflows"); \
29
+ }
30
+
31
+ namespace pytorch_flash {
32
+
33
+ // AOTriton Implementation
34
+ TORCH_API
35
+ std::tuple<
36
+ at::Tensor,
37
+ at::Tensor,
38
+ at::Tensor,
39
+ at::Tensor,
40
+ at::Tensor,
41
+ at::Tensor,
42
+ at::Tensor,
43
+ at::Tensor>
44
+ mha_fwd_aot(
45
+ const at::Tensor& q, // batch_size x seqlen_q x num_heads x head_size
46
+ const at::Tensor& k, // batch_size x seqlen_k x num_heads_k x head_size
47
+ const at::Tensor& v, // batch_size x seqlen_k x num_heads_k x head_size
48
+ std::optional<at::Tensor>&
49
+ out_, // batch_size x seqlen_q x num_heads x head_size
50
+ std::optional<at::Tensor>&
51
+ alibi_slopes_, // num_heads or batch_size x num_heads
52
+ const float p_dropout,
53
+ const float softmax_scale,
54
+ bool is_causal,
55
+ std::optional<int64_t> window_size_left,
56
+ std::optional<int64_t> window_size_right,
57
+ const bool return_softmax,
58
+ const std::optional<at::Generator>& gen_);
59
+
60
+ std::tuple<
61
+ at::Tensor,
62
+ at::Tensor,
63
+ at::Tensor,
64
+ at::Tensor,
65
+ at::Tensor,
66
+ at::Tensor,
67
+ at::Tensor,
68
+ at::Tensor>
69
+ mha_varlen_fwd_aot(
70
+ const at::Tensor&
71
+ q, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
72
+ const at::Tensor&
73
+ k, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
74
+ const at::Tensor&
75
+ v, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
76
+ std::optional<at::Tensor>&
77
+ out_, // total_q x num_heads x head_size, total_k := \sum_{i=0}^{b} s_i
78
+ const at::Tensor& cu_seqlens_q, // b+1
79
+ const at::Tensor& cu_seqlens_k, // b+1
80
+ std::optional<at::Tensor>&
81
+ seqused_k, // b. If given, only this many elements of each batch
82
+ // element's keys are used.
83
+ std::optional<at::Tensor>& block_table_,
84
+ std::optional<at::Tensor>& alibi_slopes_, // num_heads or b x num_heads
85
+ int max_seqlen_q,
86
+ const int max_seqlen_k,
87
+ const float p_dropout,
88
+ const float softmax_scale,
89
+ const bool zero_tensors,
90
+ bool is_causal,
91
+ std::optional<int64_t> window_size_left,
92
+ std::optional<int64_t> window_size_right,
93
+ const bool return_softmax,
94
+ const std::optional<at::Generator>& gen_);
95
+
96
+ std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor> mha_bwd_aot(
97
+ const at::Tensor& dout, // batch_size x seqlen_q x num_heads, x head_size_og
98
+ const at::Tensor& q, // batch_size x seqlen_q x num_heads x head_size
99
+ const at::Tensor& k, // batch_size x seqlen_k x num_heads_k x head_size
100
+ const at::Tensor& v, // batch_size x seqlen_k x num_heads_k x head_size
101
+ const at::Tensor& out, // batch_size x seqlen_q x num_heads x head_size
102
+ const at::Tensor& softmax_lse, // b x h x seqlen_q
103
+ std::optional<at::Tensor>&
104
+ dq_, // batch_size x seqlen_q x num_heads x head_size
105
+ std::optional<at::Tensor>&
106
+ dk_, // batch_size x seqlen_k x num_heads_k x head_size
107
+ std::optional<at::Tensor>&
108
+ dv_, // batch_size x seqlen_k x num_heads_k x head_size
109
+ std::optional<at::Tensor>&
110
+ alibi_slopes_, // num_heads or batch_size x num_heads
111
+ const float p_dropout, // probability to drop
112
+ const float softmax_scale,
113
+ const bool is_causal,
114
+ std::optional<int64_t> window_size_left,
115
+ std::optional<int64_t> window_size_right,
116
+ const bool deterministic,
117
+ const at::Tensor& philox_seed,
118
+ const at::Tensor& philox_offset);
119
+
120
+ std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor> mha_varlen_bwd_aot(
121
+ const at::Tensor& dout, // total_q x num_heads, x head_size
122
+ const at::Tensor&
123
+ q, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
124
+ const at::Tensor&
125
+ k, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
126
+ const at::Tensor&
127
+ v, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
128
+ const at::Tensor& out, // total_q x num_heads x head_size
129
+ const at::Tensor& softmax_lse, // b x h x s softmax logsumexp
130
+ std::optional<at::Tensor>&
131
+ dq_, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
132
+ std::optional<at::Tensor>&
133
+ dk_, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
134
+ std::optional<at::Tensor>&
135
+ dv_, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
136
+ const at::Tensor& cu_seqlens_q, // b+1
137
+ const at::Tensor& cu_seqlens_k, // b+1
138
+ std::optional<at::Tensor>& alibi_slopes_, // num_heads or b x num_heads
139
+ const int max_seqlen_q,
140
+ const int max_seqlen_k, // max sequence length to choose the kernel
141
+ const float p_dropout, // probability to drop
142
+ const float softmax_scale,
143
+ const bool zero_tensors,
144
+ const bool is_causal,
145
+ std::optional<int64_t> window_size_left,
146
+ std::optional<int64_t> window_size_right,
147
+ const bool deterministic,
148
+ const at::Tensor& philox_seed,
149
+ const at::Tensor& philox_offset);
150
+
151
+ #if defined(USE_ROCM_CK_SDPA)
152
+ // CK implementation
153
+ TORCH_API
154
+ std::tuple<
155
+ at::Tensor,
156
+ at::Tensor,
157
+ at::Tensor,
158
+ at::Tensor,
159
+ at::Tensor,
160
+ at::Tensor,
161
+ at::Tensor,
162
+ at::Tensor>
163
+ mha_fwd_ck(
164
+ const at::Tensor& q, // batch_size x seqlen_q x num_heads x head_size
165
+ const at::Tensor& k, // batch_size x seqlen_k x num_heads_k x head_size
166
+ const at::Tensor& v, // batch_size x seqlen_k x num_heads_k x head_size
167
+ std::optional<at::Tensor>&
168
+ out_, // batch_size x seqlen_q x num_heads x head_size
169
+ const float p_dropout,
170
+ const float softmax_scale,
171
+ bool is_causal,
172
+ int window_size_left,
173
+ int window_size_right,
174
+ const bool return_softmax,
175
+ std::optional<at::Generator> gen_,
176
+ const std::optional<at::Tensor>& attn_bias_); // batch_size x nheads x seqlen_q x seqlen_k
177
+
178
+ std::tuple<
179
+ at::Tensor,
180
+ at::Tensor,
181
+ at::Tensor,
182
+ at::Tensor,
183
+ at::Tensor,
184
+ at::Tensor,
185
+ at::Tensor,
186
+ at::Tensor>
187
+ mha_varlen_fwd_ck(
188
+ const at::Tensor&
189
+ q, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
190
+ const at::Tensor&
191
+ k, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
192
+ const at::Tensor&
193
+ v, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
194
+ std::optional<at::Tensor>&
195
+ out_, // total_q x num_heads x head_size, total_k := \sum_{i=0}^{b} s_i
196
+ const at::Tensor& cu_seqlens_q, // b+1
197
+ const at::Tensor& cu_seqlens_k, // b+1
198
+ std::optional<at::Tensor>&
199
+ seqused_k, // b. If given, only this many elements of each batch
200
+ // element's keys are used.
201
+ int max_seqlen_q,
202
+ const int max_seqlen_k,
203
+ const float p_dropout,
204
+ const float softmax_scale,
205
+ const bool zero_tensors,
206
+ bool is_causal,
207
+ int window_size_left,
208
+ int window_size_right,
209
+ const bool return_softmax,
210
+ std::optional<at::Generator> gen_,
211
+ const std::optional<at::Tensor>& attn_bias_);
212
+
213
+ std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor> mha_bwd_ck(
214
+ const at::Tensor& dout, // batch_size x seqlen_q x num_heads, x head_size_og
215
+ const at::Tensor& q, // batch_size x seqlen_q x num_heads x head_size
216
+ const at::Tensor& k, // batch_size x seqlen_k x num_heads_k x head_size
217
+ const at::Tensor& v, // batch_size x seqlen_k x num_heads_k x head_size
218
+ const at::Tensor& out, // batch_size x seqlen_q x num_heads x head_size
219
+ const at::Tensor& softmax_lse, // b x h x seqlen_q
220
+ std::optional<at::Tensor>&
221
+ dq_, // batch_size x seqlen_q x num_heads x head_size
222
+ std::optional<at::Tensor>&
223
+ dk_, // batch_size x seqlen_k x num_heads_k x head_size
224
+ std::optional<at::Tensor>&
225
+ dv_, // batch_size x seqlen_k x num_heads_k x head_size
226
+ std::optional<at::Tensor>&
227
+ attn_bias_, // batch_size x num_heads x seqlen_q x seqlen_k
228
+ bool bias_requires_grad,
229
+ std::optional<at::Tensor>& grad_bias,
230
+ const float p_dropout, // probability to drop
231
+ const float softmax_scale,
232
+ const bool is_causal,
233
+ int window_size_left,
234
+ int window_size_right,
235
+ const bool deterministic,
236
+ const at::Tensor philox_seed,
237
+ const at::Tensor philox_offset);
238
+
239
+ std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor> mha_varlen_bwd_ck(
240
+ const at::Tensor& dout, // total_q x num_heads, x head_size
241
+ const at::Tensor&
242
+ q, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
243
+ const at::Tensor&
244
+ k, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
245
+ const at::Tensor&
246
+ v, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
247
+ const at::Tensor& out, // total_q x num_heads x head_size
248
+ const at::Tensor& softmax_lse, // b x h x s softmax logsumexp
249
+ std::optional<at::Tensor>&
250
+ dq_, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
251
+ std::optional<at::Tensor>&
252
+ dk_, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
253
+ std::optional<at::Tensor>&
254
+ dv_, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
255
+ const at::Tensor& cu_seqlens_q, // b+1
256
+ const at::Tensor& cu_seqlens_k, // b+1
257
+ std::optional<at::Tensor>& attn_bias_, // num_heads or b x num_heads
258
+ bool bias_requires_grad,
259
+ std::optional<at::Tensor>& grad_bias,
260
+ const int max_seqlen_q,
261
+ const int max_seqlen_k, // max sequence length to choose the kernel
262
+ const float p_dropout, // probability to drop
263
+ const float softmax_scale,
264
+ const bool zero_tensors,
265
+ const bool is_causal,
266
+ int window_size_left,
267
+ int window_size_right,
268
+ const bool deterministic,
269
+ const at::Tensor philox_seed,
270
+ const at::Tensor philox_offset);
271
+ #endif
272
+
273
+ TORCH_API
274
+ std::tuple<
275
+ at::Tensor,
276
+ at::Tensor,
277
+ at::Tensor,
278
+ at::Tensor,
279
+ at::Tensor,
280
+ at::Tensor,
281
+ at::Tensor,
282
+ at::Tensor>
283
+ mha_fwd(
284
+ const at::Tensor& q, // batch_size x seqlen_q x num_heads x head_size
285
+ const at::Tensor& k, // batch_size x seqlen_k x num_heads_k x head_size
286
+ const at::Tensor& v, // batch_size x seqlen_k x num_heads_k x head_size
287
+ std::optional<at::Tensor>&
288
+ out_, // batch_size x seqlen_q x num_heads x head_size
289
+ std::optional<at::Tensor>&
290
+ alibi_slopes_, // num_heads or batch_size x num_heads
291
+ const float p_dropout,
292
+ const float softmax_scale,
293
+ bool is_causal,
294
+ std::optional<int64_t> window_size_left,
295
+ std::optional<int64_t> window_size_right,
296
+ const float softcap,
297
+ const bool return_softmax,
298
+ std::optional<at::Generator> gen_);
299
+
300
+ inline std::tuple<
301
+ at::Tensor,
302
+ at::Tensor,
303
+ at::Tensor,
304
+ at::Tensor,
305
+ at::Tensor,
306
+ at::Tensor,
307
+ at::Tensor,
308
+ at::Tensor>
309
+ mha_varlen_fwd(
310
+ const at::Tensor&
311
+ q, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
312
+ const at::Tensor&
313
+ k, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
314
+ const at::Tensor&
315
+ v, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
316
+ std::optional<at::Tensor>&
317
+ out_, // total_q x num_heads x head_size, total_k := \sum_{i=0}^{b} s_i
318
+ const at::Tensor& cu_seqlens_q, // b+1
319
+ const at::Tensor& cu_seqlens_k, // b+1
320
+ std::optional<at::Tensor>&
321
+ seqused_k, // b. If given, only this many elements of each batch
322
+ // element's keys are used.
323
+ std::optional<at::Tensor>&
324
+ block_table_, // Not used on ROCm. Keeping for parity with CUDA
325
+ std::optional<at::Tensor>& alibi_slopes_, // num_heads or b x num_heads
326
+ int max_seqlen_q,
327
+ const int max_seqlen_k,
328
+ const float p_dropout,
329
+ const float softmax_scale,
330
+ const bool zero_tensors,
331
+ bool is_causal,
332
+ std::optional<int64_t> window_size_left,
333
+ std::optional<int64_t> window_size_right,
334
+ const float softcap,
335
+ const bool return_softmax,
336
+ std::optional<at::Generator> gen_) {
337
+ #if defined(USE_ROCM_CK_SDPA)
338
+ if (at::globalContext().getROCmFAPreferredBackend() ==
339
+ at::ROCmFABackend::Ck) {
340
+ std::optional<at::Tensor> dummy_attn_bias = std::nullopt;
341
+ const int non_null_window_left = window_size_left.value_or(-1);
342
+ const int non_null_window_right = window_size_right.value_or(-1);
343
+ return mha_varlen_fwd_ck(
344
+ q,
345
+ k,
346
+ v,
347
+ out_,
348
+ cu_seqlens_q,
349
+ cu_seqlens_k,
350
+ seqused_k,
351
+ max_seqlen_q,
352
+ max_seqlen_k,
353
+ p_dropout,
354
+ softmax_scale,
355
+ zero_tensors,
356
+ is_causal,
357
+ non_null_window_left,
358
+ non_null_window_right,
359
+ return_softmax,
360
+ gen_,
361
+ dummy_attn_bias); // Not used in flash attention
362
+ }
363
+ #endif
364
+ return mha_varlen_fwd_aot(
365
+ q,
366
+ k,
367
+ v,
368
+ out_,
369
+ cu_seqlens_q,
370
+ cu_seqlens_k,
371
+ seqused_k,
372
+ block_table_,
373
+ alibi_slopes_,
374
+ max_seqlen_q,
375
+ max_seqlen_k,
376
+ p_dropout,
377
+ softmax_scale,
378
+ zero_tensors,
379
+ is_causal,
380
+ window_size_left,
381
+ window_size_right,
382
+ return_softmax,
383
+ gen_);
384
+ }
385
+
386
+ inline std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor> mha_bwd(
387
+ const at::Tensor& dout, // batch_size x seqlen_q x num_heads, x head_size_og
388
+ const at::Tensor& q, // batch_size x seqlen_q x num_heads x head_size
389
+ const at::Tensor& k, // batch_size x seqlen_k x num_heads_k x head_size
390
+ const at::Tensor& v, // batch_size x seqlen_k x num_heads_k x head_size
391
+ const at::Tensor& out, // batch_size x seqlen_q x num_heads x head_size
392
+ const at::Tensor& softmax_lse, // b x h x seqlen_q
393
+ std::optional<at::Tensor>&
394
+ dq_, // batch_size x seqlen_q x num_heads x head_size
395
+ std::optional<at::Tensor>&
396
+ dk_, // batch_size x seqlen_k x num_heads_k x head_size
397
+ std::optional<at::Tensor>&
398
+ dv_, // batch_size x seqlen_k x num_heads_k x head_size
399
+ std::optional<at::Tensor>&
400
+ alibi_slopes_, // num_heads or batch_size x num_heads
401
+ const float p_dropout, // probability to drop
402
+ const float softmax_scale,
403
+ const bool is_causal,
404
+ std::optional<int64_t> window_size_left,
405
+ std::optional<int64_t> window_size_right,
406
+ const float softcap,
407
+ const bool deterministic,
408
+ const at::Tensor philox_seed,
409
+ const at::Tensor philox_offset) {
410
+
411
+ #if defined(USE_ROCM_CK_SDPA)
412
+ if (at::globalContext().getROCmFAPreferredBackend() ==
413
+ at::ROCmFABackend::Ck) {
414
+ std::optional<at::Tensor> non_null_dbias = std::nullopt;
415
+ const int non_null_window_left = window_size_left.value_or(-1);
416
+ const int non_null_window_right = window_size_right.value_or(-1);
417
+ auto[dQuery,
418
+ dKey,
419
+ dValue,
420
+ dSoftmax,
421
+ dBias] = mha_bwd_ck(
422
+ dout,
423
+ q,
424
+ k,
425
+ v,
426
+ out,
427
+ softmax_lse,
428
+ dq_,
429
+ dk_,
430
+ dv_,
431
+ alibi_slopes_,
432
+ false, // bias_requires_grad
433
+ non_null_dbias,
434
+ p_dropout,
435
+ softmax_scale,
436
+ is_causal,
437
+ non_null_window_left,
438
+ non_null_window_right,
439
+ deterministic,
440
+ philox_seed,
441
+ philox_offset);
442
+ // for FA return [dQ, dV, dK, dSoftmax]
443
+ return std::make_tuple(std::move(dQuery), std::move(dKey), std::move(dValue), std::move(dSoftmax));
444
+ }
445
+ #endif
446
+ return mha_bwd_aot(
447
+ dout,
448
+ q,
449
+ k,
450
+ v,
451
+ out,
452
+ softmax_lse,
453
+ dq_,
454
+ dk_,
455
+ dv_,
456
+ alibi_slopes_,
457
+ p_dropout,
458
+ softmax_scale,
459
+ is_causal,
460
+ window_size_left,
461
+ window_size_right,
462
+ deterministic,
463
+ philox_seed,
464
+ philox_offset);
465
+ }
466
+
467
+ inline std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor> mha_varlen_bwd(
468
+ const at::Tensor& dout, // total_q x num_heads, x head_size
469
+ const at::Tensor&
470
+ q, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
471
+ const at::Tensor&
472
+ k, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
473
+ const at::Tensor&
474
+ v, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
475
+ const at::Tensor& out, // total_q x num_heads x head_size
476
+ const at::Tensor& softmax_lse, // b x h x s softmax logsumexp
477
+ std::optional<at::Tensor>&
478
+ dq_, // total_q x num_heads x head_size, total_q := \sum_{i=0}^{b} s_i
479
+ std::optional<at::Tensor>&
480
+ dk_, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
481
+ std::optional<at::Tensor>&
482
+ dv_, // total_k x num_heads_k x head_size, total_k := \sum_{i=0}^{b} s_i
483
+ const at::Tensor& cu_seqlens_q, // b+1
484
+ const at::Tensor& cu_seqlens_k, // b+1
485
+ std::optional<at::Tensor>& alibi_slopes_, // num_heads or b x num_heads
486
+ const int max_seqlen_q,
487
+ const int max_seqlen_k, // max sequence length to choose the kernel
488
+ const float p_dropout, // probability to drop
489
+ const float softmax_scale,
490
+ const bool zero_tensors,
491
+ const bool is_causal,
492
+ std::optional<int64_t> window_size_left,
493
+ std::optional<int64_t> window_size_right,
494
+ const float softcap,
495
+ const bool deterministic,
496
+ const at::Tensor philox_seed,
497
+ const at::Tensor philox_offset) {
498
+ #if defined(USE_ROCM_CK_SDPA)
499
+ if (at::globalContext().getROCmFAPreferredBackend() ==
500
+ at::ROCmFABackend::Ck) {
501
+ std::optional<at::Tensor> non_null_dbias = std::nullopt;
502
+ const int non_null_window_left = window_size_left.value_or(-1);
503
+ const int non_null_window_right = window_size_right.value_or(-1);
504
+ auto[dQuery,
505
+ dKey,
506
+ dValue,
507
+ dSoftmax,
508
+ dBias] = mha_varlen_bwd_ck(
509
+ dout,
510
+ q,
511
+ k,
512
+ v,
513
+ out,
514
+ softmax_lse,
515
+ dq_,
516
+ dk_,
517
+ dv_,
518
+ cu_seqlens_q,
519
+ cu_seqlens_k,
520
+ alibi_slopes_,
521
+ false, // bias_requires_grad
522
+ non_null_dbias,
523
+ max_seqlen_q,
524
+ max_seqlen_k,
525
+ p_dropout,
526
+ softmax_scale,
527
+ zero_tensors,
528
+ is_causal,
529
+ non_null_window_left,
530
+ non_null_window_right,
531
+ deterministic,
532
+ philox_seed,
533
+ philox_offset);
534
+ // for FA return [dQ, dV, dK, dSoftmax]
535
+ return std::make_tuple(std::move(dQuery), std::move(dKey), std::move(dValue), std::move(dSoftmax));
536
+ }
537
+ #endif
538
+ return mha_varlen_bwd_aot(
539
+ dout,
540
+ q,
541
+ k,
542
+ v,
543
+ out,
544
+ softmax_lse,
545
+ dq_,
546
+ dk_,
547
+ dv_,
548
+ cu_seqlens_q,
549
+ cu_seqlens_k,
550
+ alibi_slopes_,
551
+ max_seqlen_q,
552
+ max_seqlen_k,
553
+ p_dropout,
554
+ softmax_scale,
555
+ zero_tensors,
556
+ is_causal,
557
+ window_size_left,
558
+ window_size_right,
559
+ deterministic,
560
+ philox_seed,
561
+ philox_offset);
562
+ }
563
+
564
+ } // namespace pytorch_flash
565
+
566
+ #else
567
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
568
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/hip/gemm_kernel_utils.h ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ // This file is a trimmed version of cuda/mem_eff_attention/gemm_kernel_utils.h
11
+ #pragma once
12
+
13
+ #define CHECK_NOSPARSE_CONTIGUOUS_CUDA(TENSOR) \
14
+ TORCH_CHECK(TENSOR.is_cuda(), #TENSOR " must be a CUDA tensor"); \
15
+ TORCH_CHECK(!TENSOR.is_sparse(), #TENSOR " must be a dense tensor"); \
16
+ TORCH_CHECK(TENSOR.is_contiguous());
17
+
18
+ #define CHECK_NOSPARSE_LASTCONTIGUOUS_CUDA(TENSOR) \
19
+ TORCH_CHECK(TENSOR.is_cuda(), #TENSOR " must be a CUDA tensor"); \
20
+ TORCH_CHECK(!TENSOR.is_sparse(), #TENSOR " must be a dense tensor"); \
21
+ TORCH_CHECK( \
22
+ TENSOR.stride(-1) == 1, #TENSOR ": last dimension must be contiguous");
23
+
24
+ #define CHECK_ALIGNED_PTR(PTR, ALIGNMENT) \
25
+ TORCH_CHECK( \
26
+ uint64_t(PTR) % ALIGNMENT == 0, #PTR " is not correctly aligned")
27
+
28
+ #define ASSIGN_CHECK_OVERFLOW(A, B) \
29
+ { \
30
+ A = B; \
31
+ TORCH_CHECK( \
32
+ B < std::numeric_limits<decltype(A)>::max(), #B " overflows"); \
33
+ }
34
+
35
+ #else
36
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
37
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/transformers/xpu/sdp_utils.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <ATen/Context.h>
5
+ #include <ATen/native/transformers/attention.h>
6
+ #include <ATen/native/transformers/sdp_utils_cpp.h>
7
+ #include <ATen/native/transformers/xpu/flash_attn/utils.h>
8
+ #include <ATen/xpu/XPUContext.h>
9
+
10
+ namespace sdp {
11
+
12
+ C10_EXPORT bool is_flash_attention_available();
13
+ C10_EXPORT bool can_use_flash_attention(sdp_params const& params, bool debug);
14
+ C10_EXPORT bool check_flash_attention_hardware_support(
15
+ sdp_params const& params,
16
+ bool debug);
17
+
18
+ } // namespace sdp
19
+
20
+ #else
21
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
22
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/utils/Factory.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <ATen/core/Tensor.h>
5
+
6
+ namespace at::native::mobile {
7
+
8
+ Tensor allocate_padded_contiguous_if_needed(
9
+ const Tensor& input,
10
+ c10::MemoryFormat memory_format);
11
+
12
+ // TODO: Remove this function when at::native::empty() is modified to accept a
13
+ // custom memory allocator.
14
+
15
+ at::Tensor empty_with_tail_padding(
16
+ IntArrayRef size,
17
+ const caffe2::TypeMeta dtype,
18
+ c10::MemoryFormat memory_format,
19
+ std::optional<DimnameList> maybe_names);
20
+
21
+ } // namespace at
22
+
23
+ #else
24
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
25
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/utils/ParamUtils.h ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <c10/util/ArrayRef.h>
5
+ #include <vector>
6
+
7
+ namespace at {
8
+ namespace native {
9
+
10
+ template <typename T>
11
+ inline std::vector<T> _expand_param_if_needed(
12
+ ArrayRef<T> list_param,
13
+ const char* param_name,
14
+ int64_t expected_dim) {
15
+ if (list_param.size() == 1) {
16
+ return std::vector<T>(expected_dim, list_param[0]);
17
+ } else if ((int64_t)list_param.size() != expected_dim) {
18
+ std::ostringstream ss;
19
+ ss << "expected " << param_name << " to be a single integer value or a "
20
+ << "list of " << expected_dim << " values to match the convolution "
21
+ << "dimensions, but got " << param_name << '=' << list_param;
22
+ TORCH_CHECK(false, ss.str());
23
+ } else {
24
+ return list_param.vec();
25
+ }
26
+ }
27
+
28
+ inline std::vector<int64_t> expand_param_if_needed(
29
+ IntArrayRef list_param,
30
+ const char* param_name,
31
+ int64_t expected_dim) {
32
+ return _expand_param_if_needed(list_param, param_name, expected_dim);
33
+ }
34
+
35
+ inline std::vector<c10::SymInt> expand_param_if_needed(
36
+ SymIntArrayRef list_param,
37
+ const char* param_name,
38
+ int64_t expected_dim) {
39
+ return _expand_param_if_needed(list_param, param_name, expected_dim);
40
+ }
41
+
42
+ } // namespace native
43
+ } // namespace at
44
+
45
+ #else
46
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
47
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/native/utils/ParamsHash.h ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <c10/util/irange.h>
5
+ #include <memory>
6
+ #include <mutex>
7
+
8
+ namespace at::native {
9
+
10
+ // Hashing machinery for Params
11
+ // Fowler–Noll–Vo hash function
12
+ // see
13
+ // https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
14
+ template <typename Params>
15
+ struct ParamsHash {
16
+ // Params must be a POD because we read out its memory
17
+ // contents as char* when hashing
18
+ static_assert(std::is_standard_layout_v<Params>, "Params is not POD");
19
+
20
+ size_t operator()(const Params& params) const {
21
+ auto ptr = reinterpret_cast<const uint8_t*>(&params);
22
+ uint32_t value = 0x811C9DC5;
23
+ for (const auto i : c10::irange(sizeof(Params))) {
24
+ value ^= ptr[i];
25
+ value *= 0x01000193;
26
+ }
27
+ return (size_t)value;
28
+ }
29
+ };
30
+
31
+ template <typename Params>
32
+ struct ParamsEqual {
33
+ // Params must be a POD because we read out its memory
34
+ // contents as char* when comparing
35
+ static_assert(std::is_standard_layout_v<Params>, "Params is not POD");
36
+
37
+ bool operator()(const Params& a, const Params& b) const {
38
+ auto ptr1 = reinterpret_cast<const uint8_t*>(&a);
39
+ auto ptr2 = reinterpret_cast<const uint8_t*>(&b);
40
+ return memcmp(ptr1, ptr2, sizeof(Params)) == 0;
41
+ }
42
+ };
43
+
44
+ // Provide explicit byte-for-byte constructors to avoid uwittingly leaving
45
+ // padding bytes uninitialized (e.g., when passing Params by value)
46
+ template <typename T>
47
+ struct ParamsWrapper {
48
+ T pod;
49
+ static_assert(
50
+ std::is_standard_layout_v<T>,
51
+ "ParamsWrapper cannot wrap non-POD data");
52
+
53
+ ParamsWrapper() {
54
+ memset(&(this->pod), 0, sizeof(this->pod));
55
+ }
56
+
57
+ ParamsWrapper(const ParamsWrapper& other) {
58
+ memcpy(&(this->pod), &(other.pod), sizeof(this->pod));
59
+ }
60
+
61
+ ParamsWrapper(ParamsWrapper&& other) noexcept {
62
+ memcpy(&(this->pod), &(other.pod), sizeof(this->pod));
63
+ }
64
+
65
+ ParamsWrapper& operator=(const ParamsWrapper& other) {
66
+ memcpy(&(this->pod), &(other.pod), sizeof(this->pod));
67
+ return *this;
68
+ }
69
+
70
+ ParamsWrapper& operator=(ParamsWrapper&& other) noexcept {
71
+ memcpy(&(this->pod), &(other.pod), sizeof(this->pod));
72
+ return *this;
73
+ }
74
+
75
+ inline friend bool operator==(
76
+ const ParamsWrapper& lhs,
77
+ const ParamsWrapper& rhs) noexcept {
78
+ auto ptr1 = reinterpret_cast<const uint8_t*>(&(lhs.pod));
79
+ auto ptr2 = reinterpret_cast<const uint8_t*>(&(rhs.pod));
80
+ return memcmp(ptr1, ptr2, sizeof(lhs.pod)) == 0;
81
+ }
82
+ };
83
+
84
+ // Wrapped version: this allows the outer struct to have custom copy and move
85
+ // constructors for additional safety
86
+ template <typename ParamsWrapper>
87
+ struct ParamsWrapperHash {
88
+ // Params must be a POD because we read out its memory
89
+ // contents as char* when hashing
90
+ static_assert(
91
+ std::is_standard_layout_v<decltype(ParamsWrapper::pod)>,
92
+ "ParamsWrapper cannot wrap non-POD data");
93
+
94
+ size_t operator()(const ParamsWrapper& params_wrapper) const {
95
+ auto ptr = reinterpret_cast<const uint8_t*>(&(params_wrapper.pod));
96
+ uint32_t value = 0x811C9DC5;
97
+ for (const auto i : c10::irange(sizeof(params_wrapper.pod))) {
98
+ value ^= ptr[i];
99
+ value *= 0x01000193;
100
+ }
101
+ return (size_t)value;
102
+ }
103
+ };
104
+
105
+ } // namespace at::native
106
+
107
+ #else
108
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
109
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d.h ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Function.h
5
+
6
+ #include <ATen/Context.h>
7
+ #include <ATen/DeviceGuard.h>
8
+ #include <ATen/TensorUtils.h>
9
+ #include <ATen/TracerMode.h>
10
+ #include <ATen/core/Generator.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <c10/core/Scalar.h>
14
+ #include <c10/core/Storage.h>
15
+ #include <c10/core/TensorOptions.h>
16
+ #include <c10/util/Deprecated.h>
17
+ #include <optional>
18
+ #include <string_view>
19
+
20
+
21
+
22
+ #include <ATen/ops/_adaptive_avg_pool2d_ops.h>
23
+
24
+ namespace at {
25
+
26
+
27
+ // aten::_adaptive_avg_pool2d(Tensor self, SymInt[2] output_size) -> Tensor
28
+ inline at::Tensor _adaptive_avg_pool2d(const at::Tensor & self, at::IntArrayRef output_size) {
29
+ return at::_ops::_adaptive_avg_pool2d::call(self, c10::fromIntArrayRefSlow(output_size));
30
+ }
31
+ namespace symint {
32
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, int64_t>>>
33
+ at::Tensor _adaptive_avg_pool2d(const at::Tensor & self, at::IntArrayRef output_size) {
34
+ return at::_ops::_adaptive_avg_pool2d::call(self, c10::fromIntArrayRefSlow(output_size));
35
+ }
36
+ }
37
+
38
+ // aten::_adaptive_avg_pool2d(Tensor self, SymInt[2] output_size) -> Tensor
39
+ inline at::Tensor _adaptive_avg_pool2d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size) {
40
+ return at::_ops::_adaptive_avg_pool2d::call(self, output_size);
41
+ }
42
+ namespace symint {
43
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, c10::SymInt>>>
44
+ at::Tensor _adaptive_avg_pool2d(const at::Tensor & self, c10::SymIntArrayRef output_size) {
45
+ return at::_ops::_adaptive_avg_pool2d::call(self, output_size);
46
+ }
47
+ }
48
+
49
+ // aten::_adaptive_avg_pool2d.out(Tensor self, SymInt[2] output_size, *, Tensor(a!) out) -> Tensor(a!)
50
+ inline at::Tensor & _adaptive_avg_pool2d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size) {
51
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
52
+ }
53
+ namespace symint {
54
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, int64_t>>>
55
+ at::Tensor & _adaptive_avg_pool2d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size) {
56
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
57
+ }
58
+ }
59
+
60
+ // aten::_adaptive_avg_pool2d.out(Tensor self, SymInt[2] output_size, *, Tensor(a!) out) -> Tensor(a!)
61
+ inline at::Tensor & _adaptive_avg_pool2d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out) {
62
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
63
+ }
64
+ namespace symint {
65
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, int64_t>>>
66
+ at::Tensor & _adaptive_avg_pool2d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out) {
67
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
68
+ }
69
+ }
70
+
71
+ // aten::_adaptive_avg_pool2d.out(Tensor self, SymInt[2] output_size, *, Tensor(a!) out) -> Tensor(a!)
72
+ inline at::Tensor & _adaptive_avg_pool2d_symint_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size) {
73
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, output_size, out);
74
+ }
75
+ namespace symint {
76
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, c10::SymInt>>>
77
+ at::Tensor & _adaptive_avg_pool2d_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size) {
78
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, output_size, out);
79
+ }
80
+ }
81
+
82
+ // aten::_adaptive_avg_pool2d.out(Tensor self, SymInt[2] output_size, *, Tensor(a!) out) -> Tensor(a!)
83
+ inline at::Tensor & _adaptive_avg_pool2d_symint_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out) {
84
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, output_size, out);
85
+ }
86
+ namespace symint {
87
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, c10::SymInt>>>
88
+ at::Tensor & _adaptive_avg_pool2d_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out) {
89
+ return at::_ops::_adaptive_avg_pool2d_out::call(self, output_size, out);
90
+ }
91
+ }
92
+
93
+ }
94
+
95
+ #else
96
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
97
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Function.h
5
+
6
+ #include <ATen/Context.h>
7
+ #include <ATen/DeviceGuard.h>
8
+ #include <ATen/TensorUtils.h>
9
+ #include <ATen/TracerMode.h>
10
+ #include <ATen/core/Generator.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <c10/core/Scalar.h>
14
+ #include <c10/core/Storage.h>
15
+ #include <c10/core/TensorOptions.h>
16
+ #include <c10/util/Deprecated.h>
17
+ #include <optional>
18
+ #include <string_view>
19
+
20
+
21
+
22
+ #include <ATen/ops/_adaptive_avg_pool2d_backward_ops.h>
23
+
24
+ namespace at {
25
+
26
+
27
+ // aten::_adaptive_avg_pool2d_backward(Tensor grad_output, Tensor self) -> Tensor
28
+ inline at::Tensor _adaptive_avg_pool2d_backward(const at::Tensor & grad_output, const at::Tensor & self) {
29
+ return at::_ops::_adaptive_avg_pool2d_backward::call(grad_output, self);
30
+ }
31
+
32
+ // aten::_adaptive_avg_pool2d_backward.out(Tensor grad_output, Tensor self, *, Tensor(a!) out) -> Tensor(a!)
33
+ inline at::Tensor & _adaptive_avg_pool2d_backward_out(at::Tensor & out, const at::Tensor & grad_output, const at::Tensor & self) {
34
+ return at::_ops::_adaptive_avg_pool2d_backward_out::call(grad_output, self, out);
35
+ }
36
+ // aten::_adaptive_avg_pool2d_backward.out(Tensor grad_output, Tensor self, *, Tensor(a!) out) -> Tensor(a!)
37
+ inline at::Tensor & _adaptive_avg_pool2d_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out) {
38
+ return at::_ops::_adaptive_avg_pool2d_backward_out::call(grad_output, self, out);
39
+ }
40
+
41
+ }
42
+
43
+ #else
44
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
45
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace compositeexplicitautograd {
20
+
21
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_backward_out(at::Tensor & out, const at::Tensor & grad_output, const at::Tensor & self);
22
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
23
+
24
+ } // namespace compositeexplicitautograd
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_cpu_dispatch.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cpu {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool2d_backward(const at::Tensor & grad_output, const at::Tensor & self);
22
+
23
+ } // namespace cpu
24
+ } // namespace at
25
+
26
+ #else
27
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
28
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_cuda_dispatch.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cuda {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool2d_backward(const at::Tensor & grad_output, const at::Tensor & self);
22
+
23
+ } // namespace cuda
24
+ } // namespace at
25
+
26
+ #else
27
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
28
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_native.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from NativeFunction.h
5
+
6
+ #include <c10/core/Scalar.h>
7
+ #include <c10/core/Storage.h>
8
+ #include <c10/core/TensorOptions.h>
9
+ #include <c10/util/Deprecated.h>
10
+ #include <optional>
11
+ #include <c10/core/QScheme.h>
12
+ #include <ATen/core/Reduction.h>
13
+ #include <ATen/core/Tensor.h>
14
+ #include <tuple>
15
+ #include <vector>
16
+
17
+
18
+ namespace at {
19
+ namespace native {
20
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_backward_out(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
21
+ TORCH_API at::Tensor adaptive_avg_pool2d_backward_cpu(const at::Tensor & grad_output, const at::Tensor & self);
22
+ TORCH_API at::Tensor adaptive_avg_pool2d_backward_cuda(const at::Tensor & grad_output, const at::Tensor & self);
23
+ } // namespace native
24
+ } // namespace at
25
+
26
+ #else
27
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
28
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_backward_ops.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Operator.h
5
+
6
+ #include <string_view>
7
+ #include <tuple>
8
+ #include <vector>
9
+
10
+ // Forward declarations of any types needed in the operator signatures.
11
+ // We can't directly include these classes because it will cause circular include dependencies.
12
+ // This file is included by TensorBody.h, which defines the Tensor class.
13
+ #include <ATen/core/ATen_fwd.h>
14
+
15
+ namespace at {
16
+ namespace _ops {
17
+
18
+
19
+ struct TORCH_API _adaptive_avg_pool2d_backward {
20
+ using schema = at::Tensor (const at::Tensor &, const at::Tensor &);
21
+ using ptr_schema = schema*;
22
+ // See Note [static constexpr char* members for windows NVCC]
23
+ static constexpr const char* name = "aten::_adaptive_avg_pool2d_backward";
24
+ static constexpr const char* overload_name = "";
25
+ static constexpr const char* schema_str = "_adaptive_avg_pool2d_backward(Tensor grad_output, Tensor self) -> Tensor";
26
+ static at::Tensor call(const at::Tensor & grad_output, const at::Tensor & self);
27
+ static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self);
28
+ };
29
+
30
+ struct TORCH_API _adaptive_avg_pool2d_backward_out {
31
+ using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, at::Tensor &);
32
+ using ptr_schema = schema*;
33
+ // See Note [static constexpr char* members for windows NVCC]
34
+ static constexpr const char* name = "aten::_adaptive_avg_pool2d_backward";
35
+ static constexpr const char* overload_name = "out";
36
+ static constexpr const char* schema_str = "_adaptive_avg_pool2d_backward.out(Tensor grad_output, Tensor self, *, Tensor(a!) out) -> Tensor(a!)";
37
+ static at::Tensor & call(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
38
+ static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
39
+ };
40
+
41
+ }} // namespace at::_ops
42
+
43
+ #else
44
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
45
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace compositeexplicitautograd {
20
+
21
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out);
23
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_symint_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size);
24
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_symint_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
25
+
26
+ } // namespace compositeexplicitautograd
27
+ } // namespace at
28
+
29
+ #else
30
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
31
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_cpu_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cpu {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool2d(const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor _adaptive_avg_pool2d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size);
23
+
24
+ } // namespace cpu
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_cuda_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cuda {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool2d(const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor _adaptive_avg_pool2d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size);
23
+
24
+ } // namespace cuda
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_native.h ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from NativeFunction.h
5
+
6
+ #include <c10/core/Scalar.h>
7
+ #include <c10/core/Storage.h>
8
+ #include <c10/core/TensorOptions.h>
9
+ #include <c10/util/Deprecated.h>
10
+ #include <optional>
11
+ #include <c10/core/QScheme.h>
12
+ #include <ATen/core/Reduction.h>
13
+ #include <ATen/core/Tensor.h>
14
+ #include <tuple>
15
+ #include <vector>
16
+
17
+
18
+ namespace at {
19
+ namespace native {
20
+ TORCH_API at::Tensor & _adaptive_avg_pool2d_out_symint(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
21
+ TORCH_API at::Tensor adaptive_avg_pool2d_cpu(const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor adaptive_avg_pool2d_cuda(const at::Tensor & self, at::IntArrayRef output_size);
23
+ TORCH_API at::Tensor adaptive_avg_pool2d_quantized_cpu(const at::Tensor & self, at::IntArrayRef output_size);
24
+ TORCH_API at::Tensor adaptive_avg_pool2d_quantized_cuda(const at::Tensor & self, at::IntArrayRef output_size);
25
+ } // namespace native
26
+ } // namespace at
27
+
28
+ #else
29
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
30
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool2d_ops.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Operator.h
5
+
6
+ #include <string_view>
7
+ #include <tuple>
8
+ #include <vector>
9
+
10
+ // Forward declarations of any types needed in the operator signatures.
11
+ // We can't directly include these classes because it will cause circular include dependencies.
12
+ // This file is included by TensorBody.h, which defines the Tensor class.
13
+ #include <ATen/core/ATen_fwd.h>
14
+
15
+ namespace at {
16
+ namespace _ops {
17
+
18
+
19
+ struct TORCH_API _adaptive_avg_pool2d {
20
+ using schema = at::Tensor (const at::Tensor &, c10::SymIntArrayRef);
21
+ using ptr_schema = schema*;
22
+ // See Note [static constexpr char* members for windows NVCC]
23
+ static constexpr const char* name = "aten::_adaptive_avg_pool2d";
24
+ static constexpr const char* overload_name = "";
25
+ static constexpr const char* schema_str = "_adaptive_avg_pool2d(Tensor self, SymInt[2] output_size) -> Tensor";
26
+ static at::Tensor call(const at::Tensor & self, c10::SymIntArrayRef output_size);
27
+ static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, c10::SymIntArrayRef output_size);
28
+ };
29
+
30
+ struct TORCH_API _adaptive_avg_pool2d_out {
31
+ using schema = at::Tensor & (const at::Tensor &, c10::SymIntArrayRef, at::Tensor &);
32
+ using ptr_schema = schema*;
33
+ // See Note [static constexpr char* members for windows NVCC]
34
+ static constexpr const char* name = "aten::_adaptive_avg_pool2d";
35
+ static constexpr const char* overload_name = "out";
36
+ static constexpr const char* schema_str = "_adaptive_avg_pool2d.out(Tensor self, SymInt[2] output_size, *, Tensor(a!) out) -> Tensor(a!)";
37
+ static at::Tensor & call(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
38
+ static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
39
+ };
40
+
41
+ }} // namespace at::_ops
42
+
43
+ #else
44
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
45
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d.h ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Function.h
5
+
6
+ #include <ATen/Context.h>
7
+ #include <ATen/DeviceGuard.h>
8
+ #include <ATen/TensorUtils.h>
9
+ #include <ATen/TracerMode.h>
10
+ #include <ATen/core/Generator.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <c10/core/Scalar.h>
14
+ #include <c10/core/Storage.h>
15
+ #include <c10/core/TensorOptions.h>
16
+ #include <c10/util/Deprecated.h>
17
+ #include <optional>
18
+ #include <string_view>
19
+
20
+
21
+
22
+ #include <ATen/ops/_adaptive_avg_pool3d_ops.h>
23
+
24
+ namespace at {
25
+
26
+
27
+ // aten::_adaptive_avg_pool3d(Tensor self, SymInt[3] output_size) -> Tensor
28
+ inline at::Tensor _adaptive_avg_pool3d(const at::Tensor & self, at::IntArrayRef output_size) {
29
+ return at::_ops::_adaptive_avg_pool3d::call(self, c10::fromIntArrayRefSlow(output_size));
30
+ }
31
+ namespace symint {
32
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, int64_t>>>
33
+ at::Tensor _adaptive_avg_pool3d(const at::Tensor & self, at::IntArrayRef output_size) {
34
+ return at::_ops::_adaptive_avg_pool3d::call(self, c10::fromIntArrayRefSlow(output_size));
35
+ }
36
+ }
37
+
38
+ // aten::_adaptive_avg_pool3d(Tensor self, SymInt[3] output_size) -> Tensor
39
+ inline at::Tensor _adaptive_avg_pool3d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size) {
40
+ return at::_ops::_adaptive_avg_pool3d::call(self, output_size);
41
+ }
42
+ namespace symint {
43
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, c10::SymInt>>>
44
+ at::Tensor _adaptive_avg_pool3d(const at::Tensor & self, c10::SymIntArrayRef output_size) {
45
+ return at::_ops::_adaptive_avg_pool3d::call(self, output_size);
46
+ }
47
+ }
48
+
49
+ // aten::_adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
50
+ inline at::Tensor & _adaptive_avg_pool3d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size) {
51
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
52
+ }
53
+ namespace symint {
54
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, int64_t>>>
55
+ at::Tensor & _adaptive_avg_pool3d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size) {
56
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
57
+ }
58
+ }
59
+
60
+ // aten::_adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
61
+ inline at::Tensor & _adaptive_avg_pool3d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out) {
62
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
63
+ }
64
+ namespace symint {
65
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, int64_t>>>
66
+ at::Tensor & _adaptive_avg_pool3d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out) {
67
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
68
+ }
69
+ }
70
+
71
+ // aten::_adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
72
+ inline at::Tensor & _adaptive_avg_pool3d_symint_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size) {
73
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, output_size, out);
74
+ }
75
+ namespace symint {
76
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, c10::SymInt>>>
77
+ at::Tensor & _adaptive_avg_pool3d_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size) {
78
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, output_size, out);
79
+ }
80
+ }
81
+
82
+ // aten::_adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
83
+ inline at::Tensor & _adaptive_avg_pool3d_symint_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out) {
84
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, output_size, out);
85
+ }
86
+ namespace symint {
87
+ template <typename T, typename = std::enable_if_t<std::is_same_v<T, c10::SymInt>>>
88
+ at::Tensor & _adaptive_avg_pool3d_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out) {
89
+ return at::_ops::_adaptive_avg_pool3d_out::call(self, output_size, out);
90
+ }
91
+ }
92
+
93
+ }
94
+
95
+ #else
96
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
97
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Function.h
5
+
6
+ #include <ATen/Context.h>
7
+ #include <ATen/DeviceGuard.h>
8
+ #include <ATen/TensorUtils.h>
9
+ #include <ATen/TracerMode.h>
10
+ #include <ATen/core/Generator.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <c10/core/Scalar.h>
14
+ #include <c10/core/Storage.h>
15
+ #include <c10/core/TensorOptions.h>
16
+ #include <c10/util/Deprecated.h>
17
+ #include <optional>
18
+ #include <string_view>
19
+
20
+
21
+
22
+ #include <ATen/ops/_adaptive_avg_pool3d_backward_ops.h>
23
+
24
+ namespace at {
25
+
26
+
27
+ // aten::_adaptive_avg_pool3d_backward(Tensor grad_output, Tensor self) -> Tensor
28
+ inline at::Tensor _adaptive_avg_pool3d_backward(const at::Tensor & grad_output, const at::Tensor & self) {
29
+ return at::_ops::_adaptive_avg_pool3d_backward::call(grad_output, self);
30
+ }
31
+
32
+ // aten::_adaptive_avg_pool3d_backward.out(Tensor grad_output, Tensor self, *, Tensor(a!) out) -> Tensor(a!)
33
+ inline at::Tensor & _adaptive_avg_pool3d_backward_out(at::Tensor & out, const at::Tensor & grad_output, const at::Tensor & self) {
34
+ return at::_ops::_adaptive_avg_pool3d_backward_out::call(grad_output, self, out);
35
+ }
36
+ // aten::_adaptive_avg_pool3d_backward.out(Tensor grad_output, Tensor self, *, Tensor(a!) out) -> Tensor(a!)
37
+ inline at::Tensor & _adaptive_avg_pool3d_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out) {
38
+ return at::_ops::_adaptive_avg_pool3d_backward_out::call(grad_output, self, out);
39
+ }
40
+
41
+ }
42
+
43
+ #else
44
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
45
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace compositeexplicitautograd {
20
+
21
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_backward_out(at::Tensor & out, const at::Tensor & grad_output, const at::Tensor & self);
22
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
23
+
24
+ } // namespace compositeexplicitautograd
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_cpu_dispatch.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cpu {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool3d_backward(const at::Tensor & grad_output, const at::Tensor & self);
22
+
23
+ } // namespace cpu
24
+ } // namespace at
25
+
26
+ #else
27
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
28
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_cuda_dispatch.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cuda {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool3d_backward(const at::Tensor & grad_output, const at::Tensor & self);
22
+
23
+ } // namespace cuda
24
+ } // namespace at
25
+
26
+ #else
27
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
28
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_native.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from NativeFunction.h
5
+
6
+ #include <c10/core/Scalar.h>
7
+ #include <c10/core/Storage.h>
8
+ #include <c10/core/TensorOptions.h>
9
+ #include <c10/util/Deprecated.h>
10
+ #include <optional>
11
+ #include <c10/core/QScheme.h>
12
+ #include <ATen/core/Reduction.h>
13
+ #include <ATen/core/Tensor.h>
14
+ #include <tuple>
15
+ #include <vector>
16
+
17
+
18
+ namespace at {
19
+ namespace native {
20
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_backward_out(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
21
+ TORCH_API at::Tensor adaptive_avg_pool3d_backward_cpu(const at::Tensor & grad_output, const at::Tensor & self);
22
+ TORCH_API at::Tensor adaptive_avg_pool3d_backward_cuda(const at::Tensor & grad_output, const at::Tensor & self);
23
+ } // namespace native
24
+ } // namespace at
25
+
26
+ #else
27
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
28
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_backward_ops.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Operator.h
5
+
6
+ #include <string_view>
7
+ #include <tuple>
8
+ #include <vector>
9
+
10
+ // Forward declarations of any types needed in the operator signatures.
11
+ // We can't directly include these classes because it will cause circular include dependencies.
12
+ // This file is included by TensorBody.h, which defines the Tensor class.
13
+ #include <ATen/core/ATen_fwd.h>
14
+
15
+ namespace at {
16
+ namespace _ops {
17
+
18
+
19
+ struct TORCH_API _adaptive_avg_pool3d_backward {
20
+ using schema = at::Tensor (const at::Tensor &, const at::Tensor &);
21
+ using ptr_schema = schema*;
22
+ // See Note [static constexpr char* members for windows NVCC]
23
+ static constexpr const char* name = "aten::_adaptive_avg_pool3d_backward";
24
+ static constexpr const char* overload_name = "";
25
+ static constexpr const char* schema_str = "_adaptive_avg_pool3d_backward(Tensor grad_output, Tensor self) -> Tensor";
26
+ static at::Tensor call(const at::Tensor & grad_output, const at::Tensor & self);
27
+ static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self);
28
+ };
29
+
30
+ struct TORCH_API _adaptive_avg_pool3d_backward_out {
31
+ using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, at::Tensor &);
32
+ using ptr_schema = schema*;
33
+ // See Note [static constexpr char* members for windows NVCC]
34
+ static constexpr const char* name = "aten::_adaptive_avg_pool3d_backward";
35
+ static constexpr const char* overload_name = "out";
36
+ static constexpr const char* schema_str = "_adaptive_avg_pool3d_backward.out(Tensor grad_output, Tensor self, *, Tensor(a!) out) -> Tensor(a!)";
37
+ static at::Tensor & call(const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
38
+ static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self, at::Tensor & out);
39
+ };
40
+
41
+ }} // namespace at::_ops
42
+
43
+ #else
44
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
45
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace compositeexplicitautograd {
20
+
21
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out);
23
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_symint_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size);
24
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_symint_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
25
+
26
+ } // namespace compositeexplicitautograd
27
+ } // namespace at
28
+
29
+ #else
30
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
31
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_cpu_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cpu {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool3d(const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor _adaptive_avg_pool3d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size);
23
+
24
+ } // namespace cpu
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_cuda_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cuda {
20
+
21
+ TORCH_API at::Tensor _adaptive_avg_pool3d(const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor _adaptive_avg_pool3d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size);
23
+
24
+ } // namespace cuda
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_native.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from NativeFunction.h
5
+
6
+ #include <c10/core/Scalar.h>
7
+ #include <c10/core/Storage.h>
8
+ #include <c10/core/TensorOptions.h>
9
+ #include <c10/util/Deprecated.h>
10
+ #include <optional>
11
+ #include <c10/core/QScheme.h>
12
+ #include <ATen/core/Reduction.h>
13
+ #include <ATen/core/Tensor.h>
14
+ #include <tuple>
15
+ #include <vector>
16
+
17
+
18
+ namespace at {
19
+ namespace native {
20
+ TORCH_API at::Tensor & _adaptive_avg_pool3d_out_symint(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
21
+ TORCH_API at::Tensor adaptive_avg_pool3d_cpu(const at::Tensor & self, at::IntArrayRef output_size);
22
+ TORCH_API at::Tensor adaptive_avg_pool3d_cuda(const at::Tensor & self, at::IntArrayRef output_size);
23
+ TORCH_API at::Tensor adaptive_avg_pool3d_quantized_cpu(const at::Tensor & self, at::IntArrayRef output_size);
24
+ } // namespace native
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_adaptive_avg_pool3d_ops.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Operator.h
5
+
6
+ #include <string_view>
7
+ #include <tuple>
8
+ #include <vector>
9
+
10
+ // Forward declarations of any types needed in the operator signatures.
11
+ // We can't directly include these classes because it will cause circular include dependencies.
12
+ // This file is included by TensorBody.h, which defines the Tensor class.
13
+ #include <ATen/core/ATen_fwd.h>
14
+
15
+ namespace at {
16
+ namespace _ops {
17
+
18
+
19
+ struct TORCH_API _adaptive_avg_pool3d {
20
+ using schema = at::Tensor (const at::Tensor &, c10::SymIntArrayRef);
21
+ using ptr_schema = schema*;
22
+ // See Note [static constexpr char* members for windows NVCC]
23
+ static constexpr const char* name = "aten::_adaptive_avg_pool3d";
24
+ static constexpr const char* overload_name = "";
25
+ static constexpr const char* schema_str = "_adaptive_avg_pool3d(Tensor self, SymInt[3] output_size) -> Tensor";
26
+ static at::Tensor call(const at::Tensor & self, c10::SymIntArrayRef output_size);
27
+ static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, c10::SymIntArrayRef output_size);
28
+ };
29
+
30
+ struct TORCH_API _adaptive_avg_pool3d_out {
31
+ using schema = at::Tensor & (const at::Tensor &, c10::SymIntArrayRef, at::Tensor &);
32
+ using ptr_schema = schema*;
33
+ // See Note [static constexpr char* members for windows NVCC]
34
+ static constexpr const char* name = "aten::_adaptive_avg_pool3d";
35
+ static constexpr const char* overload_name = "out";
36
+ static constexpr const char* schema_str = "_adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)";
37
+ static at::Tensor & call(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
38
+ static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out);
39
+ };
40
+
41
+ }} // namespace at::_ops
42
+
43
+ #else
44
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
45
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim.h ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Function.h
5
+
6
+ #include <ATen/Context.h>
7
+ #include <ATen/DeviceGuard.h>
8
+ #include <ATen/TensorUtils.h>
9
+ #include <ATen/TracerMode.h>
10
+ #include <ATen/core/Generator.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <c10/core/Scalar.h>
14
+ #include <c10/core/Storage.h>
15
+ #include <c10/core/TensorOptions.h>
16
+ #include <c10/util/Deprecated.h>
17
+ #include <optional>
18
+ #include <string_view>
19
+
20
+
21
+
22
+ #include <ATen/ops/_add_batch_dim_ops.h>
23
+
24
+ namespace at {
25
+
26
+
27
+ // aten::_add_batch_dim(Tensor self, int batch_dim, int level) -> Tensor
28
+ inline at::Tensor _add_batch_dim(const at::Tensor & self, int64_t batch_dim, int64_t level) {
29
+ return at::_ops::_add_batch_dim::call(self, batch_dim, level);
30
+ }
31
+
32
+ }
33
+
34
+ #else
35
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
36
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim_compositeimplicitautograd_dispatch.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace compositeimplicitautograd {
20
+
21
+ TORCH_API at::Tensor _add_batch_dim(const at::Tensor & self, int64_t batch_dim, int64_t level);
22
+
23
+ } // namespace compositeimplicitautograd
24
+ } // namespace at
25
+
26
+ #else
27
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
28
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim_native.h ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from NativeFunction.h
5
+
6
+ #include <c10/core/Scalar.h>
7
+ #include <c10/core/Storage.h>
8
+ #include <c10/core/TensorOptions.h>
9
+ #include <c10/util/Deprecated.h>
10
+ #include <optional>
11
+ #include <c10/core/QScheme.h>
12
+ #include <ATen/core/Reduction.h>
13
+ #include <ATen/core/Tensor.h>
14
+ #include <tuple>
15
+ #include <vector>
16
+
17
+
18
+ namespace at {
19
+ namespace native {
20
+ TORCH_API at::Tensor _add_batch_dim(const at::Tensor & self, int64_t batch_dim, int64_t level);
21
+ } // namespace native
22
+ } // namespace at
23
+
24
+ #else
25
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
26
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_batch_dim_ops.h ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Operator.h
5
+
6
+ #include <string_view>
7
+ #include <tuple>
8
+ #include <vector>
9
+
10
+ // Forward declarations of any types needed in the operator signatures.
11
+ // We can't directly include these classes because it will cause circular include dependencies.
12
+ // This file is included by TensorBody.h, which defines the Tensor class.
13
+ #include <ATen/core/ATen_fwd.h>
14
+
15
+ namespace at {
16
+ namespace _ops {
17
+
18
+
19
+ struct TORCH_API _add_batch_dim {
20
+ using schema = at::Tensor (const at::Tensor &, int64_t, int64_t);
21
+ using ptr_schema = schema*;
22
+ // See Note [static constexpr char* members for windows NVCC]
23
+ static constexpr const char* name = "aten::_add_batch_dim";
24
+ static constexpr const char* overload_name = "";
25
+ static constexpr const char* schema_str = "_add_batch_dim(Tensor self, int batch_dim, int level) -> Tensor";
26
+ static at::Tensor call(const at::Tensor & self, int64_t batch_dim, int64_t level);
27
+ static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, int64_t batch_dim, int64_t level);
28
+ };
29
+
30
+ }} // namespace at::_ops
31
+
32
+ #else
33
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
34
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu.h ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ // @generated by torchgen/gen.py from Function.h
5
+
6
+ #include <ATen/Context.h>
7
+ #include <ATen/DeviceGuard.h>
8
+ #include <ATen/TensorUtils.h>
9
+ #include <ATen/TracerMode.h>
10
+ #include <ATen/core/Generator.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <c10/core/Scalar.h>
14
+ #include <c10/core/Storage.h>
15
+ #include <c10/core/TensorOptions.h>
16
+ #include <c10/util/Deprecated.h>
17
+ #include <optional>
18
+ #include <string_view>
19
+
20
+
21
+
22
+ #include <ATen/ops/_add_relu_ops.h>
23
+
24
+ namespace at {
25
+
26
+
27
+ // aten::_add_relu.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor
28
+ inline at::Tensor _add_relu(const at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1) {
29
+ return at::_ops::_add_relu_Tensor::call(self, other, alpha);
30
+ }
31
+
32
+ // aten::_add_relu_.Tensor(Tensor(a!) self, Tensor other, *, Scalar alpha=1) -> Tensor(a!)
33
+ inline at::Tensor & _add_relu_(at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1) {
34
+ return at::_ops::_add_relu__Tensor::call(self, other, alpha);
35
+ }
36
+
37
+ // aten::_add_relu.out(Tensor self, Tensor other, *, Scalar alpha=1, Tensor(a!) out) -> Tensor(a!)
38
+ inline at::Tensor & _add_relu_out(at::Tensor & out, const at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1) {
39
+ return at::_ops::_add_relu_out::call(self, other, alpha, out);
40
+ }
41
+ // aten::_add_relu.out(Tensor self, Tensor other, *, Scalar alpha=1, Tensor(a!) out) -> Tensor(a!)
42
+ inline at::Tensor & _add_relu_outf(const at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha, at::Tensor & out) {
43
+ return at::_ops::_add_relu_out::call(self, other, alpha, out);
44
+ }
45
+
46
+ // aten::_add_relu.Scalar(Tensor self, Scalar other, Scalar alpha=1) -> Tensor
47
+ inline at::Tensor _add_relu(const at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1) {
48
+ return at::_ops::_add_relu_Scalar::call(self, other, alpha);
49
+ }
50
+
51
+ // aten::_add_relu_.Scalar(Tensor(a!) self, Scalar other, Scalar alpha=1) -> Tensor(a!)
52
+ inline at::Tensor & _add_relu_(at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1) {
53
+ return at::_ops::_add_relu__Scalar::call(self, other, alpha);
54
+ }
55
+
56
+ // aten::_add_relu.Scalar_out(Tensor self, Scalar other, Scalar alpha=1, *, Tensor(a!) out) -> Tensor(a!)
57
+ inline at::Tensor & _add_relu_out(at::Tensor & out, const at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1) {
58
+ return at::_ops::_add_relu_Scalar_out::call(self, other, alpha, out);
59
+ }
60
+ // aten::_add_relu.Scalar_out(Tensor self, Scalar other, Scalar alpha=1, *, Tensor(a!) out) -> Tensor(a!)
61
+ inline at::Tensor & _add_relu_outf(const at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha, at::Tensor & out) {
62
+ return at::_ops::_add_relu_Scalar_out::call(self, other, alpha, out);
63
+ }
64
+
65
+ }
66
+
67
+ #else
68
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
69
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace compositeexplicitautograd {
20
+
21
+ TORCH_API at::Tensor & _add_relu_out(at::Tensor & out, const at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1);
22
+ TORCH_API at::Tensor & _add_relu_outf(const at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha, at::Tensor & out);
23
+
24
+ } // namespace compositeexplicitautograd
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_cpu_dispatch.h ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace cpu {
20
+
21
+ TORCH_API at::Tensor _add_relu(const at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1);
22
+ TORCH_API at::Tensor & _add_relu_out(at::Tensor & out, const at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1);
23
+ TORCH_API at::Tensor & _add_relu_outf(const at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha, at::Tensor & out);
24
+ TORCH_API at::Tensor & _add_relu_(at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1);
25
+ TORCH_API at::Tensor _add_relu(const at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1);
26
+ TORCH_API at::Tensor & _add_relu_(at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1);
27
+
28
+ } // namespace cpu
29
+ } // namespace at
30
+
31
+ #else
32
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
33
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_meta_dispatch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
4
+
5
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
6
+
7
+ // The only #includes we need are for custom classes that have defaults in the C++ API
8
+ #include <c10/core/MemoryFormat.h>
9
+ #include <c10/core/Scalar.h>
10
+ #include <ATen/core/Reduction.h>
11
+
12
+ // Forward declarations of any types needed in the operator signatures.
13
+ // We can't directly include these classes because it will cause circular include dependencies.
14
+ // This file is included by TensorBody.h, which defines the Tensor class.
15
+ #include <ATen/core/ATen_fwd.h>
16
+
17
+ namespace at {
18
+
19
+ namespace meta {
20
+
21
+ TORCH_API at::Tensor & _add_relu_(at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1);
22
+ TORCH_API at::Tensor & _add_relu_(at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1);
23
+
24
+ } // namespace meta
25
+ } // namespace at
26
+
27
+ #else
28
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
29
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)