warp-lang 0.9.0__py3-none-win_amd64.whl → 0.11.0__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of warp-lang might be problematic. Click here for more details.

Files changed (315) hide show
  1. warp/__init__.py +15 -7
  2. warp/__init__.pyi +1 -0
  3. warp/bin/warp-clang.dll +0 -0
  4. warp/bin/warp.dll +0 -0
  5. warp/build.py +22 -443
  6. warp/build_dll.py +384 -0
  7. warp/builtins.py +998 -488
  8. warp/codegen.py +1307 -739
  9. warp/config.py +5 -3
  10. warp/constants.py +6 -0
  11. warp/context.py +1291 -548
  12. warp/dlpack.py +31 -31
  13. warp/fabric.py +326 -0
  14. warp/fem/__init__.py +27 -0
  15. warp/fem/cache.py +389 -0
  16. warp/fem/dirichlet.py +181 -0
  17. warp/fem/domain.py +263 -0
  18. warp/fem/field/__init__.py +101 -0
  19. warp/fem/field/field.py +149 -0
  20. warp/fem/field/nodal_field.py +299 -0
  21. warp/fem/field/restriction.py +21 -0
  22. warp/fem/field/test.py +181 -0
  23. warp/fem/field/trial.py +183 -0
  24. warp/fem/geometry/__init__.py +19 -0
  25. warp/fem/geometry/closest_point.py +70 -0
  26. warp/fem/geometry/deformed_geometry.py +271 -0
  27. warp/fem/geometry/element.py +744 -0
  28. warp/fem/geometry/geometry.py +186 -0
  29. warp/fem/geometry/grid_2d.py +373 -0
  30. warp/fem/geometry/grid_3d.py +435 -0
  31. warp/fem/geometry/hexmesh.py +953 -0
  32. warp/fem/geometry/partition.py +376 -0
  33. warp/fem/geometry/quadmesh_2d.py +532 -0
  34. warp/fem/geometry/tetmesh.py +840 -0
  35. warp/fem/geometry/trimesh_2d.py +577 -0
  36. warp/fem/integrate.py +1616 -0
  37. warp/fem/operator.py +191 -0
  38. warp/fem/polynomial.py +213 -0
  39. warp/fem/quadrature/__init__.py +2 -0
  40. warp/fem/quadrature/pic_quadrature.py +245 -0
  41. warp/fem/quadrature/quadrature.py +294 -0
  42. warp/fem/space/__init__.py +292 -0
  43. warp/fem/space/basis_space.py +489 -0
  44. warp/fem/space/collocated_function_space.py +105 -0
  45. warp/fem/space/dof_mapper.py +236 -0
  46. warp/fem/space/function_space.py +145 -0
  47. warp/fem/space/grid_2d_function_space.py +267 -0
  48. warp/fem/space/grid_3d_function_space.py +306 -0
  49. warp/fem/space/hexmesh_function_space.py +352 -0
  50. warp/fem/space/partition.py +350 -0
  51. warp/fem/space/quadmesh_2d_function_space.py +369 -0
  52. warp/fem/space/restriction.py +160 -0
  53. warp/fem/space/shape/__init__.py +15 -0
  54. warp/fem/space/shape/cube_shape_function.py +738 -0
  55. warp/fem/space/shape/shape_function.py +103 -0
  56. warp/fem/space/shape/square_shape_function.py +611 -0
  57. warp/fem/space/shape/tet_shape_function.py +567 -0
  58. warp/fem/space/shape/triangle_shape_function.py +429 -0
  59. warp/fem/space/tetmesh_function_space.py +292 -0
  60. warp/fem/space/topology.py +295 -0
  61. warp/fem/space/trimesh_2d_function_space.py +221 -0
  62. warp/fem/types.py +77 -0
  63. warp/fem/utils.py +495 -0
  64. warp/native/array.h +164 -55
  65. warp/native/builtin.h +150 -174
  66. warp/native/bvh.cpp +75 -328
  67. warp/native/bvh.cu +406 -23
  68. warp/native/bvh.h +37 -45
  69. warp/native/clang/clang.cpp +136 -24
  70. warp/native/crt.cpp +1 -76
  71. warp/native/crt.h +111 -104
  72. warp/native/cuda_crt.h +1049 -0
  73. warp/native/cuda_util.cpp +15 -3
  74. warp/native/cuda_util.h +3 -1
  75. warp/native/cutlass/tools/library/scripts/conv2d_operation.py +463 -0
  76. warp/native/cutlass/tools/library/scripts/conv3d_operation.py +321 -0
  77. warp/native/cutlass/tools/library/scripts/gemm_operation.py +988 -0
  78. warp/native/cutlass/tools/library/scripts/generator.py +4625 -0
  79. warp/native/cutlass/tools/library/scripts/library.py +799 -0
  80. warp/native/cutlass/tools/library/scripts/manifest.py +402 -0
  81. warp/native/cutlass/tools/library/scripts/pycutlass/docs/source/conf.py +96 -0
  82. warp/native/cutlass/tools/library/scripts/pycutlass/profile/conv/conv2d_f16_sm80.py +106 -0
  83. warp/native/cutlass/tools/library/scripts/pycutlass/profile/gemm/gemm_f32_sm80.py +91 -0
  84. warp/native/cutlass/tools/library/scripts/pycutlass/setup.py +80 -0
  85. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/__init__.py +48 -0
  86. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/arguments.py +118 -0
  87. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/c_types.py +241 -0
  88. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/compiler.py +432 -0
  89. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/conv2d_operation.py +631 -0
  90. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/epilogue.py +1026 -0
  91. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/frontend.py +104 -0
  92. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/gemm_operation.py +1276 -0
  93. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/library.py +744 -0
  94. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/memory_manager.py +74 -0
  95. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/operation.py +110 -0
  96. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/parser.py +619 -0
  97. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/reduction_operation.py +398 -0
  98. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/tensor_ref.py +70 -0
  99. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/__init__.py +4 -0
  100. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/conv2d_testbed.py +646 -0
  101. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_grouped_testbed.py +235 -0
  102. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_testbed.py +557 -0
  103. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/profiler.py +70 -0
  104. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/type_hint.py +39 -0
  105. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/__init__.py +1 -0
  106. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/device.py +76 -0
  107. warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/reference_model.py +255 -0
  108. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/__init__.py +0 -0
  109. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +201 -0
  110. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +177 -0
  111. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +98 -0
  112. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +95 -0
  113. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_few_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +163 -0
  114. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_fixed_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +187 -0
  115. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +309 -0
  116. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +54 -0
  117. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
  118. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
  119. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_strided_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +253 -0
  120. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +97 -0
  121. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +242 -0
  122. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
  123. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
  124. warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/run_all_tests.py +10 -0
  125. warp/native/cutlass/tools/library/scripts/pycutlass/test/frontend/test_frontend.py +146 -0
  126. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/__init__.py +0 -0
  127. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_bf16_sm80.py +96 -0
  128. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f16_sm80.py +447 -0
  129. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f32_sm80.py +146 -0
  130. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f64_sm80.py +102 -0
  131. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_grouped_sm80.py +203 -0
  132. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_s8_sm80.py +229 -0
  133. warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/run_all_tests.py +9 -0
  134. warp/native/cutlass/tools/library/scripts/pycutlass/test/unit/test_sm80.py +453 -0
  135. warp/native/cutlass/tools/library/scripts/rank_2k_operation.py +398 -0
  136. warp/native/cutlass/tools/library/scripts/rank_k_operation.py +387 -0
  137. warp/native/cutlass/tools/library/scripts/rt.py +796 -0
  138. warp/native/cutlass/tools/library/scripts/symm_operation.py +400 -0
  139. warp/native/cutlass/tools/library/scripts/trmm_operation.py +407 -0
  140. warp/native/cutlass_gemm.cu +5 -3
  141. warp/native/exports.h +1240 -949
  142. warp/native/fabric.h +228 -0
  143. warp/native/hashgrid.cpp +4 -4
  144. warp/native/hashgrid.h +22 -2
  145. warp/native/initializer_array.h +2 -2
  146. warp/native/intersect.h +22 -7
  147. warp/native/intersect_adj.h +8 -8
  148. warp/native/intersect_tri.h +13 -16
  149. warp/native/marching.cu +157 -161
  150. warp/native/mat.h +119 -19
  151. warp/native/matnn.h +2 -2
  152. warp/native/mesh.cpp +108 -83
  153. warp/native/mesh.cu +243 -6
  154. warp/native/mesh.h +1547 -458
  155. warp/native/nanovdb/NanoVDB.h +1 -1
  156. warp/native/noise.h +272 -329
  157. warp/native/quat.h +51 -8
  158. warp/native/rand.h +45 -35
  159. warp/native/range.h +6 -2
  160. warp/native/reduce.cpp +157 -0
  161. warp/native/reduce.cu +348 -0
  162. warp/native/runlength_encode.cpp +62 -0
  163. warp/native/runlength_encode.cu +46 -0
  164. warp/native/scan.cu +11 -13
  165. warp/native/scan.h +1 -0
  166. warp/native/solid_angle.h +442 -0
  167. warp/native/sort.cpp +13 -0
  168. warp/native/sort.cu +9 -1
  169. warp/native/sparse.cpp +338 -0
  170. warp/native/sparse.cu +545 -0
  171. warp/native/spatial.h +2 -2
  172. warp/native/temp_buffer.h +30 -0
  173. warp/native/vec.h +126 -24
  174. warp/native/volume.h +120 -0
  175. warp/native/warp.cpp +658 -53
  176. warp/native/warp.cu +660 -68
  177. warp/native/warp.h +112 -12
  178. warp/optim/__init__.py +1 -0
  179. warp/optim/linear.py +922 -0
  180. warp/optim/sgd.py +92 -0
  181. warp/render/render_opengl.py +392 -152
  182. warp/render/render_usd.py +11 -11
  183. warp/sim/__init__.py +2 -2
  184. warp/sim/articulation.py +385 -185
  185. warp/sim/collide.py +21 -8
  186. warp/sim/import_mjcf.py +297 -106
  187. warp/sim/import_urdf.py +389 -210
  188. warp/sim/import_usd.py +198 -97
  189. warp/sim/inertia.py +17 -18
  190. warp/sim/integrator_euler.py +14 -8
  191. warp/sim/integrator_xpbd.py +161 -19
  192. warp/sim/model.py +795 -291
  193. warp/sim/optimizer.py +2 -6
  194. warp/sim/render.py +65 -3
  195. warp/sim/utils.py +3 -0
  196. warp/sparse.py +1227 -0
  197. warp/stubs.py +665 -223
  198. warp/tape.py +66 -15
  199. warp/tests/__main__.py +3 -6
  200. warp/tests/assets/curlnoise_golden.npy +0 -0
  201. warp/tests/assets/pnoise_golden.npy +0 -0
  202. warp/tests/assets/torus.usda +105 -105
  203. warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
  204. warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
  205. warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
  206. warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
  207. warp/tests/aux_test_unresolved_func.py +14 -0
  208. warp/tests/aux_test_unresolved_symbol.py +14 -0
  209. warp/tests/disabled_kinematics.py +239 -0
  210. warp/tests/run_coverage_serial.py +31 -0
  211. warp/tests/test_adam.py +103 -106
  212. warp/tests/test_arithmetic.py +128 -74
  213. warp/tests/test_array.py +1497 -211
  214. warp/tests/test_array_reduce.py +150 -0
  215. warp/tests/test_atomic.py +64 -28
  216. warp/tests/test_bool.py +99 -0
  217. warp/tests/test_builtins_resolution.py +1292 -0
  218. warp/tests/test_bvh.py +75 -43
  219. warp/tests/test_closest_point_edge_edge.py +54 -57
  220. warp/tests/test_codegen.py +233 -128
  221. warp/tests/test_compile_consts.py +28 -20
  222. warp/tests/test_conditional.py +108 -24
  223. warp/tests/test_copy.py +10 -12
  224. warp/tests/test_ctypes.py +112 -88
  225. warp/tests/test_dense.py +21 -14
  226. warp/tests/test_devices.py +98 -0
  227. warp/tests/test_dlpack.py +136 -108
  228. warp/tests/test_examples.py +277 -0
  229. warp/tests/test_fabricarray.py +955 -0
  230. warp/tests/test_fast_math.py +15 -11
  231. warp/tests/test_fem.py +1271 -0
  232. warp/tests/test_fp16.py +53 -19
  233. warp/tests/test_func.py +187 -74
  234. warp/tests/test_generics.py +194 -49
  235. warp/tests/test_grad.py +180 -116
  236. warp/tests/test_grad_customs.py +176 -0
  237. warp/tests/test_hash_grid.py +52 -37
  238. warp/tests/test_import.py +10 -23
  239. warp/tests/test_indexedarray.py +577 -24
  240. warp/tests/test_intersect.py +18 -9
  241. warp/tests/test_large.py +141 -0
  242. warp/tests/test_launch.py +251 -15
  243. warp/tests/test_lerp.py +64 -65
  244. warp/tests/test_linear_solvers.py +154 -0
  245. warp/tests/test_lvalue.py +493 -0
  246. warp/tests/test_marching_cubes.py +12 -13
  247. warp/tests/test_mat.py +508 -2778
  248. warp/tests/test_mat_lite.py +115 -0
  249. warp/tests/test_mat_scalar_ops.py +2889 -0
  250. warp/tests/test_math.py +103 -9
  251. warp/tests/test_matmul.py +305 -69
  252. warp/tests/test_matmul_lite.py +410 -0
  253. warp/tests/test_mesh.py +71 -14
  254. warp/tests/test_mesh_query_aabb.py +41 -25
  255. warp/tests/test_mesh_query_point.py +325 -34
  256. warp/tests/test_mesh_query_ray.py +39 -22
  257. warp/tests/test_mlp.py +30 -22
  258. warp/tests/test_model.py +92 -89
  259. warp/tests/test_modules_lite.py +39 -0
  260. warp/tests/test_multigpu.py +88 -114
  261. warp/tests/test_noise.py +12 -11
  262. warp/tests/test_operators.py +16 -20
  263. warp/tests/test_options.py +11 -11
  264. warp/tests/test_pinned.py +17 -18
  265. warp/tests/test_print.py +32 -11
  266. warp/tests/test_quat.py +275 -129
  267. warp/tests/test_rand.py +18 -16
  268. warp/tests/test_reload.py +38 -34
  269. warp/tests/test_rounding.py +50 -43
  270. warp/tests/test_runlength_encode.py +190 -0
  271. warp/tests/test_smoothstep.py +9 -11
  272. warp/tests/test_snippet.py +143 -0
  273. warp/tests/test_sparse.py +460 -0
  274. warp/tests/test_spatial.py +276 -243
  275. warp/tests/test_streams.py +110 -85
  276. warp/tests/test_struct.py +331 -85
  277. warp/tests/test_tape.py +39 -21
  278. warp/tests/test_torch.py +118 -89
  279. warp/tests/test_transient_module.py +12 -13
  280. warp/tests/test_types.py +614 -0
  281. warp/tests/test_utils.py +494 -0
  282. warp/tests/test_vec.py +354 -1987
  283. warp/tests/test_vec_lite.py +73 -0
  284. warp/tests/test_vec_scalar_ops.py +2099 -0
  285. warp/tests/test_volume.py +457 -293
  286. warp/tests/test_volume_write.py +124 -134
  287. warp/tests/unittest_serial.py +35 -0
  288. warp/tests/unittest_suites.py +341 -0
  289. warp/tests/unittest_utils.py +568 -0
  290. warp/tests/unused_test_misc.py +71 -0
  291. warp/tests/{test_debug.py → walkthough_debug.py} +3 -17
  292. warp/thirdparty/appdirs.py +36 -45
  293. warp/thirdparty/unittest_parallel.py +549 -0
  294. warp/torch.py +72 -30
  295. warp/types.py +1744 -713
  296. warp/utils.py +360 -350
  297. warp_lang-0.11.0.dist-info/LICENSE.md +36 -0
  298. warp_lang-0.11.0.dist-info/METADATA +238 -0
  299. warp_lang-0.11.0.dist-info/RECORD +332 -0
  300. {warp_lang-0.9.0.dist-info → warp_lang-0.11.0.dist-info}/WHEEL +1 -1
  301. warp/bin/warp-clang.exp +0 -0
  302. warp/bin/warp-clang.lib +0 -0
  303. warp/bin/warp.exp +0 -0
  304. warp/bin/warp.lib +0 -0
  305. warp/tests/test_all.py +0 -215
  306. warp/tests/test_array_scan.py +0 -60
  307. warp/tests/test_base.py +0 -208
  308. warp/tests/test_unresolved_func.py +0 -7
  309. warp/tests/test_unresolved_symbol.py +0 -7
  310. warp_lang-0.9.0.dist-info/METADATA +0 -20
  311. warp_lang-0.9.0.dist-info/RECORD +0 -177
  312. /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
  313. /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
  314. /warp/tests/{test_square.py → aux_test_square.py} +0 -0
  315. {warp_lang-0.9.0.dist-info → warp_lang-0.11.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,799 @@
1
+ #
2
+ # \file generator.py
3
+ #
4
+ # \brief Generates the CUTLASS Library's instances
5
+ #
6
+
7
+ import re
8
+
9
+ ###################################################################################################
10
+
11
+ import enum
12
+
13
+ # The following block implements enum.auto() for Python 3.5 variants that don't include it such
14
+ # as the default 3.5.2 on Ubuntu 16.04.
15
+ #
16
+ # https://codereview.stackexchange.com/questions/177309/reimplementing-pythons-enum-auto-for-compatibility
17
+
18
+ try:
19
+ from enum import auto as enum_auto
20
+ except ImportError:
21
+ __cutlass_library_auto_enum = 0
22
+ def enum_auto() -> int:
23
+ global __cutlass_library_auto_enum
24
+ i = __cutlass_library_auto_enum
25
+ __cutlass_library_auto_enum += 1
26
+ return i
27
+
28
+ ###################################################################################################
29
+
30
+ #
31
+ class GeneratorTarget(enum.Enum):
32
+ Library = enum_auto()
33
+ #
34
+ GeneratorTargetNames = {
35
+ GeneratorTarget.Library: 'library'
36
+ }
37
+ #
38
+
39
+ ###################################################################################################
40
+
41
+ #
42
+ class DataType(enum.Enum):
43
+ b1 = enum_auto()
44
+ u4 = enum_auto()
45
+ u8 = enum_auto()
46
+ u16 = enum_auto()
47
+ u32 = enum_auto()
48
+ u64 = enum_auto()
49
+ s4 = enum_auto()
50
+ s8 = enum_auto()
51
+ s16 = enum_auto()
52
+ s32 = enum_auto()
53
+ s64 = enum_auto()
54
+ f16 = enum_auto()
55
+ bf16 = enum_auto()
56
+ f32 = enum_auto()
57
+ tf32 = enum_auto()
58
+ f64 = enum_auto()
59
+ cf16 = enum_auto()
60
+ cbf16 = enum_auto()
61
+ cf32 = enum_auto()
62
+ ctf32 = enum_auto()
63
+ cf64 = enum_auto()
64
+ cs4 = enum_auto()
65
+ cs8 = enum_auto()
66
+ cs16 = enum_auto()
67
+ cs32 = enum_auto()
68
+ cs64 = enum_auto()
69
+ cu4 = enum_auto()
70
+ cu8 = enum_auto()
71
+ cu16 = enum_auto()
72
+ cu32 = enum_auto()
73
+ cu64 = enum_auto()
74
+ invalid = enum_auto()
75
+
76
+ #
77
+ ShortDataTypeNames = {
78
+ DataType.s32: 'i',
79
+ DataType.f16: 'h',
80
+ DataType.f32: 's',
81
+ DataType.f64: 'd',
82
+ DataType.cf32: 'c',
83
+ DataType.cf64: 'z',
84
+ }
85
+
86
+ #
87
+ DataTypeNames = {
88
+ DataType.b1: "b1",
89
+ DataType.u4: "u4",
90
+ DataType.u8: "u8",
91
+ DataType.u16: "u16",
92
+ DataType.u32: "u32",
93
+ DataType.u64: "u64",
94
+ DataType.s4: "s4",
95
+ DataType.s8: "s8",
96
+ DataType.s16: "s16",
97
+ DataType.s32: "s32",
98
+ DataType.s64: "s64",
99
+ DataType.f16: "f16",
100
+ DataType.bf16: "bf16",
101
+ DataType.f32: "f32",
102
+ DataType.tf32: "tf32",
103
+ DataType.f64: "f64",
104
+ DataType.cf16: "cf16",
105
+ DataType.cbf16: "cbf16",
106
+ DataType.cf32: "cf32",
107
+ DataType.ctf32: "ctf32",
108
+ DataType.cf64: "cf64",
109
+ DataType.cu4: "cu4",
110
+ DataType.cu8: "cu8",
111
+ DataType.cu16: "cu16",
112
+ DataType.cu32: "cu32",
113
+ DataType.cu64: "cu64",
114
+ DataType.cs4: "cs4",
115
+ DataType.cs8: "cs8",
116
+ DataType.cs16: "cs16",
117
+ DataType.cs32: "cs32",
118
+ DataType.cs64: "cs64",
119
+ }
120
+
121
+ DataTypeTag = {
122
+ DataType.b1: "cutlass::uint1b_t",
123
+ DataType.u4: "cutlass::uint4b_t",
124
+ DataType.u8: "uint8_t",
125
+ DataType.u16: "uint16_t",
126
+ DataType.u32: "uint32_t",
127
+ DataType.u64: "uint64_t",
128
+ DataType.s4: "cutlass::int4b_t",
129
+ DataType.s8: "int8_t",
130
+ DataType.s16: "int16_t",
131
+ DataType.s32: "int32_t",
132
+ DataType.s64: "int64_t",
133
+ DataType.f16: "cutlass::half_t",
134
+ DataType.bf16: "cutlass::bfloat16_t",
135
+ DataType.f32: "float",
136
+ DataType.tf32: "cutlass::tfloat32_t",
137
+ DataType.f64: "double",
138
+ DataType.cf16: "cutlass::complex<cutlass::half_t>",
139
+ DataType.cbf16: "cutlass::complex<cutlass::bfloat16_t>",
140
+ DataType.cf32: "cutlass::complex<float>",
141
+ DataType.ctf32: "cutlass::complex<cutlass::tfloat32_t>",
142
+ DataType.cf64: "cutlass::complex<double>",
143
+ DataType.cu4: "cutlass::complex<cutlass::uint4b_t>",
144
+ DataType.cu8: "cutlass::complex<cutlass::uint8_t>",
145
+ DataType.cu16: "cutlass::complex<cutlass::uint16_t>",
146
+ DataType.cu32: "cutlass::complex<cutlass::uint32_t>",
147
+ DataType.cu64: "cutlass::complex<cutlass::uint64_t>",
148
+ DataType.cs4: "cutlass::complex<cutlass::int4b_t>",
149
+ DataType.cs8: "cutlass::complex<cutlass::int8_t>",
150
+ DataType.cs16: "cutlass::complex<cutlass::int16_t>",
151
+ DataType.cs32: "cutlass::complex<cutlass::int32_t>",
152
+ DataType.cs64: "cutlass::complex<cutlass::int64_t>",
153
+ }
154
+
155
+ DataTypeSize = {
156
+ DataType.b1: 1,
157
+ DataType.u4: 4,
158
+ DataType.u8: 8,
159
+ DataType.u16: 16,
160
+ DataType.u32: 32,
161
+ DataType.u64: 64,
162
+ DataType.s4: 4,
163
+ DataType.s8: 8,
164
+ DataType.s16: 16,
165
+ DataType.s32: 32,
166
+ DataType.s64: 64,
167
+ DataType.f16: 16,
168
+ DataType.bf16: 16,
169
+ DataType.f32: 32,
170
+ DataType.tf32: 32,
171
+ DataType.f64: 64,
172
+ DataType.cf16: 32,
173
+ DataType.cbf16: 32,
174
+ DataType.cf32: 64,
175
+ DataType.ctf32: 32,
176
+ DataType.cf64: 128,
177
+ DataType.cu4: 8,
178
+ DataType.cu8: 16,
179
+ DataType.cu16: 32,
180
+ DataType.cu32: 64,
181
+ DataType.cu64: 128,
182
+ DataType.cs4: 8,
183
+ DataType.cs8: 16,
184
+ DataType.cs16: 32,
185
+ DataType.cs32: 64,
186
+ DataType.cs64: 128,
187
+ }
188
+
189
+ ###################################################################################################
190
+ #
191
+ class BlasMode(enum.Enum):
192
+ symmetric = enum_auto()
193
+ hermitian = enum_auto()
194
+
195
+ #
196
+ BlasModeTag = {
197
+ BlasMode.symmetric: 'cutlass::BlasMode::kSymmetric',
198
+ BlasMode.hermitian: 'cutlass::BlasMode::kHermitian',
199
+ }
200
+
201
+ #
202
+ class ComplexTransform(enum.Enum):
203
+ none = enum_auto()
204
+ conj = enum_auto()
205
+
206
+ #
207
+ ComplexTransformTag = {
208
+ ComplexTransform.none: 'cutlass::ComplexTransform::kNone',
209
+ ComplexTransform.conj: 'cutlass::ComplexTransform::kConjugate',
210
+ }
211
+
212
+ #
213
+ RealComplexBijection = [
214
+ (DataType.f16, DataType.cf16),
215
+ (DataType.f32, DataType.cf32),
216
+ (DataType.f64, DataType.cf64),
217
+ ]
218
+
219
+ #
220
+ def is_complex(data_type):
221
+ for r, c in RealComplexBijection:
222
+ if data_type == c:
223
+ return True
224
+ return False
225
+
226
+ #
227
+ def get_complex_from_real(real_type):
228
+ for r, c in RealComplexBijection:
229
+ if real_type == r:
230
+ return c
231
+ return DataType.invalid
232
+
233
+ #
234
+ def get_real_from_complex(complex_type):
235
+ for r, c in RealComplexBijection:
236
+ if complex_type == c:
237
+ return r
238
+ return DataType.invalid
239
+
240
+ #
241
+ class ComplexMultiplyOp(enum.Enum):
242
+ multiply_add = enum_auto()
243
+ gaussian = enum_auto()
244
+
245
+ ###################################################################################################
246
+
247
+ #
248
+ class MathOperation(enum.Enum):
249
+ multiply_add = enum_auto()
250
+ multiply_add_saturate = enum_auto()
251
+ xor_popc = enum_auto()
252
+ multiply_add_fast_bf16 = enum_auto()
253
+ multiply_add_fast_f16 = enum_auto()
254
+ multiply_add_fast_f32 = enum_auto()
255
+ multiply_add_complex_fast_f32 = enum_auto()
256
+ multiply_add_complex = enum_auto()
257
+ multiply_add_complex_gaussian = enum_auto()
258
+
259
+ #
260
+ MathOperationTag = {
261
+ MathOperation.multiply_add: 'cutlass::arch::OpMultiplyAdd',
262
+ MathOperation.multiply_add_saturate: 'cutlass::arch::OpMultiplyAddSaturate',
263
+ MathOperation.xor_popc: 'cutlass::arch::OpXorPopc',
264
+ MathOperation.multiply_add_fast_bf16: 'cutlass::arch::OpMultiplyAddFastBF16',
265
+ MathOperation.multiply_add_fast_f16: 'cutlass::arch::OpMultiplyAddFastF16',
266
+ MathOperation.multiply_add_fast_f32: 'cutlass::arch::OpMultiplyAddFastF32',
267
+ MathOperation.multiply_add_complex_fast_f32: 'cutlass::arch::OpMultiplyAddComplexFastF32',
268
+ MathOperation.multiply_add_complex: 'cutlass::arch::OpMultiplyAddComplex',
269
+ MathOperation.multiply_add_complex_gaussian: 'cutlass::arch::OpMultiplyAddGaussianComplex',
270
+ }
271
+
272
+ ###################################################################################################
273
+
274
+ #
275
+ class LayoutType(enum.Enum):
276
+ ColumnMajor = enum_auto()
277
+ RowMajor = enum_auto()
278
+ ColumnMajorInterleaved2 = enum_auto()
279
+ RowMajorInterleaved2 = enum_auto()
280
+ ColumnMajorInterleaved32 = enum_auto()
281
+ RowMajorInterleaved32 = enum_auto()
282
+ ColumnMajorInterleaved64 = enum_auto()
283
+ RowMajorInterleaved64 = enum_auto()
284
+ TensorNHWC = enum_auto()
285
+ TensorNDHWC = enum_auto()
286
+ TensorNCHW = enum_auto()
287
+ TensorNGHWC = enum_auto()
288
+ TensorNC32HW32 = enum_auto()
289
+ TensorNC64HW64 = enum_auto()
290
+ TensorC32RSK32 = enum_auto()
291
+ TensorC64RSK64 = enum_auto()
292
+
293
+ #
294
+ LayoutTag = {
295
+ LayoutType.ColumnMajor: 'cutlass::layout::ColumnMajor',
296
+ LayoutType.RowMajor: 'cutlass::layout::RowMajor',
297
+ LayoutType.ColumnMajorInterleaved2: 'cutlass::layout::ColumnMajorInterleaved<2>',
298
+ LayoutType.RowMajorInterleaved2: 'cutlass::layout::RowMajorInterleaved<2>',
299
+ LayoutType.ColumnMajorInterleaved32: 'cutlass::layout::ColumnMajorInterleaved<32>',
300
+ LayoutType.RowMajorInterleaved32: 'cutlass::layout::RowMajorInterleaved<32>',
301
+ LayoutType.ColumnMajorInterleaved64: 'cutlass::layout::ColumnMajorInterleaved<64>',
302
+ LayoutType.RowMajorInterleaved64: 'cutlass::layout::RowMajorInterleaved<64>',
303
+ LayoutType.TensorNHWC: 'cutlass::layout::TensorNHWC',
304
+ LayoutType.TensorNDHWC: 'cutlass::layout::TensorNDHWC',
305
+ LayoutType.TensorNCHW: 'cutlass::layout::TensorNCHW',
306
+ LayoutType.TensorNGHWC: 'cutlass::layout::TensorNGHWC',
307
+ LayoutType.TensorNC32HW32: 'cutlass::layout::TensorNCxHWx<32>',
308
+ LayoutType.TensorC32RSK32: 'cutlass::layout::TensorCxRSKx<32>',
309
+ LayoutType.TensorNC64HW64: 'cutlass::layout::TensorNCxHWx<64>',
310
+ LayoutType.TensorC64RSK64: 'cutlass::layout::TensorCxRSKx<64>',
311
+ }
312
+
313
+ #
314
+ TransposedLayout = {
315
+ LayoutType.ColumnMajor: LayoutType.RowMajor,
316
+ LayoutType.RowMajor: LayoutType.ColumnMajor,
317
+ LayoutType.ColumnMajorInterleaved2: LayoutType.RowMajorInterleaved2,
318
+ LayoutType.RowMajorInterleaved2: LayoutType.ColumnMajorInterleaved2,
319
+ LayoutType.ColumnMajorInterleaved32: LayoutType.RowMajorInterleaved32,
320
+ LayoutType.RowMajorInterleaved32: LayoutType.ColumnMajorInterleaved32,
321
+ LayoutType.ColumnMajorInterleaved64: LayoutType.RowMajorInterleaved64,
322
+ LayoutType.RowMajorInterleaved64: LayoutType.ColumnMajorInterleaved64,
323
+ LayoutType.TensorNHWC: LayoutType.TensorNHWC
324
+ }
325
+
326
+ #
327
+ ShortLayoutTypeNames = {
328
+ LayoutType.ColumnMajor: 'n',
329
+ LayoutType.ColumnMajorInterleaved2: 'n2',
330
+ LayoutType.ColumnMajorInterleaved32: 'n32',
331
+ LayoutType.ColumnMajorInterleaved64: 'n64',
332
+ LayoutType.RowMajor: 't',
333
+ LayoutType.RowMajorInterleaved2: 't2',
334
+ LayoutType.RowMajorInterleaved32: 't32',
335
+ LayoutType.RowMajorInterleaved64: 't64',
336
+ LayoutType.TensorNHWC: 'nhwc',
337
+ LayoutType.TensorNDHWC: 'ndhwc',
338
+ LayoutType.TensorNCHW: 'nchw',
339
+ LayoutType.TensorNGHWC: 'nghwc',
340
+ LayoutType.TensorNC32HW32: 'nc32hw32',
341
+ LayoutType.TensorNC64HW64: 'nc64hw64',
342
+ LayoutType.TensorC32RSK32: 'c32rsk32',
343
+ LayoutType.TensorC64RSK64: 'c64rsk64'
344
+ }
345
+
346
+ #
347
+ ShortComplexLayoutNames = {
348
+ (LayoutType.ColumnMajor, ComplexTransform.none): 'n',
349
+ (LayoutType.ColumnMajor, ComplexTransform.conj): 'c',
350
+ (LayoutType.RowMajor, ComplexTransform.none): 't',
351
+ (LayoutType.RowMajor, ComplexTransform.conj): 'h'
352
+ }
353
+
354
+ ###################################################################################################
355
+
356
+ #
357
+ class SideMode(enum.Enum):
358
+ Left = enum_auto()
359
+ Right = enum_auto()
360
+
361
+ #
362
+ SideModeTag = {
363
+ SideMode.Left: 'cutlass::SideMode::kLeft',
364
+ SideMode.Right: 'cutlass::SideMode::kRight'
365
+ }
366
+
367
+ #
368
+ ShortSideModeNames = {
369
+ SideMode.Left: 'ls',
370
+ SideMode.Right: 'rs'
371
+ }
372
+
373
+ ###################################################################################################
374
+
375
+ #
376
+ class FillMode(enum.Enum):
377
+ Lower = enum_auto()
378
+ Upper = enum_auto()
379
+
380
+ #
381
+ FillModeTag = {
382
+ FillMode.Lower: 'cutlass::FillMode::kLower',
383
+ FillMode.Upper: 'cutlass::FillMode::kUpper'
384
+ }
385
+
386
+ #
387
+ ShortFillModeNames = {
388
+ FillMode.Lower: 'l',
389
+ FillMode.Upper: 'u'
390
+ }
391
+
392
+ ###################################################################################################
393
+
394
+ #
395
+ class DiagType(enum.Enum):
396
+ NonUnit = enum_auto()
397
+ Unit = enum_auto()
398
+
399
+ #
400
+ DiagTypeTag = {
401
+ DiagType.NonUnit: 'cutlass::DiagType::kNonUnit',
402
+ DiagType.Unit: 'cutlass::DiagType::kUnit'
403
+ }
404
+
405
+ #
406
+ ShortDiagTypeNames = {
407
+ DiagType.NonUnit: 'nu',
408
+ DiagType.Unit: 'un'
409
+ }
410
+
411
+ ###################################################################################################
412
+
413
+ #
414
+ class OpcodeClass(enum.Enum):
415
+ Simt = enum_auto()
416
+ TensorOp = enum_auto()
417
+ WmmaTensorOp = enum_auto()
418
+ SparseTensorOp = enum_auto()
419
+
420
+
421
+ OpcodeClassNames = {
422
+ OpcodeClass.Simt: 'simt',
423
+ OpcodeClass.TensorOp: 'tensorop',
424
+ OpcodeClass.WmmaTensorOp: 'wmma_tensorop',
425
+ }
426
+
427
+ OpcodeClassTag = {
428
+ OpcodeClass.Simt: 'cutlass::arch::OpClassSimt',
429
+ OpcodeClass.TensorOp: 'cutlass::arch::OpClassTensorOp',
430
+ OpcodeClass.WmmaTensorOp: 'cutlass::arch::OpClassWmmaTensorOp',
431
+ }
432
+
433
+ ###################################################################################################
434
+
435
+ #
436
+ class OperationKind(enum.Enum):
437
+ Gemm = enum_auto()
438
+ RankK = enum_auto()
439
+ Rank2K = enum_auto()
440
+ Trmm = enum_auto()
441
+ Symm = enum_auto()
442
+ Conv2d = enum_auto()
443
+ Conv3d = enum_auto()
444
+
445
+ #
446
+ OperationKindNames = {
447
+ OperationKind.Gemm: 'gemm'
448
+ , OperationKind.RankK: 'rank_k'
449
+ , OperationKind.Rank2K: 'rank_2k'
450
+ , OperationKind.Trmm: 'trmm'
451
+ , OperationKind.Symm: 'symm'
452
+ , OperationKind.Conv2d: 'conv2d'
453
+ , OperationKind.Conv3d: 'conv3d'
454
+ }
455
+
456
+ #
457
+ class Target(enum.Enum):
458
+ library = enum_auto()
459
+ #
460
+ ArchitectureNames = {
461
+ 50: 'maxwell',
462
+ 60: 'pascal',
463
+ 61: 'pascal',
464
+ 70: 'volta',
465
+ 75: 'turing',
466
+ 80: 'ampere',
467
+ }
468
+
469
+ #
470
+ SharedMemPerCC = {
471
+ 70: 96, # 96KB of SMEM
472
+ 72: 96, # 96KB of SMEM
473
+ 75: 64, # 64KB of SMEM
474
+ 80: 163, # 163KB of SMEM - 1KB reserved for the driver
475
+ 86: 99, # 99KB of SMEM - 1KB reserved for the driver
476
+ 87: 163, # 163KB of SMEM - 1KB reserved for the driver
477
+ 89: 99, # 99KB of SMEM - 1KB reserved for the driver
478
+ 90: 227, # 227KB of SMEM - 1KB reserved for the driver
479
+ }
480
+
481
+ ###################################################################################################
482
+
483
+ #
484
+ def SubstituteTemplate(template, values):
485
+ text = template
486
+ changed = True
487
+ while changed:
488
+ changed = False
489
+ for key, value in values.items():
490
+ regex = "\\$\\{%s\\}" % key
491
+ newtext = re.sub(regex, value, text)
492
+ if newtext != text:
493
+ changed = True
494
+ text = newtext
495
+ return text
496
+
497
+ ###################################################################################################
498
+
499
+ #
500
+ class GemmKind(enum.Enum):
501
+ Gemm = enum_auto()
502
+ Sparse = enum_auto()
503
+ Universal = enum_auto()
504
+ PlanarComplex = enum_auto()
505
+ PlanarComplexArray = enum_auto()
506
+ Grouped = enum_auto()
507
+
508
+ #
509
+ GemmKindNames = {
510
+ GemmKind.Gemm: "gemm",
511
+ GemmKind.Sparse: "spgemm",
512
+ GemmKind.Universal: "gemm",
513
+ GemmKind.PlanarComplex: "gemm_planar_complex",
514
+ GemmKind.PlanarComplexArray: "gemm_planar_complex_array",
515
+ GemmKind.Grouped: "gemm_grouped"
516
+ }
517
+
518
+ #
519
+ class RankKKind(enum.Enum):
520
+ Universal = enum_auto()
521
+
522
+ #
523
+ RankKKindNames = {
524
+ RankKKind.Universal: "rank_k"
525
+ }
526
+
527
+ #
528
+ class TrmmKind(enum.Enum):
529
+ Universal = enum_auto()
530
+
531
+ #
532
+ TrmmKindNames = {
533
+ TrmmKind.Universal: "trmm"
534
+ }
535
+
536
+ #
537
+ class SymmKind(enum.Enum):
538
+ Universal = enum_auto()
539
+
540
+ #
541
+ SymmKindNames = {
542
+ SymmKind.Universal: "symm"
543
+ }
544
+
545
+ #
546
+ class EpilogueFunctor(enum.Enum):
547
+ LinearCombination = enum_auto()
548
+ LinearCombinationClamp = enum_auto()
549
+
550
+ #
551
+ EpilogueFunctorTag = {
552
+ EpilogueFunctor.LinearCombination: 'cutlass::epilogue::thread::LinearCombination',
553
+ EpilogueFunctor.LinearCombinationClamp: 'cutlass::epilogue::thread::LinearCombinationClamp',
554
+ }
555
+
556
+ #
557
+ class SwizzlingFunctor(enum.Enum):
558
+ Identity1 = enum_auto()
559
+ Identity2 = enum_auto()
560
+ Identity4 = enum_auto()
561
+ Identity8 = enum_auto()
562
+ Horizontal = enum_auto()
563
+ StridedDgradIdentity1 = enum_auto()
564
+ StridedDgradIdentity4 = enum_auto()
565
+ StridedDgradHorizontal = enum_auto()
566
+ StreamK = enum_auto()
567
+
568
+ #
569
+ SwizzlingFunctorTag = {
570
+ SwizzlingFunctor.Identity1: 'cutlass::gemm::threadblock::GemmIdentityThreadblockSwizzle<1>',
571
+ SwizzlingFunctor.Identity2: 'cutlass::gemm::threadblock::GemmIdentityThreadblockSwizzle<2>',
572
+ SwizzlingFunctor.Identity4: 'cutlass::gemm::threadblock::GemmIdentityThreadblockSwizzle<4>',
573
+ SwizzlingFunctor.Identity8: 'cutlass::gemm::threadblock::GemmIdentityThreadblockSwizzle<8>',
574
+ SwizzlingFunctor.Horizontal: 'cutlass::gemm::threadblock::GemmHorizontalThreadblockSwizzle',
575
+ SwizzlingFunctor.StridedDgradIdentity1: 'cutlass::conv::threadblock::StridedDgradIdentityThreadblockSwizzle<1>',
576
+ SwizzlingFunctor.StridedDgradIdentity4: 'cutlass::conv::threadblock::StridedDgradIdentityThreadblockSwizzle<4>',
577
+ SwizzlingFunctor.StridedDgradHorizontal: 'cutlass::conv::threadblock::StridedDgradHorizontalThreadblockSwizzle',
578
+ SwizzlingFunctor.StreamK: 'cutlass::gemm::threadblock::ThreadblockSwizzleStreamK',
579
+ }
580
+
581
+ #
582
+ class GroupScheduleMode(enum.Enum):
583
+ Device = enum_auto(),
584
+ Host = enum_auto()
585
+
586
+ #
587
+ GroupScheduleModeTag = {
588
+ GroupScheduleMode.Device: 'cutlass::gemm::kernel::GroupScheduleMode::kDeviceOnly',
589
+ GroupScheduleMode.Host: 'cutlass::gemm::kernel::GroupScheduleMode::kHostPrecompute'
590
+ }
591
+
592
+ #
593
+ ShortGroupScheduleModeNames = {
594
+ GroupScheduleMode.Device: 'Device',
595
+ GroupScheduleMode.Host: 'Host'
596
+ }
597
+
598
+ ###################################################################################################
599
+
600
+ #
601
+ class ConvKind(enum.Enum):
602
+ Fprop = enum_auto()
603
+ Dgrad = enum_auto()
604
+ Wgrad = enum_auto()
605
+
606
+ #
607
+ ConvKindTag = {
608
+ ConvKind.Fprop: 'cutlass::conv::Operator::kFprop',
609
+ ConvKind.Dgrad: 'cutlass::conv::Operator::kDgrad',
610
+ ConvKind.Wgrad: 'cutlass::conv::Operator::kWgrad'
611
+ }
612
+
613
+ ConvKindNames = {
614
+ ConvKind.Fprop: 'fprop',
615
+ ConvKind.Dgrad: 'dgrad',
616
+ ConvKind.Wgrad: 'wgrad',
617
+ }
618
+
619
+ #
620
+ class IteratorAlgorithm(enum.Enum):
621
+ Analytic = enum_auto()
622
+ Optimized = enum_auto()
623
+ FixedChannels = enum_auto()
624
+ FewChannels = enum_auto()
625
+ FixedStrideDilation = enum_auto()
626
+
627
+ #
628
+ IteratorAlgorithmTag = {
629
+ IteratorAlgorithm.Analytic: 'cutlass::conv::IteratorAlgorithm::kAnalytic',
630
+ IteratorAlgorithm.Optimized: 'cutlass::conv::IteratorAlgorithm::kOptimized',
631
+ IteratorAlgorithm.FixedChannels: 'cutlass::conv::IteratorAlgorithm::kFixedChannels',
632
+ IteratorAlgorithm.FewChannels: 'cutlass::conv::IteratorAlgorithm::kFewChannels',
633
+ IteratorAlgorithm.FixedStrideDilation: 'cutlass::conv::IteratorAlgorithm::kFixedStrideDilation'
634
+ }
635
+
636
+ IteratorAlgorithmNames = {
637
+ IteratorAlgorithm.Analytic: 'analytic',
638
+ IteratorAlgorithm.Optimized: 'optimized',
639
+ IteratorAlgorithm.FixedChannels: 'fixed_channels',
640
+ IteratorAlgorithm.FewChannels: 'few_channels',
641
+ IteratorAlgorithm.FixedStrideDilation: 'fixed_stride_dilation'
642
+ }
643
+
644
+ #
645
+ class StrideSupport(enum.Enum):
646
+ Strided = enum_auto()
647
+ Unity = enum_auto()
648
+ Fixed = enum_auto()
649
+
650
+ #
651
+ StrideSupportTag = {
652
+ StrideSupport.Strided: 'cutlass::conv::StrideSupport::kStrided',
653
+ StrideSupport.Unity: 'cutlass::conv::StrideSupport::kUnity',
654
+ StrideSupport.Fixed: 'cutlass::conv::StrideSupport::kFixed'
655
+ }
656
+
657
+ StrideSupportNames = {
658
+ StrideSupport.Strided: '',
659
+ StrideSupport.Unity: 'unity_stride',
660
+ StrideSupport.Fixed: 'fixed_stride'
661
+ }
662
+
663
+ #
664
+ class GroupMode(enum.Enum):
665
+ NoneGroup = enum_auto() # dense conv (G=1)
666
+ SingleGroup = enum_auto() # grouped convolution (single group per CTA)
667
+ MultipleGroup = enum_auto() # grouped convolution ( multiple groups per CTA)
668
+ Depthwise = enum_auto() # Depthwise convolution ( C=K=G )
669
+
670
+ #
671
+ GroupModeTag = {
672
+ GroupMode.NoneGroup: 'cutlass::conv::GroupMode::kNone',
673
+ GroupMode.SingleGroup: 'cutlass::conv::GroupMode::kSingleGroup',
674
+ GroupMode.MultipleGroup: 'cutlass::conv::GroupMode::kMultipleGroup',
675
+ GroupMode.Depthwise: 'cutlass::conv::GroupMode::kDepthwise',
676
+ }
677
+
678
+ GroupModeNames = {
679
+ GroupMode.NoneGroup: '',
680
+ GroupMode.SingleGroup: 'single_group',
681
+ GroupMode.MultipleGroup: 'multiple_group',
682
+ GroupMode.Depthwise: 'depthwise',
683
+ }
684
+
685
+ ###################################################################################################
686
+
687
+ #
688
+ class MathInstruction:
689
+ def __init__(self, instruction_shape, element_a, element_b, element_accumulator, opcode_class, math_operation = MathOperation.multiply_add):
690
+ self.instruction_shape = instruction_shape
691
+ self.element_a = element_a
692
+ self.element_b = element_b
693
+ self.element_accumulator = element_accumulator
694
+ self.opcode_class = opcode_class
695
+ self.math_operation = math_operation
696
+
697
+ #
698
+ class TileDescription:
699
+
700
+ def __init__(self, threadblock_shape, stages, warp_count, math_instruction, min_compute, max_compute):
701
+ self.threadblock_shape = threadblock_shape
702
+ self.stages = stages
703
+ self.warp_count = warp_count
704
+ self.math_instruction = math_instruction
705
+ self.minimum_compute_capability = min_compute
706
+ self.maximum_compute_capability = max_compute
707
+
708
+ def procedural_name(self):
709
+ return "%dx%d_%dx%d" % (self.threadblock_shape[0], self.threadblock_shape[1], self.threadblock_shape[2], self.stages)
710
+
711
+ #
712
+ class Direct2dConvFixedStrideDilationTileDescription:
713
+ def __init__(self, threadblock_output_shape, filter_shape, stages, stride, dilation, warp_count, math_instruction, min_compute, max_compute):
714
+ self.threadblock_shape = [threadblock_output_shape[0]*threadblock_output_shape[1]*threadblock_output_shape[2], threadblock_output_shape[3], filter_shape[0]*filter_shape[1]]
715
+ self.threadblock_output_shape = threadblock_output_shape
716
+ self.filter_shape = filter_shape
717
+ self.stages = stages
718
+ self.warp_count = warp_count
719
+ self.stride = stride
720
+ self.dilation = dilation
721
+ self.math_instruction = math_instruction
722
+ self.minimum_compute_capability = min_compute
723
+ self.maximum_compute_capability = max_compute
724
+
725
+ def procedural_name(self):
726
+ str_name = "%dx%dx%d_%dx%dx%dx%d_%d_filter%dx%d" % (self.threadblock_shape[0],
727
+ self.threadblock_shape[1],
728
+ self.threadblock_shape[2],
729
+ self.threadblock_output_shape[0],
730
+ self.threadblock_output_shape[1],
731
+ self.threadblock_output_shape[2],
732
+ self.threadblock_output_shape[3],
733
+ self.stages,
734
+ self.filter_shape[0],
735
+ self.filter_shape[1])
736
+ # Fixed Strided and dilation
737
+ if self.stride != [-1, -1] and self.dilation != [-1, -1]:
738
+ str_name += "_stride%dx%d_dilation%dx%d" % (self.stride[0],
739
+ self.stride[1],
740
+ self.dilation[0],
741
+ self.dilation[1])
742
+ return str_name
743
+
744
+ #
745
+ class TensorDescription:
746
+ def __init__(self, element, layout, alignment = 1, complex_transform = ComplexTransform.none):
747
+ self.element = element
748
+ self.layout = layout
749
+ self.alignment = alignment
750
+ self.complex_transform = complex_transform
751
+
752
+ #
753
+ class SymmetricTensorDescription:
754
+ def __init__(self, element, layout, fill_mode, alignment = 1, complex_transform = ComplexTransform.none, side_mode = SideMode.Left):
755
+ self.element = element
756
+ self.layout = layout
757
+ self.fill_mode = fill_mode
758
+ self.alignment = alignment
759
+ self.complex_transform = complex_transform
760
+ self.side_mode = side_mode
761
+
762
+ #
763
+ class TriangularTensorDescription:
764
+ def __init__(self, element, layout, side_mode, fill_mode, diag_type, alignment = 1, complex_transform = ComplexTransform.none):
765
+ self.element = element
766
+ self.layout = layout
767
+ self.side_mode = side_mode
768
+ self.fill_mode = fill_mode
769
+ self.diag_type = diag_type
770
+ self.alignment = alignment
771
+ self.complex_transform = complex_transform
772
+
773
+ ###################################################################################################
774
+
775
+ #
776
+ def CalculateSmemUsage(operation):
777
+ cta_shape = operation.tile_description.threadblock_shape
778
+ stages = operation.tile_description.stages
779
+
780
+ if operation.operation_kind == OperationKind.Gemm and operation.gemm_kind == GemmKind.Sparse:
781
+ # Elements represented by 8 bits of metadata (based on 4:8, 2:4 or 1:2 sparsity)
782
+ if DataTypeSize[operation.A.element] == 32:
783
+ elements_per_8b_md = 2
784
+ elif DataTypeSize[operation.A.element] == 4:
785
+ elements_per_8b_md = 8
786
+ else:
787
+ elements_per_8b_md = 4
788
+
789
+ smem_per_stage = DataTypeSize[operation.A.element] * cta_shape[0] * (cta_shape[2] // 2) // 8 + \
790
+ DataTypeSize[operation.B.element] * cta_shape[1] * cta_shape[2] // 8 + \
791
+ cta_shape[0] * (cta_shape[2] // 2) // elements_per_8b_md
792
+ else:
793
+ # Few BLAS3 operations only have A tensor
794
+ smem_per_stage = DataTypeSize[operation.A.element] * cta_shape[0] * cta_shape[2] // 8 + \
795
+ DataTypeSize[operation.A.element] * cta_shape[1] * cta_shape[2] // 8
796
+
797
+ smem_usage = smem_per_stage * stages
798
+ return (smem_usage >> 10)
799
+ ###################################################################################################