hyperray 0.0.1__py3-none-any.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.
Files changed (788) hide show
  1. hyperdrone/__init__.py +53 -0
  2. hyperdrone/_cuda/__init__.py +76 -0
  3. hyperdrone/_dlpack.py +30 -0
  4. hyperdrone/_jit/__init__.py +131 -0
  5. hyperdrone/_jit/_build.py +113 -0
  6. hyperdrone/_jit/_lock.py +23 -0
  7. hyperdrone/_jit/_patches.py +99 -0
  8. hyperdrone/_jit/_toolchain.py +17 -0
  9. hyperdrone/_jit/_workspace.py +94 -0
  10. hyperdrone/_native/cmake/hyperdrone_jit.cmake +65 -0
  11. hyperdrone/_native/common/bindings.h +39 -0
  12. hyperdrone/_native/common/cuda_staging.h +80 -0
  13. hyperdrone/_native/common/jit_host.h +69 -0
  14. hyperdrone/_native/common/models.h +24 -0
  15. hyperdrone/_native/common/verbosity.h +52 -0
  16. hyperdrone/_native/dynamics/CMakeLists.txt +63 -0
  17. hyperdrone/_native/dynamics/host.cpp +188 -0
  18. hyperdrone/_native/dynamics/iface.h +71 -0
  19. hyperdrone/_native/dynamics/impl.cpp +638 -0
  20. hyperdrone/_native/env/CMakeLists.txt +98 -0
  21. hyperdrone/_native/env/environment.cpp +190 -0
  22. hyperdrone/_native/env/environment.h +282 -0
  23. hyperdrone/_native/env/impl.cpp +779 -0
  24. hyperdrone/_native/env/rotorcraft_bindings.cpp +53 -0
  25. hyperdrone/_native/render/CMakeLists.txt +96 -0
  26. hyperdrone/_native/render/renderer.cpp +973 -0
  27. hyperdrone/_native/render/rig_bindings.h +152 -0
  28. hyperdrone/_native/render/scene_bindings.cpp +515 -0
  29. hyperdrone/_outputs.py +32 -0
  30. hyperdrone/_parameters.py +36 -0
  31. hyperdrone/_vendor/rl-tools/CMakeLists.txt +207 -0
  32. hyperdrone/_vendor/rl-tools/LICENSE +21 -0
  33. hyperdrone/_vendor/rl-tools/cmake/autodetect/all.cmake +34 -0
  34. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-diff.cmake +100 -0
  35. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-hash.cmake +24 -0
  36. hyperdrone/_vendor/rl-tools/cmake/autodetect/summary.cmake +65 -0
  37. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier0-compiler.cmake +18 -0
  38. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier1-blas.cmake +51 -0
  39. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier2-json-hdf5-zlib.cmake +82 -0
  40. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier3-tensorboard.cmake +25 -0
  41. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier4-cuda.cmake +42 -0
  42. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier5-cli11.cmake +24 -0
  43. hyperdrone/_vendor/rl-tools/cmake/dependencies/assimp.cmake +19 -0
  44. hyperdrone/_vendor/rl-tools/cmake/legacy_flags.cmake +33 -0
  45. hyperdrone/_vendor/rl-tools/cmake/optional/assimp.cmake +30 -0
  46. hyperdrone/_vendor/rl-tools/cmake/optional/googletest.cmake +20 -0
  47. hyperdrone/_vendor/rl-tools/cmake/optional/metal.cmake +25 -0
  48. hyperdrone/_vendor/rl-tools/cmake/optional/mujoco.cmake +89 -0
  49. hyperdrone/_vendor/rl-tools/cmake/optional/optix.cmake +25 -0
  50. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing.cmake +105 -0
  51. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing_generic.cmake +2 -0
  52. hyperdrone/_vendor/rl-tools/cmake/optional/vulkan.cmake +4 -0
  53. hyperdrone/_vendor/rl-tools/cmake/optional/webgpu.cmake +24 -0
  54. hyperdrone/_vendor/rl-tools/cmake/scripts/embed_text.cmake +7 -0
  55. hyperdrone/_vendor/rl-tools/cmake/scripts/generate-git-snapshot.cmake +138 -0
  56. hyperdrone/_vendor/rl-tools/include/conta/conta.h +1480 -0
  57. hyperdrone/_vendor/rl-tools/include/metra/metra.h +381 -0
  58. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/matrix.h +143 -0
  59. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_arm.h +33 -0
  60. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu.h +314 -0
  61. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_accelerate.h +37 -0
  62. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_blas.h +67 -0
  63. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_mkl.h +38 -0
  64. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_openblas.h +34 -0
  65. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cuda.h +289 -0
  66. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_dummy.h +20 -0
  67. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_esp32.h +29 -0
  68. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_generic.h +944 -0
  69. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_wasm32.h +13 -0
  70. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/persist_code.h +136 -0
  71. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_arm.h +1 -0
  72. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu.h +94 -0
  73. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_accelerate.h +25 -0
  74. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_blas.h +115 -0
  75. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_mkl.h +25 -0
  76. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_openblas.h +25 -0
  77. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cuda.h +713 -0
  78. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_generic.h +1356 -0
  79. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/persist_code.h +130 -0
  80. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/tensor.h +490 -0
  81. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/arm.h +91 -0
  82. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu.h +210 -0
  83. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_accelerate.h +23 -0
  84. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_blas.h +21 -0
  85. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_emscripten.h +20 -0
  86. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_mkl.h +45 -0
  87. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_openblas.h +56 -0
  88. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_tensorboard.h +34 -0
  89. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda.h +464 -0
  90. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda_streams.h +23 -0
  91. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/devices.h +105 -0
  92. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/dummy.h +55 -0
  93. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/esp32.h +85 -0
  94. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/generic.h +0 -0
  95. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/wasm32.h +59 -0
  96. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/model.h +218 -0
  97. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/operations_generic.h +769 -0
  98. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/persist.h +278 -0
  99. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter.h +100 -0
  100. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter_persist.h +52 -0
  101. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/tensor_operations_generic.h +55 -0
  102. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_backend.h +117 -0
  103. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_interface.h +36 -0
  104. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/l2f.h +98 -0
  105. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_dyn.h +18 -0
  106. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_generic.h +268 -0
  107. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_backend.h +31 -0
  108. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_interface.h +12 -0
  109. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_backend.h +98 -0
  110. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_interface.h +50 -0
  111. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/executor.h +133 -0
  112. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/helper.h +109 -0
  113. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/operations_generic.h +219 -0
  114. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arduino.h +117 -0
  115. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arm.h +56 -0
  116. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu.h +57 -0
  117. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu_tensorboard.h +151 -0
  118. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cuda.h +65 -0
  119. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_dummy.h +45 -0
  120. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_wasm32.h +56 -0
  121. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_arm.h +98 -0
  122. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cpu.h +138 -0
  123. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cuda.h +380 -0
  124. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_dummy.h +93 -0
  125. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_esp32.h +92 -0
  126. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_generic.h +295 -0
  127. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_wasm32.h +230 -0
  128. hyperdrone/_vendor/rl-tools/include/rl_tools/mode/mode.h +98 -0
  129. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/activation_functions.h +113 -0
  130. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/capability.h +61 -0
  131. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/persist_code.h +31 -0
  132. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/group.h +99 -0
  133. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/layer.h +122 -0
  134. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_cuda.h +64 -0
  135. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_generic.h +186 -0
  136. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/persist.h +33 -0
  137. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/layer.h +300 -0
  138. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cpu_mkl.h +590 -0
  139. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cuda.h +809 -0
  140. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_generic.h +1219 -0
  141. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist.h +99 -0
  142. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist_code.h +170 -0
  143. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/layer.h +145 -0
  144. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/dsp.h +63 -0
  145. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/opt.h +173 -0
  146. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu.h +13 -0
  147. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_accelerate.h +66 -0
  148. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_blas.h +282 -0
  149. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_mkl.h +66 -0
  150. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_openblas.h +65 -0
  151. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cuda.h +519 -0
  152. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_dummy.h +8 -0
  153. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/dsp.h +58 -0
  154. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/opt.h +167 -0
  155. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_generic.h +429 -0
  156. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist.h +62 -0
  157. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_code.h +178 -0
  158. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_common.h +59 -0
  159. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/layer.h +188 -0
  160. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_cuda.h +356 -0
  161. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_generic.h +536 -0
  162. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/persist.h +32 -0
  163. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/layer.h +119 -0
  164. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/operations_generic.h +223 -0
  165. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/persist.h +46 -0
  166. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/layer.h +121 -0
  167. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/operations_generic.h +154 -0
  168. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist.h +44 -0
  169. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist_code.h +106 -0
  170. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_cuda.h +602 -0
  171. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_generic.h +251 -0
  172. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/layer.h +206 -0
  173. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/operations_generic.h +889 -0
  174. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist.h +75 -0
  175. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist_code.h +199 -0
  176. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/layers.h +3 -0
  177. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/layer.h +143 -0
  178. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_cuda.h +80 -0
  179. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_generic.h +216 -0
  180. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/persist.h +39 -0
  181. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu.h +1 -0
  182. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_accelerate.h +1 -0
  183. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_blas.h +1 -0
  184. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_mkl.h +3 -0
  185. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_openblas.h +1 -0
  186. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cuda.h +9 -0
  187. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_dummy.h +1 -0
  188. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_generic.h +3 -0
  189. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/layer.h +223 -0
  190. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_cuda.h +138 -0
  191. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_generic.h +446 -0
  192. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/persist.h +70 -0
  193. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/layer.h +154 -0
  194. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_cuda.h +119 -0
  195. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_generic.h +502 -0
  196. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist.h +50 -0
  197. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist_code.h +173 -0
  198. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/layer.h +116 -0
  199. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_cuda.h +156 -0
  200. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_generic.h +295 -0
  201. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist.h +83 -0
  202. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist_code.h +163 -0
  203. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/layer.h +123 -0
  204. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/operations_generic.h +272 -0
  205. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist.h +17 -0
  206. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist_code.h +164 -0
  207. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/layer.h +122 -0
  208. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_cuda.h +55 -0
  209. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_generic.h +160 -0
  210. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist.h +47 -0
  211. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist_code.h +106 -0
  212. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/layer.h +132 -0
  213. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_cuda.h +141 -0
  214. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_generic.h +230 -0
  215. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/categorical_cross_entropy/operations_generic.h +102 -0
  216. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_cuda.h +97 -0
  217. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_generic.h +101 -0
  218. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/operations_generic.h +2 -0
  219. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/nn.h +14 -0
  220. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu.h +1 -0
  221. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_accelerate.h +1 -0
  222. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_blas.h +1 -0
  223. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mkl.h +1 -0
  224. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mux.h +16 -0
  225. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_openblas.h +1 -0
  226. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cuda.h +2 -0
  227. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_dummy.h +1 -0
  228. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_generic.h +15 -0
  229. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/adam.h +121 -0
  230. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_cuda.h +98 -0
  231. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_generic.h +150 -0
  232. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist.h +39 -0
  233. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist_code.h +80 -0
  234. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_cuda.h +85 -0
  235. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_generic.h +109 -0
  236. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/persist.h +25 -0
  237. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/instance/operations_generic.h +107 -0
  238. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/lamb.h +40 -0
  239. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/operations_generic.h +68 -0
  240. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/optimizers.h +3 -0
  241. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_cuda.h +85 -0
  242. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_generic.h +140 -0
  243. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist.h +37 -0
  244. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist_code.h +72 -0
  245. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_cuda.h +49 -0
  246. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_generic.h +50 -0
  247. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/sgd.h +92 -0
  248. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/update.h +54 -0
  249. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_cuda.h +0 -0
  250. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_generic.h +98 -0
  251. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/parameters.h +79 -0
  252. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist.h +34 -0
  253. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist_code.h +136 -0
  254. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist.h +2 -0
  255. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist_code.h +27 -0
  256. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/behaviors/skip_parameter_gradients.h +65 -0
  257. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/README.md +107 -0
  258. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/model.h +19 -0
  259. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/persist_code.h +77 -0
  260. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/network.h +174 -0
  261. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_cuda.h +10 -0
  262. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_dummy.h +8 -0
  263. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_generic.h +407 -0
  264. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist.h +56 -0
  265. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist_code.h +137 -0
  266. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/network.h +55 -0
  267. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/operations_generic.h +86 -0
  268. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist.h +43 -0
  269. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist_code.h +142 -0
  270. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/models.h +3 -0
  271. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/model.h +148 -0
  272. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/operations_generic.h +288 -0
  273. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist.h +25 -0
  274. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist_code.h +71 -0
  275. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cpu.h +0 -0
  276. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cuda.h +1 -0
  277. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_dummy.h +1 -0
  278. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_generic.h +4 -0
  279. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/model.h +290 -0
  280. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_cuda.h +174 -0
  281. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_generic.h +623 -0
  282. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist.h +80 -0
  283. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist_code.h +200 -0
  284. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist.h +1 -0
  285. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist_code.h +1 -0
  286. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/model.h +43 -0
  287. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/operations_generic.h +73 -0
  288. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/resnet/resnet.h +97 -0
  289. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/model.h +270 -0
  290. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/operations_generic.h +625 -0
  291. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist.h +99 -0
  292. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist_code.h +115 -0
  293. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/bf16.h +28 -0
  294. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/categories.h +22 -0
  295. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/persist_code.h +54 -0
  296. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/policy.h +48 -0
  297. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_1.h +18 -0
  298. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_2.h +14 -0
  299. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_3.h +14 -0
  300. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm.h +19 -0
  301. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_1.h +17 -0
  302. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_2.h +12 -0
  303. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_3.h +15 -0
  304. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu.h +19 -0
  305. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_1.h +16 -0
  306. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_2.h +12 -0
  307. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_3.h +15 -0
  308. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate.h +19 -0
  309. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_1.h +17 -0
  310. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_2.h +12 -0
  311. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_3.h +15 -0
  312. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl.h +18 -0
  313. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mux.h +158 -0
  314. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_1.h +16 -0
  315. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_2.h +12 -0
  316. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_3.h +15 -0
  317. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas.h +18 -0
  318. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_1.h +16 -0
  319. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_2.h +12 -0
  320. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_3.h +15 -0
  321. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard.h +19 -0
  322. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_1.h +18 -0
  323. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_2.h +12 -0
  324. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_3.h +12 -0
  325. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda.h +19 -0
  326. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_1.h +15 -0
  327. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_2.h +12 -0
  328. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_3.h +12 -0
  329. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy.h +19 -0
  330. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_1.h +16 -0
  331. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_2.h +12 -0
  332. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_3.h +13 -0
  333. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32.h +19 -0
  334. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_1.h +15 -0
  335. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_2.h +12 -0
  336. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_3.h +12 -0
  337. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32.h +19 -0
  338. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/hdf5.h +54 -0
  339. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/operations_cpu.h +419 -0
  340. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/io.h +55 -0
  341. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_cpu.h +58 -0
  342. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_generic.h +620 -0
  343. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_posix.h +63 -0
  344. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/tar.h +74 -0
  345. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/code.h +38 -0
  346. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_arm.h +39 -0
  347. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cpu.h +81 -0
  348. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cuda.h +172 -0
  349. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_dummy.h +72 -0
  350. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_esp32.h +45 -0
  351. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic.h +133 -0
  352. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic_array.h +73 -0
  353. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_wasm32.h +57 -0
  354. hyperdrone/_vendor/rl-tools/include/rl_tools/random/persist.h +77 -0
  355. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/camera.h +105 -0
  356. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/cache.h +26 -0
  357. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/free_space.h +60 -0
  358. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/operations_cpu.h +411 -0
  359. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/glb.h +25 -0
  360. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/operations_cpu.h +1288 -0
  361. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/operations_cpu.h +136 -0
  362. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/catalog.h +232 -0
  363. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/conversion.h +33 -0
  364. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/operations_cpu.h +123 -0
  365. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/procthor.h +39 -0
  366. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_cpu.h +717 -0
  367. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_generic.h +1283 -0
  368. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/context.h +193 -0
  369. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/device_source.h +17 -0
  370. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/operations_cpu.h +1123 -0
  371. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device.h +207 -0
  372. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device_impl.h +1043 -0
  373. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/operations_cuda.h +1747 -0
  374. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/overlay_accel.h +64 -0
  375. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/specialization.h +37 -0
  376. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/context.h +251 -0
  377. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/device_source.h +48 -0
  378. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/operations_cpu.h +2067 -0
  379. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/bvh_sah.h +182 -0
  380. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/context.h +280 -0
  381. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/device_source.h +17 -0
  382. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/operations_cpu.h +1405 -0
  383. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_common.h +948 -0
  384. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_mux.h +32 -0
  385. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_post.h +96 -0
  386. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/renderer.h +484 -0
  387. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/save_cpu.h +314 -0
  388. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/scene.h +44 -0
  389. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/transforms_generic.h +25 -0
  390. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/types.h +45 -0
  391. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_cpu.h +119 -0
  392. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_generic.h +121 -0
  393. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/rig.h +70 -0
  394. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/scene.h +132 -0
  395. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/segmentation_cpu.h +145 -0
  396. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/transforms.h +204 -0
  397. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/types.h +76 -0
  398. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/algorithms.h +6 -0
  399. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu.h +1 -0
  400. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu_mkl.h +1 -0
  401. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_generic.h +1 -0
  402. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/config.h +243 -0
  403. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_cuda.h +9 -0
  404. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_generic.h +205 -0
  405. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/persist.h +109 -0
  406. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/state.h +51 -0
  407. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/mixed_imitation.h +63 -0
  408. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_cuda.h +190 -0
  409. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic.h +332 -0
  410. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic_mixed_imitation.h +81 -0
  411. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/persist.h +28 -0
  412. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/ppo.h +105 -0
  413. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_gru.h +84 -0
  414. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_mlp.h +61 -0
  415. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/config.h +106 -0
  416. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/operations_generic.h +193 -0
  417. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/state.h +52 -0
  418. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu.h +9 -0
  419. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_accelerate.h +2 -0
  420. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mkl.h +2 -0
  421. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mux.h +9 -0
  422. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cuda.h +131 -0
  423. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_generic.h +580 -0
  424. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/sac.h +151 -0
  425. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_gru.h +72 -0
  426. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_mlp.h +54 -0
  427. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/config.h +107 -0
  428. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/operations_generic.h +174 -0
  429. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/state.h +46 -0
  430. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu.h +9 -0
  431. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_accelerate.h +2 -0
  432. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mkl.h +2 -0
  433. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mux.h +9 -0
  434. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cuda.h +117 -0
  435. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_generic.h +359 -0
  436. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/td3.h +141 -0
  437. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/components.h +4 -0
  438. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/off_policy_runner.h +225 -0
  439. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu.h +95 -0
  440. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_accelerate.h +21 -0
  441. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_mkl.h +21 -0
  442. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cuda.h +237 -0
  443. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic.h +498 -0
  444. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic_per_env.h +112 -0
  445. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/collection.h +57 -0
  446. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/on_policy_runner.h +122 -0
  447. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu.h +2 -0
  448. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_accelerate.h +8 -0
  449. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mkl.h +8 -0
  450. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mux.h +12 -0
  451. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cuda.h +183 -0
  452. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic.h +366 -0
  453. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic_common.h +74 -0
  454. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/persist.h +47 -0
  455. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu.h +2 -0
  456. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_accelerate.h +1 -0
  457. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_mkl.h +1 -0
  458. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_generic.h +2 -0
  459. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_cpu.h +9 -0
  460. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_generic.h +123 -0
  461. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/persist.h +57 -0
  462. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/replay_buffer.h +93 -0
  463. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/operations_generic.h +76 -0
  464. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/persist.h +31 -0
  465. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/running_normalizer.h +33 -0
  466. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/operations_generic.h +58 -0
  467. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/operations_generic.h +28 -0
  468. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/wrapper.h +26 -0
  469. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/wrappers.h +29 -0
  470. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/acrobot.h +88 -0
  471. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_cpu.h +152 -0
  472. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_generic.h +202 -0
  473. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/environment.h +40 -0
  474. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_cuda.h +204 -0
  475. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic.h +106 -0
  476. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic_common.h +26 -0
  477. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/persist.h +33 -0
  478. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/car.h +119 -0
  479. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_cpu.h +110 -0
  480. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_generic.h +206 -0
  481. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_json.h +59 -0
  482. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/track.h +23 -0
  483. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/ui.h +189 -0
  484. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/environments.h +28 -0
  485. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/environment.h +87 -0
  486. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_cpu.h +212 -0
  487. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_generic.h +215 -0
  488. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/observation.h +75 -0
  489. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cpu.h +1063 -0
  490. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cuda.h +564 -0
  491. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/pose.h +253 -0
  492. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/presets.h +154 -0
  493. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_cpu.h +26 -0
  494. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_generic.h +91 -0
  495. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/raptor.h +71 -0
  496. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_cpu.h +190 -0
  497. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_generic.h +32 -0
  498. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/rig.h +25 -0
  499. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cpu.h +86 -0
  500. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cuda.h +69 -0
  501. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_optix.h +163 -0
  502. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu.h +223 -0
  503. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu_spectator.h +194 -0
  504. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda.h +1 -0
  505. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda_spectator.h +109 -0
  506. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spectator.h +82 -0
  507. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spy.h +107 -0
  508. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/ui.h +30 -0
  509. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/moving_gate.h +103 -0
  510. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cpu.h +279 -0
  511. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cuda.h +242 -0
  512. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cpu.h +322 -0
  513. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cuda.h +312 -0
  514. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_generic_position_hold.h +128 -0
  515. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/position_hold.h +22 -0
  516. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/target_frame.h +92 -0
  517. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/baseline.h +46 -0
  518. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/calibration.h +62 -0
  519. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/metrics.h +101 -0
  520. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/operations_cpu.h +374 -0
  521. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/visual_inertial_localization.h +126 -0
  522. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/world.h +333 -0
  523. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/inertial_velocity.h +27 -0
  524. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/metrics.h +266 -0
  525. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/multirotor.h +1138 -0
  526. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_cpu.h +2252 -0
  527. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/05_state_is_nan.h +148 -0
  528. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/10_sample_initial_parameters.h +228 -0
  529. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/20_initial_state.h +208 -0
  530. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/30_sample_initial_state.h +300 -0
  531. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/35_get_desired_state.h +63 -0
  532. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/40_observe.h +637 -0
  533. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/50_state_algebra.h +57 -0
  534. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/60_dynamics.h +134 -0
  535. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/70_post_integration.h +368 -0
  536. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/80_abs_diff.h +312 -0
  537. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic.h +367 -0
  538. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic_inertial_velocity.h +44 -0
  539. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_helper_generic.h +43 -0
  540. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic.h +70 -0
  541. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic_forward.h +24 -0
  542. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/default.h +209 -0
  543. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/arpl.h +112 -0
  544. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie.h +127 -0
  545. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie_openmv.h +119 -0
  546. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/flightmare.h +111 -0
  547. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/fs.h +113 -0
  548. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/mrs.h +110 -0
  549. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft.h +117 -0
  550. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft_rigid.h +118 -0
  551. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500.h +88 -0
  552. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_real.h +88 -0
  553. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_sim.h +114 -0
  554. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/init/default.h +56 -0
  555. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/registry.h +96 -0
  556. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/default.h +64 -0
  557. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/reward_functions.h +1 -0
  558. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/operations_generic.h +202 -0
  559. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/squared.h +52 -0
  560. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/termination/default.h +33 -0
  561. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/lissajous.h +72 -0
  562. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/trajectory.h +78 -0
  563. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist.h +21 -0
  564. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist_code.h +53 -0
  565. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/quaternion_helper.h +103 -0
  566. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/ui.h +180 -0
  567. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/environment.h +69 -0
  568. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_cpu.h +46 -0
  569. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_generic.h +78 -0
  570. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/README.MD +5 -0
  571. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ant.h +77 -0
  572. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/model.h +415 -0
  573. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/operations_cpu.h +162 -0
  574. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/persist.h +86 -0
  575. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ui.h +141 -0
  576. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/mujoco.h +1 -0
  577. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/bottleneck.h +113 -0
  578. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_cpu.h +289 -0
  579. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_generic.h +495 -0
  580. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/environments.h +16 -0
  581. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/observation.h +37 -0
  582. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_cpu.h +2 -0
  583. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_generic.h +33 -0
  584. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_cpu.h +146 -0
  585. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_generic.h +262 -0
  586. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/pendulum.h +197 -0
  587. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui.h +97 -0
  588. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui_xeus.h +124 -0
  589. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_cpu.h +426 -0
  590. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_generic.h +424 -0
  591. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/reacher.h +137 -0
  592. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/loop.h +15 -0
  593. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/config.h +28 -0
  594. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/operations_cpu.h +233 -0
  595. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/persist.h +30 -0
  596. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/state.h +21 -0
  597. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/config.h +25 -0
  598. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/operations_generic.h +47 -0
  599. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/persist.h +20 -0
  600. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/state.h +17 -0
  601. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/config.h +47 -0
  602. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/operations_generic.h +106 -0
  603. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/persist.h +40 -0
  604. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/state.h +36 -0
  605. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/config.h +22 -0
  606. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/operations_cpu.h +44 -0
  607. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/persist.h +20 -0
  608. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/state.h +26 -0
  609. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/config.h +37 -0
  610. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/operations_cpu.h +113 -0
  611. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/persist.h +20 -0
  612. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/state.h +24 -0
  613. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/config.h +43 -0
  614. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/operations_cpu.h +190 -0
  615. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/persist.h +30 -0
  616. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/state.h +37 -0
  617. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/steps.h +4 -0
  618. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/config.h +27 -0
  619. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/operations_cpu.h +52 -0
  620. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/persist.h +20 -0
  621. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/state.h +25 -0
  622. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/operations_generic.h +3 -0
  623. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/rl.h +5 -0
  624. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/evaluation.h +106 -0
  625. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_cpu.h +48 -0
  626. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_generic.h +275 -0
  627. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation.h +269 -0
  628. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation_analysis.h +85 -0
  629. hyperdrone/_vendor/rl-tools/include/rl_tools/rl_tools.h +80 -0
  630. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/client.h +50 -0
  631. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_boost.h +92 -0
  632. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_cpu.h +174 -0
  633. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_websocket.h +208 -0
  634. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/server.h +448 -0
  635. hyperdrone/_vendor/rl-tools/include/rl_tools/universe.h +4 -0
  636. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu.h +13 -0
  637. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu_emscripten.h +15 -0
  638. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_arm.h +29 -0
  639. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu.h +24 -0
  640. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu_emscripten.h +28 -0
  641. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cuda.h +33 -0
  642. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_dummy.h +18 -0
  643. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_esp32.h +20 -0
  644. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_generic.h +19 -0
  645. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_wasm32.h +18 -0
  646. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_cpu.h +16 -0
  647. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_generic.h +14 -0
  648. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/extrack.h +129 -0
  649. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/operations_cpu.h +588 -0
  650. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/integrators.h +103 -0
  651. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/memcpy.h +16 -0
  652. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/operations_generic.h +48 -0
  653. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/tuple.h +147 -0
  654. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/typing.h +122 -0
  655. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/vector_operations.h +172 -0
  656. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_cuda.h +53 -0
  657. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_generic.h +93 -0
  658. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/string/operations_generic.h +201 -0
  659. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/zlib/operations_cpu.h +45 -0
  660. hyperdrone/_vendor/rl-tools/include/rl_tools/version.h +28 -0
  661. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/CMakeLists.txt +15 -0
  662. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/README.md +214 -0
  663. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/CMakeLists.txt +11 -0
  664. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/CMakeLists.txt +17 -0
  665. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/freestanding_check.cpp +134 -0
  666. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/CMakeLists.txt +31 -0
  667. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/device.metal +912 -0
  668. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/metal_cpp_impl.cpp +6 -0
  669. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/CMakeLists.txt +51 -0
  670. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/device.cu +1 -0
  671. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/overlay_accel.cu +308 -0
  672. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/CMakeLists.txt +37 -0
  673. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device.comp +970 -0
  674. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device_spirv.cpp +44 -0
  675. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/CMakeLists.txt +31 -0
  676. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/device.wgsl +1381 -0
  677. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/CMakeLists.txt +129 -0
  678. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/README.md +131 -0
  679. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark.cpp +180 -0
  680. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark_dynamic.cpp +491 -0
  681. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/download_paper_scene.py +74 -0
  682. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/CMakeLists.txt +104 -0
  683. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Info.plist +36 -0
  684. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Sources/BenchmarkApp.swift +172 -0
  685. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.h +10 -0
  686. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.mm +46 -0
  687. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/build.sh +17 -0
  688. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/rig.cpp +119 -0
  689. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.cpp +1382 -0
  690. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.h +5 -0
  691. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_config.h.in +25 -0
  692. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_identity.cmake +11 -0
  693. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_main.cpp +5 -0
  694. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.cu +125 -0
  695. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.h +58 -0
  696. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_contract.h +179 -0
  697. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_cpu.cpp +77 -0
  698. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/camera_orbit.h +51 -0
  699. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/CMakeLists.txt +199 -0
  700. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/antialiasing.cpp +214 -0
  701. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone.cpp +320 -0
  702. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone_device.cu +359 -0
  703. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/environment.h +96 -0
  704. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/operations_cpu.h +263 -0
  705. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/example.cpp +273 -0
  706. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/fixed_pose.cpp +221 -0
  707. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/flow.cpp +120 -0
  708. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/interactive.cpp +1015 -0
  709. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/make_drone_glb.py +172 -0
  710. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal.cpp +82 -0
  711. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal_overlay.cpp +137 -0
  712. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/motion_blur.cpp +232 -0
  713. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace.cpp +1829 -0
  714. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace_motion_blur.cpp +647 -0
  715. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/CMakeLists.txt +147 -0
  716. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/README.md +15 -0
  717. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/job.sbatch +28 -0
  718. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model.h +260 -0
  719. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_config.h +24 -0
  720. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_forward_cuda.h +397 -0
  721. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_operations.h +418 -0
  722. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_persist.h +45 -0
  723. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_student.h +70 -0
  724. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.cpp +222 -0
  725. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.h +68 -0
  726. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/.gitignore +4 -0
  727. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/CMakeLists.txt +4 -0
  728. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info.plist +24 -0
  729. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info_ios.plist +36 -0
  730. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/CameraManager.swift +120 -0
  731. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/ContentView.swift +703 -0
  732. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/DatasetRecorder.swift +285 -0
  733. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/YawPredictorApp.swift +25 -0
  734. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/YawPredictor.entitlements +8 -0
  735. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build.sh +66 -0
  736. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build_ios.sh +133 -0
  737. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/generate.sh +6 -0
  738. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/h5_to_tar.cpp +82 -0
  739. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.cpp +166 -0
  740. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.h +26 -0
  741. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/project.yml +30 -0
  742. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/test_tar_vs_hdf5.cpp +173 -0
  743. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_cuda.cu +699 -0
  744. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_dataset_overlay.cpp +475 -0
  745. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_distill_cuda.cu +995 -0
  746. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_eval.cu +457 -0
  747. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_real_world_eval.cpp +660 -0
  748. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_viewer.cu +443 -0
  749. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/CMakeLists.txt +63 -0
  750. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/example.cpp +101 -0
  751. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/ui.cpp +380 -0
  752. hyperdrone/dynamics/__init__.py +5 -0
  753. hyperdrone/dynamics/_component.py +31 -0
  754. hyperdrone/dynamics/_config.py +46 -0
  755. hyperdrone/dynamics/_sim.py +166 -0
  756. hyperdrone/env/__init__.py +23 -0
  757. hyperdrone/env/_multi_environment.py +566 -0
  758. hyperdrone/env/_rotorcraft.py +29 -0
  759. hyperdrone/env/_spy.py +39 -0
  760. hyperdrone/examples/.gitignore +3 -0
  761. hyperdrone/examples/Benchmark.ipynb +113 -0
  762. hyperdrone/examples/HyperDrone.ipynb +589 -0
  763. hyperdrone/examples/Orbiter.ipynb +496 -0
  764. hyperdrone/examples/Renderer.ipynb +218 -0
  765. hyperdrone/examples/__init__.py +16 -0
  766. hyperdrone/examples/articulation.py +55 -0
  767. hyperdrone/examples/benchmark.py +236 -0
  768. hyperdrone/examples/benchmark_minimal.py +65 -0
  769. hyperdrone/examples/data.py +71 -0
  770. hyperdrone/examples/drone_flythrough.py +169 -0
  771. hyperdrone/examples/hyperdrone_videos/my_world_preview.h +17 -0
  772. hyperdrone/examples/my_world.h +17 -0
  773. hyperdrone/examples/render_procthor.py +40 -0
  774. hyperdrone/examples/shots.py +108 -0
  775. hyperdrone/examples/spy.py +40 -0
  776. hyperdrone/examples/visual_inertial_localization.py +158 -0
  777. hyperdrone/gym/__init__.py +67 -0
  778. hyperdrone/render/__init__.py +57 -0
  779. hyperdrone/render/_component.py +51 -0
  780. hyperdrone/render/_config.py +76 -0
  781. hyperdrone/render/_renderer.py +498 -0
  782. hyperdrone/render/_rig.py +136 -0
  783. hyperdrone/render/_sampling.py +69 -0
  784. hyperdrone/render/_scene.py +38 -0
  785. hyperdrone/render/datasets.py +15 -0
  786. hyperray-0.0.1.dist-info/METADATA +519 -0
  787. hyperray-0.0.1.dist-info/RECORD +788 -0
  788. hyperray-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,1356 @@
1
+ #include "../../version.h"
2
+ #if (defined(RL_TOOLS_DISABLE_INCLUDE_GUARDS) || !defined(RL_TOOLS_CONTAINERS_TENSOR_OPERATIONS_GENERIC_H)) && (RL_TOOLS_USE_THIS_VERSION == 1)
3
+ #pragma once
4
+ #define RL_TOOLS_CONTAINERS_TENSOR_OPERATIONS_GENERIC_H
5
+
6
+ #include "tensor.h"
7
+ #include "../../mode/mode.h"
8
+
9
+ RL_TOOLS_NAMESPACE_WRAPPER_START
10
+ namespace rl_tools{
11
+ template<typename DEVICE, typename T, typename T_TI, T_TI SIZE>
12
+ RL_TOOLS_FUNCTION_PLACEMENT void malloc(DEVICE& device, tensor::TensorStatic<T, T_TI, SIZE>& tensor) {
13
+ // no-op
14
+ }
15
+ template<typename DEVICE, typename T, typename T_TI, T_TI SIZE>
16
+ RL_TOOLS_FUNCTION_PLACEMENT void free(DEVICE& device, tensor::TensorStatic<T, T_TI, SIZE>& tensor) {
17
+ // no-op
18
+ }
19
+ template<typename DEVICE, typename T>
20
+ RL_TOOLS_FUNCTION_PLACEMENT void malloc(DEVICE& device, tensor::TensorStaticEmpty<T>& tensor) {
21
+ // no-op
22
+ }
23
+ template<typename DEVICE, typename T>
24
+ RL_TOOLS_FUNCTION_PLACEMENT void free(DEVICE& device, tensor::TensorStaticEmpty<T>& tensor) {
25
+ // no-op
26
+ }
27
+
28
+ #if !defined(RL_TOOLS_DISABLE_DYNAMIC_MEMORY_ALLOCATIONS)
29
+ template<typename DEVICE, typename T, typename T_TI, T_TI SIZE, bool CONST>
30
+ RL_TOOLS_FUNCTION_PLACEMENT void malloc(DEVICE& device, tensor::TensorDynamic<T, T_TI, SIZE, CONST>& tensor){
31
+ T* temp = (T*) new T[SIZE > 0 ? SIZE : 1]; // zero-extent shapes (e.g. an autonomous task's empty action tensor) still get a valid pointer
32
+ *data_pointer(tensor) = temp;
33
+ #if RL_TOOLS_DEBUG_CONTAINER_MALLOC_INIT_NAN
34
+ for(typename DEVICE::index_t i=0; i < SIZE; i++){
35
+ data(tensor)[i] = math::nan<T>(device.math);
36
+ }
37
+ #endif
38
+ }
39
+ template <typename DEVICE, typename T, typename T_TI, T_TI SIZE, bool CONST>
40
+ RL_TOOLS_FUNCTION_PLACEMENT void free(DEVICE& device, tensor::TensorDynamic<T, T_TI, SIZE, CONST>& tensor){
41
+ delete[] data(tensor);
42
+ }
43
+ #endif
44
+
45
+ template <typename SHAPE, typename DEVICE, typename SPEC>
46
+ RL_TOOLS_FUNCTION_PLACEMENT auto view_memory(DEVICE& device, const Tensor<SPEC>& tensor){
47
+ static_assert(product(SHAPE{}) <= SPEC::SIZE);
48
+ static_assert(tensor::dense_row_major_layout<SPEC>());
49
+ static constexpr auto LAST_STRIDE = get<length(typename SPEC::STRIDE{}) - 1>(typename SPEC::STRIDE{});
50
+ using STRIDE = tensor::RowMajorStride<SHAPE, LAST_STRIDE>;
51
+ using VIEW_SPEC = tensor::Specification<typename SPEC::T, typename SPEC::TI, SHAPE, true, STRIDE, true>; // note the last boolean signals constness and needs to be flipped for the non-const version of this function
52
+ using VIEW_TYPE = Tensor<VIEW_SPEC>;
53
+ const VIEW_TYPE view{{data(tensor)}};
54
+ return view;
55
+ }
56
+
57
+ template <typename SHAPE, typename DEVICE, typename SPEC>
58
+ RL_TOOLS_FUNCTION_PLACEMENT auto view_memory(DEVICE& device, Tensor<SPEC>& tensor){
59
+ static_assert(product(SHAPE{}) <= SPEC::SIZE);
60
+ static_assert(tensor::dense_row_major_layout<SPEC>());
61
+ static constexpr auto LAST_STRIDE = get<length(typename SPEC::STRIDE{}) - 1>(typename SPEC::STRIDE{});
62
+ using STRIDE = tensor::RowMajorStride<SHAPE, LAST_STRIDE>;
63
+ using VIEW_SPEC = tensor::Specification<typename SPEC::T, typename SPEC::TI, SHAPE, true, STRIDE, false>;
64
+ using VIEW_TYPE = Tensor<VIEW_SPEC>;
65
+ VIEW_TYPE view{{data(tensor)}};
66
+ return view;
67
+ }
68
+
69
+ template <typename DEVICE, typename SPEC, auto DIM=0, auto SIZE=0>
70
+ RL_TOOLS_FUNCTION_PLACEMENT auto view_range(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t index, const tensor::ViewSpec<DIM, SIZE>){
71
+ static_assert(SIZE > 0);
72
+ static_assert(get<DIM>(typename SPEC::SHAPE{}) >= SIZE);
73
+ auto offset = index * get<DIM>(typename SPEC::STRIDE{});
74
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
75
+ utils::assert_exit(device, index < SPEC::SHAPE::template GET<DIM>, "Index out of bounds");
76
+ utils::assert_exit(device, index + SIZE <= SPEC::SHAPE::template GET<DIM>, "Index + Range out of bounds");
77
+ #endif
78
+ using VIEW_TYPE = Tensor<tensor::spec::view::range::Specification<SPEC, tensor::ViewSpec<DIM, SIZE>, true>>;
79
+ using VIEW_TYPE_CV = const VIEW_TYPE;
80
+
81
+ VIEW_TYPE_CV view{data(tensor) + offset};
82
+ return view;
83
+ }
84
+
85
+ template <typename DEVICE, typename SPEC, auto DIM=0, auto SIZE=0>
86
+ RL_TOOLS_FUNCTION_PLACEMENT auto view_range(DEVICE& device, Tensor<SPEC>& tensor, typename DEVICE::index_t index, const tensor::ViewSpec<DIM, SIZE>){
87
+ static_assert(SIZE > 0);
88
+ static_assert(get<DIM>(typename SPEC::SHAPE{}) >= SIZE);
89
+ auto offset = index * get<DIM>(typename SPEC::STRIDE{});
90
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
91
+ utils::assert_exit(device, index < SPEC::SHAPE::template GET<DIM>, "Index out of bounds");
92
+ utils::assert_exit(device, index + SIZE <= SPEC::SHAPE::template GET<DIM>, "Index + Range out of bounds");
93
+ #endif
94
+ using VIEW_TYPE = Tensor<tensor::spec::view::range::Specification<SPEC, tensor::ViewSpec<DIM, SIZE>, false>>;
95
+ VIEW_TYPE view{data(tensor) + offset};
96
+ return view;
97
+ }
98
+ template <typename DEVICE, typename SPEC, auto DIM=0, auto SIZE=0>
99
+ RL_TOOLS_FUNCTION_PLACEMENT auto view_range(DEVICE& device, const Tensor<SPEC>& tensor, const tensor::ViewSpec<DIM, SIZE>){
100
+ return view_range(device, tensor, 0, tensor::ViewSpec<DIM, SIZE>{});
101
+ }
102
+
103
+ template <typename DEVICE, typename SPEC, auto DIM=0, auto SIZE=0>
104
+ RL_TOOLS_FUNCTION_PLACEMENT auto view_range(DEVICE& device, Tensor<SPEC>& tensor, const tensor::ViewSpec<DIM, SIZE>){
105
+ return view_range(device, tensor, 0, tensor::ViewSpec<DIM, SIZE>{});
106
+ }
107
+
108
+ template <auto DIM=0, typename DEVICE, typename SPEC>
109
+ RL_TOOLS_FUNCTION_PLACEMENT auto view(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t index, const tensor::ViewSpec<DIM> = {}){
110
+ static_assert(SPEC::SHAPE::LENGTH > DIM);
111
+ using NEW_SHAPE = tensor::Remove<typename SPEC::SHAPE, DIM>;
112
+ using NEW_STRIDE = tensor::Remove<typename SPEC::STRIDE, DIM>;
113
+ using NEW_SPEC = tensor::Specification<typename SPEC::T, typename SPEC::TI, NEW_SHAPE, true, NEW_STRIDE, true>;
114
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
115
+ rl_tools::utils::assert_exit(device, index < SPEC::SHAPE::template GET<DIM>, "Index out of bounds");
116
+ #endif
117
+ auto offset = index * get<DIM>(typename SPEC::STRIDE{});
118
+ const Tensor<NEW_SPEC> view{{data(tensor) + offset}};
119
+ return view;
120
+ }
121
+
122
+ template <auto DIM=0, typename DEVICE, typename SPEC>
123
+ RL_TOOLS_FUNCTION_PLACEMENT auto view(DEVICE& device, Tensor<SPEC>& tensor, typename DEVICE::index_t index, const tensor::ViewSpec<DIM> = {}){
124
+ static_assert(SPEC::SHAPE::LENGTH > DIM);
125
+ using NEW_SHAPE = tensor::Remove<typename SPEC::SHAPE, DIM>;
126
+ using NEW_STRIDE = tensor::Remove<typename SPEC::STRIDE, DIM>;
127
+ using NEW_SPEC = tensor::Specification<typename SPEC::T, typename SPEC::TI, NEW_SHAPE, true, NEW_STRIDE, false>;
128
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
129
+ rl_tools::utils::assert_exit(device, index < SPEC::SHAPE::template GET<DIM>, "Index out of bounds");
130
+ #endif
131
+ auto offset = index * get<DIM>(typename SPEC::STRIDE{});
132
+ // data_reference(view) = ;
133
+ Tensor<NEW_SPEC> view{{data(tensor) + offset}};
134
+ return view;
135
+ }
136
+
137
+ namespace tensor{
138
+ template <auto T_DIM_1, auto T_DIM_2>
139
+ struct PermutationSpec{
140
+ static constexpr auto DIM_1 = T_DIM_1;
141
+ static constexpr auto DIM_2 = T_DIM_2;
142
+ };
143
+ }
144
+
145
+ template <typename DEVICE, typename SPEC, auto DIM_1=0, auto DIM_2=1>
146
+ RL_TOOLS_FUNCTION_PLACEMENT auto permute(DEVICE& device, const Tensor<SPEC>& tensor, const tensor::PermutationSpec<DIM_1, DIM_2> spec={}){
147
+ static_assert(length(typename SPEC::SHAPE{}) >= 2);
148
+ static_assert(DIM_1 < length(typename SPEC::SHAPE{}));
149
+ static_assert(DIM_2 < length(typename SPEC::SHAPE{}));
150
+ using SHAPE = typename SPEC::SHAPE;
151
+ using TI = typename SHAPE::TI;
152
+ using NEW_SHAPE_INTERMEDIATE = tensor::Replace<SHAPE, get<DIM_2>(SHAPE{}), DIM_1>;
153
+ using NEW_SHAPE = tensor::Replace<NEW_SHAPE_INTERMEDIATE, get<DIM_1>(SHAPE{}), DIM_2>;
154
+ using STRIDE = typename SPEC::STRIDE;
155
+ using NEW_STRIDE_INTERMEDIATE = tensor::Replace<STRIDE, get<DIM_2>(STRIDE{}), DIM_1>;
156
+ using NEW_STRIDE = tensor::Replace<NEW_STRIDE_INTERMEDIATE, get<DIM_1>(STRIDE{}), DIM_2>;
157
+ using NEW_SPEC = tensor::Specification<typename SPEC::T, TI, NEW_SHAPE, true, NEW_STRIDE, true>; // const here
158
+ const Tensor<NEW_SPEC> view{data(tensor)};
159
+ return view;
160
+ }
161
+ template <typename DEVICE, typename SPEC, auto DIM_1=0, auto DIM_2=1>
162
+ RL_TOOLS_FUNCTION_PLACEMENT auto permute(DEVICE& device, Tensor<SPEC>& tensor, const tensor::PermutationSpec<DIM_1, DIM_2> spec={}){
163
+ static_assert(length(typename SPEC::SHAPE{}) >= 2);
164
+ static_assert(DIM_1 < length(typename SPEC::SHAPE{}));
165
+ static_assert(DIM_2 < length(typename SPEC::SHAPE{}));
166
+ using SHAPE = typename SPEC::SHAPE;
167
+ using TI = typename SHAPE::TI;
168
+ using NEW_SHAPE_INTERMEDIATE = tensor::Replace<SHAPE, get<DIM_2>(SHAPE{}), DIM_1>;
169
+ using NEW_SHAPE = tensor::Replace<NEW_SHAPE_INTERMEDIATE, get<DIM_1>(SHAPE{}), DIM_2>;
170
+ using STRIDE = typename SPEC::STRIDE;
171
+ using NEW_STRIDE_INTERMEDIATE = tensor::Replace<STRIDE, get<DIM_2>(STRIDE{}), DIM_1>;
172
+ using NEW_STRIDE = tensor::Replace<NEW_STRIDE_INTERMEDIATE, get<DIM_1>(STRIDE{}), DIM_2>;
173
+ using NEW_SPEC = tensor::Specification<typename SPEC::T, TI, NEW_SHAPE, true, NEW_STRIDE, false>; // non-const here
174
+ Tensor<NEW_SPEC> view;
175
+ *data_pointer(view) = data(tensor);
176
+ return view;
177
+ }
178
+
179
+ template<typename DEVICE, typename SPEC, typename TII>
180
+ RL_TOOLS_FUNCTION_PLACEMENT typename DEVICE::index_t index(DEVICE& device, const Tensor<SPEC>& tensor, TII index){
181
+ static_assert(length(typename SPEC::SHAPE{})==1);
182
+ return static_cast<typename DEVICE::index_t>(index) * get<0>(typename SPEC::STRIDE{});
183
+ }
184
+
185
+ template<typename DEVICE, typename SPEC, typename... INDICES>
186
+ RL_TOOLS_FUNCTION_PLACEMENT auto index(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t index, const INDICES... indices){
187
+ using TI = typename DEVICE::index_t;
188
+ auto v = view(device, tensor, index);
189
+ TI current = get<0>(typename SPEC::STRIDE{}) * index;
190
+ if constexpr(length(typename SPEC::SHAPE{}) == 1){
191
+ return current + index(device, v);
192
+ }
193
+ else{
194
+ return current + index(device, v, indices...);
195
+ }
196
+ }
197
+
198
+ template<typename DEVICE, typename SPEC>
199
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T& get_ref(DEVICE& device, Tensor<SPEC>& tensor, typename DEVICE::index_t local_index){
200
+ static_assert(SPEC::SHAPE::LENGTH==1);
201
+ auto idx = index(device, tensor, local_index);
202
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
203
+ utils::assert_exit(device, idx < SPEC::SIZE, "Index out of bounds");
204
+ #endif
205
+ return *(data(tensor) + idx);
206
+ }
207
+
208
+ template<typename DEVICE, typename SPEC, typename... INDICES>
209
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T& get_ref(DEVICE& device, Tensor<SPEC>& tensor, typename DEVICE::index_t index, const INDICES... indices){
210
+ auto v = view(device, tensor, index);
211
+ if constexpr(length(typename SPEC::SHAPE{}) == 1){
212
+ return get_ref(device, v, index);
213
+ }
214
+ else{
215
+ return get_ref(device, v, indices...);
216
+ }
217
+ }
218
+
219
+ template<typename DEVICE, typename SPEC>
220
+ RL_TOOLS_FUNCTION_PLACEMENT const typename SPEC::T& get_ref(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t local_index){
221
+ static_assert(SPEC::SHAPE::LENGTH==1);
222
+ auto idx = index(device, tensor, local_index);
223
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
224
+ utils::assert_exit(device, idx < SPEC::SIZE, "Index out of bounds");
225
+ #endif
226
+ return *(data(tensor) + idx);
227
+ }
228
+
229
+ template<typename DEVICE, typename SPEC, typename... INDICES>
230
+ RL_TOOLS_FUNCTION_PLACEMENT const typename SPEC::T& get_ref(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t index, const INDICES... indices){
231
+ auto v = view(device, tensor, index);
232
+ if constexpr(length(typename SPEC::SHAPE{}) == 1){
233
+ return get_ref(device, v, index);
234
+ }
235
+ else{
236
+ return get_ref(device, v, indices...);
237
+ }
238
+ }
239
+
240
+ template<typename DEVICE, typename SPEC>
241
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T get(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t local_index){
242
+ static_assert(SPEC::SHAPE::LENGTH==1);
243
+ auto idx = index(device, tensor, local_index);
244
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
245
+ utils::assert_exit(device, idx < SPEC::SIZE, "Index out of bounds");
246
+ #endif
247
+ return *(data(tensor) + idx);
248
+ }
249
+
250
+ template<typename DEVICE, typename SPEC, typename... INDICES>
251
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T get(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t index, const INDICES... indices){
252
+ auto v = view(device, tensor, index);
253
+ if constexpr(length(typename SPEC::SHAPE{}) == 1){
254
+ return get(device, v, index);
255
+ }
256
+ else{
257
+ return get(device, v, indices...);
258
+ }
259
+ }
260
+
261
+ template<typename DEVICE, typename SPEC>
262
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T get_flat(DEVICE& device, const Tensor<SPEC>& tensor, typename DEVICE::index_t local_index){
263
+ static_assert(tensor::dense_row_major_layout<SPEC>());
264
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
265
+ utils::assert_exit(device, local_index < SPEC::SIZE, "Index out of bounds");
266
+ #endif
267
+ return *(data(tensor) + local_index);
268
+ }
269
+
270
+ template<typename DEVICE, typename SPEC, typename TII> //SFINAE actually not required: typename utils::typing::enable_if_t<length(typename SPEC::SHAPE{})==1>* = nullptr>
271
+ RL_TOOLS_FUNCTION_PLACEMENT void set(DEVICE& device, Tensor<SPEC>& tensor, typename SPEC::T value, TII current_index){
272
+ static_assert(length(typename SPEC::SHAPE{})==1);
273
+ auto idx = index(device, tensor, static_cast<typename DEVICE::index_t>(current_index));
274
+ #if defined(RL_TOOLS_DEBUG_CONTAINER_CHECK_BOUNDS) && !defined(__CUDA_ARCH__)
275
+ utils::assert_exit(device, idx < SPEC::SIZE, "Index out of bounds");
276
+ #endif
277
+ *(data(tensor) + idx) = value;
278
+ }
279
+
280
+ template<typename DEVICE, typename SPEC, typename TII, typename... INDICES>
281
+ RL_TOOLS_FUNCTION_PLACEMENT void set(DEVICE& device, Tensor<SPEC>& tensor, typename SPEC::T value, const TII index, const INDICES... indices){
282
+ auto v = view(device, tensor, static_cast<typename DEVICE::index_t>(index));
283
+ if constexpr(length(typename SPEC::SHAPE{}) == 1){
284
+ set(device, v, value);
285
+ }
286
+ else{
287
+ set(device, v, value, indices...);
288
+ }
289
+ }
290
+
291
+ template<typename DEVICE, typename SPEC, typename TII, typename... INDICES>
292
+ RL_TOOLS_FUNCTION_PLACEMENT void increment(DEVICE& device, Tensor<SPEC>& tensor, typename SPEC::T value, const TII index, const INDICES... indices){
293
+ typename SPEC::T current = get(device, tensor, index, indices...);
294
+ set(device, tensor, current + value, index, indices...);
295
+ }
296
+
297
+ template<typename FROM_DEVICE, typename TO_DEVICE, typename FROM_SPEC, typename TO_SPEC>
298
+ RL_TOOLS_FUNCTION_PLACEMENT void copy(FROM_DEVICE& from_device, TO_DEVICE& to_device, const Tensor<FROM_SPEC>& from, Tensor<TO_SPEC>& to){
299
+ using TI = typename FROM_DEVICE::index_t;
300
+ static_assert(tensor::same_dimensions<FROM_SPEC, TO_SPEC>());
301
+ if constexpr(length(typename FROM_SPEC::SHAPE{}) > 1){
302
+ for(TI i=0; i < get<0>(typename FROM_SPEC::SHAPE{}); ++i){
303
+ auto next_from = view(from_device, from, i);
304
+ auto next_to = view(to_device, to, i);
305
+ copy(from_device, to_device, next_from, next_to);
306
+ }
307
+ }
308
+ else{
309
+ for(TI i=0; i < get<0>(typename FROM_SPEC::SHAPE{}); i++){
310
+ set(to_device, to, get(from_device, from, i), i);
311
+ }
312
+ }
313
+ }
314
+ template<typename FROM_DEVICE, typename TO_DEVICE, typename FROM, typename TO_SPEC>
315
+ RL_TOOLS_FUNCTION_PLACEMENT void copy_from_generic(FROM_DEVICE& from_device, TO_DEVICE& to_device, const FROM& from, Tensor<TO_SPEC>& to){
316
+ #ifndef RL_TOOLS_CONTAINERS_TENSOR_COPY_FROM_GENERIC_DISABLE_SHAPE_CHECK
317
+ static_assert(tensor::same_dimensions<typename FROM::SPEC, TO_SPEC>());
318
+ static_assert(tensor::same_dimensions_shape<typename FROM::SPEC::STRIDE, typename TO_SPEC::STRIDE>());
319
+ #endif
320
+ Tensor<tensor::Specification<typename FROM::SPEC::T, typename TO_DEVICE::index_t, typename TO_SPEC::SHAPE, true, typename TO_SPEC::STRIDE, true>> temp_from;
321
+ temp_from._data = from._data;
322
+ copy(from_device, to_device, temp_from, to);
323
+ }
324
+ template<typename DEVICE, typename SPEC, typename RNG>
325
+ RL_TOOLS_FUNCTION_PLACEMENT void randn(DEVICE& device, Tensor<SPEC>& t, RNG& rng){
326
+ using T = typename SPEC::T;
327
+ using TI = typename DEVICE::index_t;
328
+ if constexpr(length(typename SPEC::SHAPE{}) > 1){
329
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); ++i){
330
+ auto next = view(device, t, i);
331
+ randn(device, next, rng);
332
+ }
333
+ }
334
+ else{
335
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); i++){
336
+ T value = random::normal_distribution::sample(device.random, (T)0, (T)1, rng);
337
+ set(device, t, value, i);
338
+ }
339
+ }
340
+ }
341
+ template<typename DEVICE, typename SPEC, typename RNG>
342
+ RL_TOOLS_FUNCTION_PLACEMENT void rand(DEVICE& device, Tensor<SPEC>& t, RNG& rng, typename SPEC::T min=0, typename SPEC::T max=1){
343
+ using T = typename SPEC::T;
344
+ using TI = typename DEVICE::index_t;
345
+ if constexpr(length(typename SPEC::SHAPE{}) > 1){
346
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); ++i){
347
+ auto next = view(device, t, i);
348
+ rand(device, next, rng, min, max);
349
+ }
350
+ }
351
+ else{
352
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); i++){
353
+ T value = random::uniform_real_distribution(device.random, (T)min, (T)max, rng);
354
+ set(device, t, value, i);
355
+ }
356
+ }
357
+ }
358
+
359
+ namespace tensor{
360
+ struct Operation{};
361
+ struct OperationEmptyParameter{};
362
+ template <auto T_OPERATION, typename PARAMETER=OperationEmptyParameter>
363
+ struct OperationLegacy{
364
+ static constexpr auto OPERATION = T_OPERATION;
365
+ PARAMETER parameter;
366
+ };
367
+ namespace operations::unary{
368
+ struct Negate: Operation {
369
+ template <typename DEVICE, typename T>
370
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const Negate& parameter, T a){
371
+ return -a;
372
+ }
373
+ };
374
+ struct Abs: Operation {
375
+ template <typename DEVICE, typename T>
376
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const Abs& parameter, T a){
377
+ return math::abs(device.math, a);
378
+ }
379
+ };
380
+ template <typename T>
381
+ struct Constant: Operation {
382
+ T constant;
383
+ template <typename DEVICE, typename T_T>
384
+ RL_TOOLS_FUNCTION_PLACEMENT static T_T operation(DEVICE& device, const Constant<T_T>& parameter, T_T a){
385
+ return parameter.constant;
386
+ }
387
+ };
388
+ template <typename TENSOR>
389
+ struct ConstantFromTensor: Operation {
390
+ TENSOR constant;
391
+ template <typename DEVICE, typename T_TENSOR>
392
+ RL_TOOLS_FUNCTION_PLACEMENT static typename T_TENSOR::SPEC::T operation(DEVICE& device, const ConstantFromTensor<T_TENSOR>& parameter, typename T_TENSOR::SPEC::T a){
393
+ return get(device, parameter.constant, 0);
394
+ }
395
+ };
396
+ struct Sigmoid: Operation {
397
+ template <typename DEVICE, typename T>
398
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const Sigmoid& parameter, T a){
399
+ if(a < -20) return 0;
400
+ if(a > 20) return 1;
401
+ return 1 / (1 + math::exp(device.math, -a));
402
+ }
403
+ };
404
+ struct FastSigmoid: Operation {
405
+ template <typename DEVICE, typename T>
406
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const FastSigmoid& parameter, T a){
407
+ return math::fast_sigmoid(device.math, a);
408
+ }
409
+ };
410
+ struct Exp: Operation {
411
+ template <typename DEVICE, typename T>
412
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const Exp& parameter, T a){
413
+ return math::exp(device.math, a);
414
+ }
415
+ };
416
+ struct Tanh: Operation {
417
+ template <typename DEVICE, typename T>
418
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const Tanh& parameter, T a){
419
+ return math::tanh(device.math, a);
420
+ }
421
+ };
422
+ struct FastTanh: Operation {
423
+ template <typename DEVICE, typename T>
424
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const FastTanh& parameter, T a){
425
+ return math::fast_tanh(device.math, a);
426
+ }
427
+ };
428
+ struct OneMinus: Operation {
429
+ template <typename DEVICE, typename T>
430
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const OneMinus& parameter, T a){
431
+ return 1 - a;
432
+ }
433
+ };
434
+ struct Increment: Operation {
435
+ template <typename DEVICE, typename T>
436
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const Increment& parameter, T a){
437
+ return a + 1;
438
+ }
439
+ };
440
+ template <typename T>
441
+ struct Scale: Operation{
442
+ T scale;
443
+ bool reciprocal;
444
+ template <typename DEVICE, typename T_T>
445
+ RL_TOOLS_FUNCTION_PLACEMENT T_T static operation(DEVICE& device, const Scale<T_T>& parameter, T_T a){
446
+ if(parameter.reciprocal){
447
+ return ((T_T)1.0)/a * parameter.scale;
448
+ }
449
+ else{
450
+ return a * parameter.scale;
451
+ }
452
+ }
453
+ };
454
+ }
455
+ namespace operations::binary{
456
+ struct LogicalOr: Operation{
457
+ template <typename DEVICE, typename T1, typename T2>
458
+ RL_TOOLS_FUNCTION_PLACEMENT static bool operation(DEVICE&, const LogicalOr&, T1 a, T2 b){
459
+ return a || b;
460
+ }
461
+ };
462
+ struct Add: Operation{
463
+ template <typename DEVICE, typename T1, typename T2>
464
+ RL_TOOLS_FUNCTION_PLACEMENT static auto operation(DEVICE& device, const Add& parameter, T1 a, T2 b){
465
+ return a + b;
466
+ }
467
+ };
468
+ struct Subtract: Operation{
469
+ template <typename DEVICE, typename T1, typename T2>
470
+ RL_TOOLS_FUNCTION_PLACEMENT static auto operation(DEVICE& device, const Subtract& parameter, T1 a, T2 b){
471
+ return a - b;
472
+ }
473
+ };
474
+ struct Multiply: Operation{
475
+ template <typename DEVICE, typename T1, typename T2>
476
+ RL_TOOLS_FUNCTION_PLACEMENT static auto operation(DEVICE& device, const Multiply& parameter, T1 a, T2 b){
477
+ return a * b;
478
+ }
479
+ };
480
+ struct Divide: Operation{
481
+ template <typename DEVICE, typename T>
482
+ RL_TOOLS_FUNCTION_PLACEMENT static T operation(DEVICE& device, const Divide parameter, T a, T b){
483
+ return a / b;
484
+ }
485
+ };
486
+ }
487
+ namespace operations::ternary{
488
+ template <typename T>
489
+ struct MultiplyAccumulate: Operation{
490
+ template <typename DEVICE, typename T_T>
491
+ RL_TOOLS_FUNCTION_PLACEMENT T_T static operation(DEVICE& device, const MultiplyAccumulate<T_T>& parameter, T_T a, T_T b, T_T acc){
492
+ return acc + a * b;
493
+ }
494
+ };
495
+ }
496
+ template <typename PARAMETER, typename T_ACCUMULATOR_TYPE, typename T_CURRENT_TYPE, auto T_UNARY_REDUCE_OPERATION>
497
+ struct UnaryReduceOperation{
498
+ using ACCUMULATOR_TYPE = T_ACCUMULATOR_TYPE;
499
+ using CURRENT_TYPE = T_CURRENT_TYPE;
500
+ static constexpr auto UNARY_REDUCE_OPERATION = T_UNARY_REDUCE_OPERATION;
501
+ PARAMETER parameter;
502
+ ACCUMULATOR_TYPE initial_value;
503
+ };
504
+ namespace unary_reduce_operations{
505
+ namespace impl{
506
+ template <typename DEVICE, typename PARAMETER, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE>
507
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE sum(DEVICE, const PARAMETER& parameter, const ACCUMULATOR_TYPE& accumulator, CURRENT_TYPE current){
508
+ return accumulator + current;
509
+ }
510
+ template <typename DEVICE, typename PARAMETER, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE>
511
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE squared_sum(DEVICE, const PARAMETER& parameter, const ACCUMULATOR_TYPE& accumulator, CURRENT_TYPE current){
512
+ return accumulator + current * current;
513
+ }
514
+ template <typename DEVICE, typename PARAMETER, typename CURRENT_TYPE>
515
+ RL_TOOLS_FUNCTION_PLACEMENT CURRENT_TYPE sum_reduce(DEVICE, const PARAMETER& parameter, CURRENT_TYPE a, CURRENT_TYPE b){
516
+ return a + b;
517
+ }
518
+ template <typename DEVICE, typename PARAMETER, typename CURRENT_TYPE>
519
+ RL_TOOLS_FUNCTION_PLACEMENT bool is_nan(DEVICE& device, const PARAMETER& parameter, const bool& accumulator, CURRENT_TYPE current){
520
+ return accumulator || math::is_nan(device, current);
521
+ }
522
+ template <typename DEVICE, typename PARAMETER, typename CURRENT_TYPE>
523
+ RL_TOOLS_FUNCTION_PLACEMENT bool is_finite(DEVICE& device, const PARAMETER& parameter, const bool& accumulator, CURRENT_TYPE current){
524
+ return accumulator || math::is_finite(device, current);
525
+ }
526
+ template <typename DEVICE, typename PARAMETER>
527
+ RL_TOOLS_FUNCTION_PLACEMENT bool is_nan_reduce(DEVICE& device, const PARAMETER& parameter, bool a, bool b){
528
+ return a || b;
529
+ }
530
+ }
531
+ template <typename DEVICE, typename T>
532
+ using Sum = UnaryReduceOperation<OperationEmptyParameter, T, T, impl::sum<DEVICE, OperationEmptyParameter, T, T>>;
533
+ template <typename DEVICE, typename T>
534
+ using SquaredSum = UnaryReduceOperation<OperationEmptyParameter, T, T, impl::squared_sum<DEVICE, OperationEmptyParameter, T, T>>;
535
+ template <typename TARGET_TYPE, typename DEVICE, typename T>
536
+ using CastSum = UnaryReduceOperation<OperationEmptyParameter, T, T, impl::sum<DEVICE, OperationEmptyParameter, TARGET_TYPE, TARGET_TYPE>>;
537
+ template <typename DEVICE, typename T>
538
+ using IsNan = UnaryReduceOperation<OperationEmptyParameter, bool, T, impl::is_nan<DEVICE, OperationEmptyParameter, T>>;
539
+ template <typename DEVICE, typename T>
540
+ using IsFinite = UnaryReduceOperation<OperationEmptyParameter, bool, T, impl::is_finite<DEVICE, OperationEmptyParameter, T>>;
541
+ namespace impl{
542
+ template <typename DEVICE, typename PARAMETER, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE>
543
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE abs_sum(DEVICE& device, const PARAMETER& parameter, const ACCUMULATOR_TYPE& accumulator, CURRENT_TYPE current){
544
+ return accumulator + math::abs(device, current);
545
+ }
546
+ template <typename DEVICE, typename PARAMETER, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE>
547
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE abs_max(DEVICE& device, const PARAMETER& parameter, const ACCUMULATOR_TYPE& accumulator, CURRENT_TYPE current){
548
+ return math::max(device, accumulator, math::abs(device, current));
549
+ }
550
+ template <typename DEVICE, typename PARAMETER, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE>
551
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE abs_min(DEVICE& device, const PARAMETER& parameter, const ACCUMULATOR_TYPE& accumulator, CURRENT_TYPE current){
552
+ return math::min(device, accumulator, math::abs(device, current));
553
+ }
554
+ }
555
+ template <typename DEVICE, typename T>
556
+ using AbsSum = UnaryReduceOperation<OperationEmptyParameter, T, T, impl::abs_sum<DEVICE, OperationEmptyParameter, T, T>>;
557
+ template <typename DEVICE, typename T>
558
+ using AbsMax = UnaryReduceOperation<OperationEmptyParameter, T, T, impl::abs_max<DEVICE, OperationEmptyParameter, T, T>>;
559
+ template <typename DEVICE, typename T>
560
+ using AbsMin = UnaryReduceOperation<OperationEmptyParameter, T, T, impl::abs_min<DEVICE, OperationEmptyParameter, T, T>>;
561
+ }
562
+ template <typename PARAMETER, typename T_ACCUMULATOR_TYPE, typename T_CURRENT_TYPE1, typename T_CURRENT_TYPE2, auto T_OPERATION, auto T_REDUCE_OPERATION>
563
+ struct BinaryReduceOperation{
564
+ using ACCUMULATOR_TYPE = T_ACCUMULATOR_TYPE;
565
+ using CURRENT_TYPE1 = T_CURRENT_TYPE1;
566
+ using CURRENT_TYPE2 = T_CURRENT_TYPE2;
567
+ static constexpr auto OPERATION = T_OPERATION;
568
+ static constexpr auto REDUCE_OPERATION = T_REDUCE_OPERATION; // the associative part
569
+ PARAMETER parameter;
570
+ ACCUMULATOR_TYPE initial_value;
571
+ };
572
+ namespace binary_reduce_operations{
573
+ namespace impl{
574
+ template <typename DEVICE, typename PARAMETER, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE1, typename CURRENT_TYPE2>
575
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE absolute_difference(DEVICE& device, const PARAMETER& parameter, const ACCUMULATOR_TYPE& accumulator, CURRENT_TYPE1 current1, CURRENT_TYPE2 current2){
576
+ return accumulator + math::abs(device.math, current1 - current2);
577
+ }
578
+ template <typename DEVICE, typename PARAMETER, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE>
579
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE sum(DEVICE& device, const PARAMETER& parameter, const ACCUMULATOR_TYPE& accumulator, CURRENT_TYPE current){
580
+ return accumulator + current;
581
+ }
582
+ }
583
+ template <typename DEVICE, typename T1, typename T2>
584
+ using AbsoluteDifference = BinaryReduceOperation<OperationEmptyParameter, T1, T1, T2, impl::absolute_difference<DEVICE, OperationEmptyParameter, T1, T1, T2>, impl::sum<DEVICE, OperationEmptyParameter, T1, T1>>;
585
+ }
586
+ }
587
+ template<typename DEVICE, typename OPERATION, typename SPEC_1, typename SPEC_2, typename SPEC_OUT>
588
+ RL_TOOLS_FUNCTION_PLACEMENT void binary_operation(DEVICE& device, const OPERATION& operation, Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2, Tensor<SPEC_OUT>& result){
589
+ using T_RESULT = typename SPEC_OUT::T;
590
+ using TI = typename DEVICE::index_t;
591
+ static_assert(tensor::same_dimensions<SPEC_1, SPEC_2>());
592
+ static_assert(tensor::same_dimensions<SPEC_1, SPEC_OUT>());
593
+ if constexpr(length(typename SPEC_1::SHAPE{}) > 1){
594
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); ++i){
595
+ auto next_t1 = view(device, t1, i);
596
+ auto next_t2 = view(device, t2, i);
597
+ auto next_result = view(device, result, i);
598
+ binary_operation(device, operation, next_t1, next_t2, next_result);
599
+ }
600
+ }
601
+ else{
602
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); i++){
603
+ auto t1_value = get(device, t1, i);
604
+ auto t2_value = get(device, t2, i);
605
+ T_RESULT result_value = OPERATION::operation(device, operation, t1_value, t2_value);
606
+ set(device, result, result_value, i);
607
+ }
608
+ }
609
+ }
610
+ template<typename DEVICE, typename OPERATION, typename SPEC_1, typename SPEC_2>
611
+ RL_TOOLS_FUNCTION_PLACEMENT void binary_operation(DEVICE& device, const OPERATION operation, const Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2){
612
+ using T = typename SPEC_1::T;
613
+ using TI = typename DEVICE::index_t;
614
+ static_assert(tensor::same_dimensions<SPEC_1, SPEC_2>());
615
+ if constexpr(length(typename SPEC_1::SHAPE{}) > 1){
616
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); ++i){
617
+ auto next_t1 = view(device, t1, i);
618
+ auto next_t2 = view(device, t2, i);
619
+ binary_operation(device, operation, next_t1, next_t2);
620
+ }
621
+ }
622
+ else{
623
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); i++){
624
+ T t1_value = get(device, t1, i);
625
+ T t2_value = get(device, t2, i);
626
+ T result_value = OPERATION::operation(device, operation, t1_value, t2_value);
627
+ set(device, t2, result_value, i);
628
+ }
629
+ }
630
+ }
631
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2>
632
+ RL_TOOLS_FUNCTION_PLACEMENT void add(DEVICE& device, Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2){
633
+ binary_operation(device, tensor::operations::binary::Add{}, t1, t2);
634
+ }
635
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUT>
636
+ RL_TOOLS_FUNCTION_PLACEMENT void subtract(DEVICE& device, Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2, Tensor<SPEC_OUT>& result){
637
+ binary_operation(device, tensor::operations::binary::Subtract{}, t1, t2, result);
638
+ }
639
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2>
640
+ RL_TOOLS_FUNCTION_PLACEMENT void multiply(DEVICE& device, Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2){
641
+ binary_operation(device, tensor::operations::binary::Multiply{}, t1, t2);
642
+ }
643
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUTPUT>
644
+ RL_TOOLS_FUNCTION_PLACEMENT void multiply(DEVICE& device, Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2, Tensor<SPEC_OUTPUT>& t_output){
645
+ binary_operation(device, tensor::operations::binary::Multiply{}, t1, t2, t_output);
646
+ }
647
+
648
+ template<typename DEVICE, typename OPERATION, typename SPEC, typename SPEC_OUTPUT>
649
+ RL_TOOLS_FUNCTION_PLACEMENT void unary_operation(DEVICE& device, const OPERATION& operation, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output){
650
+ using T = typename SPEC::T;
651
+ using TI = typename DEVICE::index_t;
652
+ if constexpr(length(typename SPEC::SHAPE{}) > 1){
653
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); ++i){
654
+ auto next_t = view(device, t, i);
655
+ auto next_output = view(device, output, i);
656
+ unary_operation(device, operation, next_t, next_output);
657
+ }
658
+ }
659
+ else{
660
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); i++){
661
+ T t_value = get(device, t, i);
662
+ T result_value = OPERATION::operation(device, operation, t_value);
663
+ set(device, output, result_value, i);
664
+ }
665
+ }
666
+ }
667
+ template<typename DEVICE, typename OPERATION, typename SPEC>
668
+ RL_TOOLS_FUNCTION_PLACEMENT void unary_operation(DEVICE& device, const OPERATION& operation, Tensor<SPEC>& t){
669
+ unary_operation(device, operation, t, t);
670
+ }
671
+ template<typename DEVICE, typename SPEC>
672
+ RL_TOOLS_FUNCTION_PLACEMENT void exp(DEVICE& device, Tensor<SPEC>& t){
673
+ using T = typename SPEC::T;
674
+ unary_operation(device, tensor::operations::unary::Exp{}, t);
675
+ }
676
+ template<typename DEVICE, typename SPEC, typename SPEC_OUTPUT>
677
+ RL_TOOLS_FUNCTION_PLACEMENT void exp(DEVICE& device, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output){
678
+ static_assert(tensor::same_dimensions<SPEC, SPEC_OUTPUT>());
679
+ using T = typename SPEC::T;
680
+ unary_operation(device, tensor::operations::unary::Exp{}, t, output);
681
+ }
682
+ template<typename DEVICE, typename SPEC>
683
+ RL_TOOLS_FUNCTION_PLACEMENT void sigmoid(DEVICE& device, Tensor<SPEC>& t){
684
+ using T = typename SPEC::T;
685
+ unary_operation(device, tensor::operations::unary::Sigmoid{}, t);
686
+ }
687
+ template<typename DEVICE, typename SPEC, typename SPEC_OUTPUT>
688
+ RL_TOOLS_FUNCTION_PLACEMENT void sigmoid(DEVICE& device, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output){
689
+ static_assert(tensor::same_dimensions<SPEC, SPEC_OUTPUT>());
690
+ using T = typename SPEC::T;
691
+ unary_operation(device, tensor::operations::unary::Sigmoid{}, t, output);
692
+ }
693
+ template<typename DEVICE, typename SPEC>
694
+ RL_TOOLS_FUNCTION_PLACEMENT void fast_sigmoid(DEVICE& device, Tensor<SPEC>& t){
695
+ using T = typename SPEC::T;
696
+ unary_operation(device, tensor::operations::unary::FastSigmoid{}, t);
697
+ }
698
+ template<typename DEVICE, typename SPEC, typename SPEC_OUTPUT>
699
+ RL_TOOLS_FUNCTION_PLACEMENT void fast_sigmoid(DEVICE& device, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output){
700
+ static_assert(tensor::same_dimensions<SPEC, SPEC_OUTPUT>());
701
+ using T = typename SPEC::T;
702
+ unary_operation(device, tensor::operations::unary::FastSigmoid{}, t, output);
703
+ }
704
+ template<typename DEVICE, typename SPEC>
705
+ RL_TOOLS_FUNCTION_PLACEMENT void tanh(DEVICE& device, Tensor<SPEC>& t){
706
+ using T = typename SPEC::T;
707
+ unary_operation(device, tensor::operations::unary::Tanh{}, t);
708
+ }
709
+ template<typename DEVICE, typename SPEC, typename SPEC_OUTPUT>
710
+ RL_TOOLS_FUNCTION_PLACEMENT void tanh(DEVICE& device, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output){
711
+ static_assert(tensor::same_dimensions<SPEC, SPEC_OUTPUT>());
712
+ using T = typename SPEC::T;
713
+ unary_operation(device, tensor::operations::unary::Tanh{}, t, output);
714
+ }
715
+ template<typename DEVICE, typename SPEC>
716
+ RL_TOOLS_FUNCTION_PLACEMENT void fast_tanh(DEVICE& device, Tensor<SPEC>& t){
717
+ using T = typename SPEC::T;
718
+ unary_operation(device, tensor::operations::unary::FastTanh{}, t);
719
+ }
720
+ template<typename DEVICE, typename SPEC, typename SPEC_OUTPUT>
721
+ RL_TOOLS_FUNCTION_PLACEMENT void fast_tanh(DEVICE& device, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output){
722
+ static_assert(tensor::same_dimensions<SPEC, SPEC_OUTPUT>());
723
+ using T = typename SPEC::T;
724
+ unary_operation(device, tensor::operations::unary::FastTanh{}, t, output);
725
+ }
726
+ template<typename DEVICE, typename SPEC>
727
+ RL_TOOLS_FUNCTION_PLACEMENT void scale(DEVICE& device, Tensor<SPEC>& t, typename SPEC::T scale, bool reciprocal = false){
728
+ using T = typename SPEC::T;
729
+ tensor::operations::unary::Scale<T> operation;
730
+ operation.scale = scale;
731
+ operation.reciprocal = reciprocal;
732
+ unary_operation(device, operation, t);
733
+ }
734
+ template<typename DEVICE, typename SPEC, typename SPEC_OUTPUT>
735
+ RL_TOOLS_FUNCTION_PLACEMENT void scale(DEVICE& device, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output, bool reciprocal = false){
736
+ static_assert(tensor::same_dimensions<SPEC, SPEC_OUTPUT>());
737
+ using T = typename SPEC::T;
738
+ tensor::operations::unary::Scale<T> operation;
739
+ operation.scale = scale;
740
+ operation.reciprocal = reciprocal;
741
+ unary_operation(device, operation, t, output);
742
+ }
743
+ template<typename DEVICE, typename SPEC>
744
+ RL_TOOLS_FUNCTION_PLACEMENT void abs(DEVICE& device, Tensor<SPEC>& t){
745
+ using T = typename SPEC::T;
746
+ unary_operation(device, tensor::operations::unary::Abs{}, t);
747
+ }
748
+
749
+ template<typename DEVICE, typename SPEC>
750
+ RL_TOOLS_FUNCTION_PLACEMENT void set_all(DEVICE& device, Tensor<SPEC>& t, typename SPEC::T value){
751
+ tensor::operations::unary::Constant<typename SPEC::T> op;
752
+ op.constant = value;
753
+ unary_operation(device, op, t);
754
+ }
755
+ template<typename DEVICE, typename SPEC, typename VALUE_SPEC>
756
+ RL_TOOLS_FUNCTION_PLACEMENT void set_all(DEVICE& device, Tensor<SPEC>& t, Tensor<VALUE_SPEC>& value){
757
+ static_assert(VALUE_SPEC::SHAPE::LENGTH == 1);
758
+ static_assert(VALUE_SPEC::SHAPE::template GET<0> == 1);
759
+ tensor::operations::unary::ConstantFromTensor<Tensor<VALUE_SPEC>> op;
760
+ op.constant = value;
761
+ unary_operation(device, op, t);
762
+ }
763
+ template<typename DEVICE, typename SPEC>
764
+ RL_TOOLS_FUNCTION_PLACEMENT void increment(DEVICE& device, Tensor<SPEC>& t){
765
+ unary_operation(device, tensor::operations::unary::Increment{}, t);
766
+ }
767
+ template<typename DEVICE, typename SPEC>
768
+ RL_TOOLS_FUNCTION_PLACEMENT void one_minus(DEVICE& device, Tensor<SPEC>& t){
769
+ using T = typename SPEC::T;
770
+ using PARAMETER = T;
771
+ unary_operation(device, tensor::operations::unary::OneMinus{}, t);
772
+ }
773
+ template<typename DEVICE, typename SPEC, typename SPEC_OUTPUT>
774
+ RL_TOOLS_FUNCTION_PLACEMENT void one_minus(DEVICE& device, Tensor<SPEC>& t, Tensor<SPEC_OUTPUT>& output){
775
+ using T = typename SPEC::T;
776
+ using PARAMETER = T;
777
+ unary_operation(device, tensor::operations::unary::OneMinus{}, t, output);
778
+ }
779
+
780
+
781
+
782
+ template<typename DEVICE, typename SPEC, auto UNARY_REDUCE_OPERATION, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE, typename OPERATION_PARAMETER>
783
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE _unary_associative_reduce(DEVICE& device, const tensor::UnaryReduceOperation<OPERATION_PARAMETER, ACCUMULATOR_TYPE, CURRENT_TYPE, UNARY_REDUCE_OPERATION>& op, const Tensor<SPEC>& t, ACCUMULATOR_TYPE accumulator){
784
+ using T = typename SPEC::T;
785
+ using TI = typename DEVICE::index_t;
786
+ if constexpr(length(typename SPEC::SHAPE{}) > 1){
787
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); ++i){
788
+ auto next_t = view(device, t, i);
789
+ accumulator = _unary_associative_reduce(device, op, next_t, accumulator);
790
+ }
791
+ return accumulator;
792
+ }
793
+ else{
794
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); i++){
795
+ T t_value = get(device, t, i);
796
+ accumulator = UNARY_REDUCE_OPERATION(device.math, op.parameter, accumulator, static_cast<CURRENT_TYPE>(t_value));
797
+ }
798
+ return accumulator;
799
+ }
800
+ }
801
+ template<typename DEVICE, typename SPEC, auto UNARY_REDUCE_OPERATION, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE, typename OPERATION_PARAMETER>
802
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE unary_associative_reduce(DEVICE& device, const tensor::UnaryReduceOperation<OPERATION_PARAMETER, ACCUMULATOR_TYPE, CURRENT_TYPE, UNARY_REDUCE_OPERATION>& op, const Tensor<SPEC>& t){
803
+ return _unary_associative_reduce(device, op, t, op.initial_value);
804
+ }
805
+ template<typename DEVICE, typename SPEC, auto UNARY_REDUCE_OPERATION, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE, typename OPERATION_PARAMETER, typename RESULT_SPEC>
806
+ RL_TOOLS_FUNCTION_PLACEMENT void unary_associative_reduce(DEVICE& device, const tensor::UnaryReduceOperation<OPERATION_PARAMETER, ACCUMULATOR_TYPE, CURRENT_TYPE, UNARY_REDUCE_OPERATION>& op, const Tensor<SPEC>& t, Tensor<RESULT_SPEC>& result){
807
+ static_assert(RESULT_SPEC::SHAPE::LENGTH == 1);
808
+ static_assert(RESULT_SPEC::SHAPE::template GET<0> == 1);
809
+ ACCUMULATOR_TYPE result_value = _unary_associative_reduce(device, op, t, op.initial_value);
810
+ set(device, result, result_value, 0);
811
+ }
812
+
813
+ template<typename DEVICE, typename SPEC>
814
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T sum(DEVICE& device, Tensor<SPEC>& t){
815
+ static_assert(!utils::typing::is_same_v<typename SPEC::T, bool>, "Sum would work like or for boolean tensors");
816
+ tensor::unary_reduce_operations::Sum<decltype(device.math), typename SPEC::T> op;
817
+ op.initial_value = 0;
818
+ return unary_associative_reduce(device, op, t);
819
+ }
820
+ template<typename DEVICE, typename SPEC>
821
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T squared_sum(DEVICE& device, const Tensor<SPEC>& t){
822
+ static_assert(!utils::typing::is_same_v<typename SPEC::T, bool>, "Sum would work like or for boolean tensors");
823
+ tensor::unary_reduce_operations::SquaredSum<decltype(device.math), typename SPEC::T> op;
824
+ op.initial_value = 0;
825
+ return unary_associative_reduce(device, op, t);
826
+ }
827
+ template<typename DEVICE, typename SPEC>
828
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T abs_sum(DEVICE& device, const Tensor<SPEC>& t){
829
+ tensor::unary_reduce_operations::AbsSum<decltype(device.math), typename SPEC::T> op;
830
+ op.initial_value = 0;
831
+ return unary_associative_reduce(device, op, t);
832
+ }
833
+ template<typename DEVICE, typename SPEC>
834
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T abs_mean(DEVICE& device, const Tensor<SPEC>& t){
835
+ return abs_sum(device, t) / SPEC::SIZE;
836
+ }
837
+ template<typename DEVICE, typename SPEC>
838
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T abs_max(DEVICE& device, const Tensor<SPEC>& t){
839
+ tensor::unary_reduce_operations::AbsMax<decltype(device.math), typename SPEC::T> op;
840
+ op.initial_value = 0;
841
+ return unary_associative_reduce(device, op, t);
842
+ }
843
+ template<typename DEVICE, typename SPEC>
844
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::T abs_min(DEVICE& device, const Tensor<SPEC>& t){
845
+ using T = typename SPEC::T;
846
+ tensor::unary_reduce_operations::AbsMin<decltype(device.math), T> op;
847
+ op.initial_value = (T)1e38;
848
+ return unary_associative_reduce(device, op, t);
849
+ }
850
+ template<typename TARGET_TYPE, typename DEVICE, typename SPEC>
851
+ RL_TOOLS_FUNCTION_PLACEMENT TARGET_TYPE cast_reduce_sum(DEVICE& device, const Tensor<SPEC>& t){
852
+ tensor::unary_reduce_operations::CastSum<TARGET_TYPE, decltype(device.math), TARGET_TYPE> op;
853
+ op.initial_value = 0;
854
+ return unary_associative_reduce(device, op, t);
855
+ }
856
+ template<typename TARGET_TYPE, typename DEVICE, typename SPEC, typename RESULT_SPEC>
857
+ RL_TOOLS_FUNCTION_PLACEMENT void cast_reduce_sum(DEVICE& device, const Tensor<SPEC>& t, Tensor<RESULT_SPEC>& result){
858
+ static_assert(RESULT_SPEC::SHAPE::LENGTH == 1);
859
+ static_assert(RESULT_SPEC::SHAPE::template GET<0> == 1);
860
+ tensor::unary_reduce_operations::CastSum<TARGET_TYPE, decltype(device.math), TARGET_TYPE> op;
861
+ op.initial_value = 0;
862
+ unary_associative_reduce(device, op, t, result);
863
+ }
864
+ template<typename DEVICE, typename SPEC, typename MODE = mode::Default<>>
865
+ RL_TOOLS_FUNCTION_PLACEMENT bool is_nan(DEVICE& device, const Tensor<SPEC>& t, const Mode<MODE>& mode = {}){
866
+ tensor::unary_reduce_operations::IsNan<decltype(device.math), typename SPEC::T> op;
867
+ op.initial_value = false;
868
+ return unary_associative_reduce(device, op, t);
869
+ }
870
+ template<typename DEVICE, typename SPEC>
871
+ RL_TOOLS_FUNCTION_PLACEMENT bool is_finite(DEVICE& device, const Tensor<SPEC>& t){
872
+ tensor::unary_reduce_operations::IsFinite<decltype(device.math), typename SPEC::T> op;
873
+ op.initial_value = false;
874
+ return unary_associative_reduce(device, op, t);
875
+ }
876
+
877
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_3, typename SPEC_OUT, typename OPERATION>
878
+ RL_TOOLS_FUNCTION_PLACEMENT void ternary_operation(DEVICE& device, const OPERATION& op, const Tensor<SPEC_1>& t1, const Tensor<SPEC_2>& t2, const Tensor<SPEC_3>& t3, Tensor<SPEC_OUT>& result){
879
+ using T = typename SPEC_1::T;
880
+ using TI = typename DEVICE::index_t;
881
+ static_assert(tensor::same_dimensions<SPEC_1, SPEC_2>());
882
+ static_assert(tensor::same_dimensions<SPEC_2, SPEC_3>());
883
+ static_assert(tensor::same_dimensions<SPEC_3, SPEC_OUT>());
884
+ if constexpr(length(typename SPEC_1::SHAPE{}) > 1){
885
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); ++i){
886
+ auto next_t1 = view(device, t1, i);
887
+ auto next_t2 = view(device, t2, i);
888
+ auto next_t3 = view(device, t3, i);
889
+ auto next_result = view(device, result, i);
890
+ ternary_operation(device, op, next_t1, next_t2, next_t3, next_result);
891
+ }
892
+ }
893
+ else{
894
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); i++){
895
+ T t1_value = get(device, t1, i);
896
+ T t2_value = get(device, t2, i);
897
+ T t3_value = get(device, t3, i);
898
+ T result_value = OPERATION::operation(device, op, t1_value, t2_value, t3_value);
899
+ set(device, result, result_value, i);
900
+ }
901
+ }
902
+ }
903
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUT, typename OPERATION>
904
+ RL_TOOLS_FUNCTION_PLACEMENT void ternary_operation(DEVICE& device, const OPERATION& op, const Tensor<SPEC_1>& t1, const Tensor<SPEC_2>& t2, Tensor<SPEC_OUT>& result){
905
+ ternary_operation(device, op, t1, t2, result, result);
906
+ }
907
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUTPUT>
908
+ RL_TOOLS_FUNCTION_PLACEMENT void multiply_accumulate(DEVICE& device, const Tensor<SPEC_1>& t1, const Tensor<SPEC_2>& t2, Tensor<SPEC_OUTPUT>& t_output){
909
+ #ifdef RL_TOOLS_ENABLE_TRACY
910
+ ZoneScopedN("tensor::multiply_accumulate");
911
+ #endif
912
+ ternary_operation(device, tensor::operations::ternary::MultiplyAccumulate<typename SPEC_1::T>{}, t1, t2, t_output);
913
+ }
914
+
915
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, auto BINARY_REDUCE_OPERATION, auto BINARY_ASSOCIATIVE_REDUCE_OPERATION, typename ACCUMULATOR_TYPE, typename CURRENT_TYPE1, typename CURRENT_TYPE2, typename OPERATION_PARAMETER>
916
+ RL_TOOLS_FUNCTION_PLACEMENT ACCUMULATOR_TYPE binary_associative_reduce(DEVICE& device, const tensor::BinaryReduceOperation<OPERATION_PARAMETER, ACCUMULATOR_TYPE, CURRENT_TYPE1, CURRENT_TYPE2, BINARY_REDUCE_OPERATION, BINARY_ASSOCIATIVE_REDUCE_OPERATION>& op, const Tensor<SPEC_1>& t1, const Tensor<SPEC_2>& t2){
917
+ using T = typename SPEC_1::T;
918
+ using TI = typename DEVICE::index_t;
919
+ static_assert(tensor::same_dimensions<SPEC_1, SPEC_2>());
920
+ if constexpr(length(typename SPEC_1::SHAPE{}) > 1){
921
+ ACCUMULATOR_TYPE accumulator = op.initial_value;
922
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); ++i){
923
+ auto next_t1 = view(device, t1, i);
924
+ auto next_t2 = view(device, t2, i);
925
+ accumulator = BINARY_ASSOCIATIVE_REDUCE_OPERATION(device, op.parameter, accumulator, binary_associative_reduce(device, op, next_t1, next_t2));
926
+ }
927
+ return accumulator;
928
+ }
929
+ else{
930
+ ACCUMULATOR_TYPE accumulator = op.initial_value;
931
+ for(TI i=0; i < get<0>(typename SPEC_1::SHAPE{}); i++){
932
+ T t1_value = get(device, t1, i);
933
+ T t2_value = get(device, t2, i);
934
+ accumulator = BINARY_REDUCE_OPERATION(device, op.parameter, accumulator, t1_value, t2_value);
935
+ }
936
+ return accumulator;
937
+ }
938
+ }
939
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2>
940
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC_1::T abs_diff(DEVICE& device, const Tensor<SPEC_1>& t1, const Tensor<SPEC_2>& t2){
941
+ tensor::binary_reduce_operations::AbsoluteDifference<DEVICE, typename SPEC_1::T, typename SPEC_2::T> op{};
942
+ op.initial_value = 0;
943
+ return binary_associative_reduce(device, op, t1, t2);
944
+ }
945
+
946
+ template <bool ACCUMULATE, typename DEVICE, typename SPEC, typename OUTPUT_SPEC, auto SIZE=0, auto DIM=length(typename SPEC::SHAPE{})-1>
947
+ RL_TOOLS_FUNCTION_PLACEMENT auto reduce_sum(DEVICE& device, Tensor<SPEC>& input, Tensor<OUTPUT_SPEC>& output, tensor::ViewSpec<DIM, SIZE> = tensor::ViewSpec<length(typename SPEC::SHAPE{})-1, SIZE>{}){
948
+ // reduces along the last dimension by default
949
+ static_assert(DIM == length(typename SPEC::SHAPE{}) - 1); // only supporting the last dimension for now
950
+ using EXPECTED_OUTPUT_SHAPE = tensor::Remove<typename SPEC::SHAPE, DIM>;
951
+ using TI = typename DEVICE::index_t;
952
+ using T = typename SPEC::T;
953
+ static_assert(tensor::same_dimensions_shape<typename OUTPUT_SPEC::SHAPE, EXPECTED_OUTPUT_SHAPE>());
954
+ if constexpr(length(typename SPEC::SHAPE{}) == 2){
955
+ for(TI row_i=0; row_i < get<0>(typename SPEC::SHAPE{}); ++row_i){
956
+ auto input_row = view(device, input, row_i);
957
+
958
+ T aggregate = sum(device, input_row);
959
+ if constexpr(ACCUMULATE){
960
+ aggregate += get(device, output, row_i);
961
+ }
962
+ set(device, output, aggregate, row_i);
963
+ }
964
+ }
965
+ else{
966
+ for(TI i=0; i < get<0>(typename SPEC::SHAPE{}); ++i){
967
+ auto next_input = view(device, input, i);
968
+ auto next_output = view(device, output, i);
969
+ reduce_sum(device, next_input, next_output);
970
+ }
971
+ }
972
+ }
973
+ template <typename DEVICE, typename SPEC, typename OUTPUT_SPEC, auto SIZE=0, auto DIM=length(typename SPEC::SHAPE{})-1>
974
+ RL_TOOLS_FUNCTION_PLACEMENT auto reduce_sum(DEVICE& device, Tensor<SPEC>& input, Tensor<OUTPUT_SPEC>& output, tensor::ViewSpec<DIM, SIZE> = tensor::ViewSpec<length(typename SPEC::SHAPE{})-1, SIZE>{}){
975
+ reduce_sum<false>(device, input, output);
976
+ }
977
+
978
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUT>
979
+ RL_TOOLS_FUNCTION_PLACEMENT void matrix_multiply(DEVICE& device, Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2, Tensor<SPEC_OUT>& result){
980
+ static_assert(length(typename SPEC_1::SHAPE{}) == 2);
981
+ static_assert(length(typename SPEC_2::SHAPE{}) == 2);
982
+ static_assert(length(typename SPEC_OUT::SHAPE{}) == 2);
983
+ static_assert(get<1>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_2::SHAPE{}));
984
+ static_assert(get<0>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_OUT::SHAPE{}));
985
+ static_assert(get<1>(typename SPEC_2::SHAPE{}) == get<1>(typename SPEC_OUT::SHAPE{}));
986
+ auto a = matrix_view(device, t1);
987
+ auto b = matrix_view(device, t2);
988
+ auto c = matrix_view(device, result);
989
+ multiply(device, a, b, c);
990
+ }
991
+ template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUT>
992
+ RL_TOOLS_FUNCTION_PLACEMENT void matrix_multiply_accumulate(DEVICE& device, const Tensor<SPEC_1>& t1, const Tensor<SPEC_2>& t2, Tensor<SPEC_OUT>& result){
993
+ static_assert(length(typename SPEC_1::SHAPE{}) == 2);
994
+ static_assert(length(typename SPEC_2::SHAPE{}) == 2);
995
+ static_assert(length(typename SPEC_OUT::SHAPE{}) == 2);
996
+ static_assert(get<1>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_2::SHAPE{}));
997
+ static_assert(get<0>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_OUT::SHAPE{}));
998
+ static_assert(get<1>(typename SPEC_2::SHAPE{}) == get<1>(typename SPEC_OUT::SHAPE{}));
999
+ auto a = matrix_view(device, t1);
1000
+ auto b = matrix_view(device, t2);
1001
+ auto c = matrix_view(device, result);
1002
+ multiply_accumulate(device, a, b, c);
1003
+ }
1004
+
1005
+ #ifndef RL_TOOLS_NN_DISABLE_GENERIC_FORWARD_BACKWARD
1006
+ // template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUT>
1007
+ // void matrix_multiply(DEVICE& device, Tensor<SPEC_1>& t1, Tensor<SPEC_2>& t2, Tensor<SPEC_OUT>& result){
1008
+ // static_assert(length(typename SPEC_1::SHAPE{}) == 2);
1009
+ // static_assert(length(typename SPEC_2::SHAPE{}) == 2);
1010
+ // static_assert(length(typename SPEC_OUT::SHAPE{}) == 2);
1011
+ // static_assert(get<1>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_2::SHAPE{}));
1012
+ // static_assert(get<0>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_OUT::SHAPE{}));
1013
+ // static_assert(get<1>(typename SPEC_2::SHAPE{}) == get<1>(typename SPEC_OUT::SHAPE{}));
1014
+ // using T = typename SPEC_1::T;
1015
+ // using TI = typename DEVICE::index_t;
1016
+ // for(TI row_i=0; row_i < get<0>(typename SPEC_1::SHAPE{}); ++row_i){
1017
+ // for(TI col_j=0; col_j < get<1>(typename SPEC_2::SHAPE{}); ++col_j){
1018
+ // T acc = 0;
1019
+ // for(TI k=0; k < get<1>(typename SPEC_1::SHAPE{}); ++k){
1020
+ // acc += get(device, t1, row_i, k) * get(device, t2, k, col_j);
1021
+ // }
1022
+ // set(device, result, acc, row_i, col_j);
1023
+ // }
1024
+ // }
1025
+ // }
1026
+ // template<typename DEVICE, typename SPEC_1, typename SPEC_2, typename SPEC_OUT>
1027
+ // void matrix_multiply_accumulate(DEVICE& device, const Tensor<SPEC_1>& t1, const Tensor<SPEC_2>& t2, Tensor<SPEC_OUT>& result){
1028
+ // static_assert(length(typename SPEC_1::SHAPE{}) == 2);
1029
+ // static_assert(length(typename SPEC_2::SHAPE{}) == 2);
1030
+ // static_assert(length(typename SPEC_OUT::SHAPE{}) == 2);
1031
+ // static_assert(get<1>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_2::SHAPE{}));
1032
+ // static_assert(get<0>(typename SPEC_1::SHAPE{}) == get<0>(typename SPEC_OUT::SHAPE{}));
1033
+ // static_assert(get<1>(typename SPEC_2::SHAPE{}) == get<1>(typename SPEC_OUT::SHAPE{}));
1034
+ // using T = typename SPEC_1::T;
1035
+ // using TI = typename DEVICE::index_t;
1036
+ // for(TI row_i=0; row_i < get<0>(typename SPEC_1::SHAPE{}); ++row_i){
1037
+ // for(TI col_j=0; col_j < get<1>(typename SPEC_2::SHAPE{}); ++col_j){
1038
+ // T acc = get(device, result, row_i, col_j);
1039
+ // for(TI k=0; k < get<1>(typename SPEC_1::SHAPE{}); ++k){
1040
+ // acc += get(device, t1, row_i, k) * get(device, t2, k, col_j);
1041
+ // }
1042
+ // set(device, result, acc, row_i, col_j);
1043
+ // }
1044
+ // }
1045
+ // }
1046
+ #endif
1047
+ // template<typename DEVICE, typename SPEC, typename = utils::typing::enable_if_t<length(typename SPEC::SHAPE{}) == 2, typename SPEC::TI>>
1048
+ // auto matrix_view(DEVICE& device, Tensor<SPEC>& t){
1049
+ // static_assert(tensor::generalized_row_major<typename SPEC::SHAPE, typename SPEC::STRIDE>());
1050
+ // using LAYOUT = matrix::layouts::Fixed<typename SPEC::TI, get<0>(typename SPEC::STRIDE{}), get<1>(typename SPEC::STRIDE{})>;
1051
+ // MatrixDynamic<matrix::Specification<typename SPEC::T, typename SPEC::TI, get<0>(typename SPEC::SHAPE{}), get<1>(typename SPEC::SHAPE{})>> view{data(t)};
1052
+ // return view;
1053
+ // }
1054
+ namespace tensor{
1055
+ template <auto A, auto B>
1056
+ RL_TOOLS_FUNCTION_PLACEMENT constexpr bool greater_than(){
1057
+ return A > B;
1058
+ }
1059
+ template <auto A, auto B>
1060
+ RL_TOOLS_FUNCTION_PLACEMENT constexpr bool equal(){
1061
+ return A == B;
1062
+ }
1063
+ }
1064
+ template<typename DEVICE, typename SPEC>
1065
+ RL_TOOLS_FUNCTION_PLACEMENT auto _matrix_view_one_dim(DEVICE& device, const Tensor<SPEC>& t){
1066
+ using TI = typename SPEC::TI;
1067
+ constexpr TI N_DIM = length(typename SPEC::SHAPE{});
1068
+ static_assert(tensor::generalized_row_major<typename SPEC::SHAPE, typename SPEC::STRIDE>());
1069
+ using ROW_MAJOR_STRIDE = tensor::RowMajorStride<typename SPEC::SHAPE>;
1070
+ static_assert(tensor::same_dimensions_shape<ROW_MAJOR_STRIDE, typename SPEC::STRIDE>(), "Stride must be row major for creating a matrix view");
1071
+ using LAYOUT = matrix::layouts::Fixed<typename SPEC::TI, 1, get<N_DIM-1>(typename SPEC::STRIDE{})>;
1072
+ const Matrix<matrix::Specification<typename SPEC::T, typename SPEC::TI, 1, get<N_DIM-1>(typename SPEC::SHAPE{}), true, LAYOUT, true>> view{data(t)};
1073
+ return view;
1074
+ }
1075
+ template<typename DEVICE, typename SPEC>
1076
+ RL_TOOLS_FUNCTION_PLACEMENT auto _matrix_view_one_dim(DEVICE& device, Tensor<SPEC>& t){
1077
+ using TI = typename SPEC::TI;
1078
+ constexpr TI N_DIM = length(typename SPEC::SHAPE{});
1079
+ static_assert(tensor::generalized_row_major<typename SPEC::SHAPE, typename SPEC::STRIDE>());
1080
+ using ROW_MAJOR_STRIDE = tensor::RowMajorStride<typename SPEC::SHAPE>;
1081
+ static_assert(tensor::same_dimensions_shape<ROW_MAJOR_STRIDE, typename SPEC::STRIDE>(), "Stride must be row major for creating a matrix view");
1082
+ using LAYOUT = matrix::layouts::Fixed<typename SPEC::TI, 1, get<N_DIM-1>(typename SPEC::STRIDE{})>;
1083
+ const Matrix<matrix::Specification<typename SPEC::T, typename SPEC::TI, 1, get<N_DIM-1>(typename SPEC::SHAPE{}), true, LAYOUT>> view{data(t)};
1084
+ return view;
1085
+ }
1086
+ template<typename DEVICE, typename SPEC>
1087
+ RL_TOOLS_FUNCTION_PLACEMENT auto matrix_view(DEVICE& device, const Tensor<SPEC>& t){
1088
+ // broadcasting over the first N-1 dimensions => M x N x K => (M*N) x K
1089
+ using TI = typename SPEC::TI;
1090
+ constexpr TI N_DIM = length(typename SPEC::SHAPE{});
1091
+ if constexpr (N_DIM == 1){
1092
+ return _matrix_view_one_dim(device, t);
1093
+ }
1094
+ else{
1095
+ if constexpr (N_DIM == 2){
1096
+ using LAYOUT = matrix::layouts::Fixed<typename SPEC::TI, SPEC::STRIDE::template GET<0>, SPEC::STRIDE::template GET<1>>;
1097
+ const Matrix<matrix::Specification<typename SPEC::T, typename SPEC::TI, SPEC::SHAPE::template GET<0>, SPEC::SHAPE::template GET<1>, true, LAYOUT, true>> view{{data(t)}};
1098
+ return view;
1099
+ }
1100
+ else{
1101
+ static_assert(tensor::generalized_row_major<typename SPEC::SHAPE, typename SPEC::STRIDE>());
1102
+ static_assert(tensor::dense_row_major_layout<SPEC, true>(), "Stride must be row major for creating a matrix view");
1103
+ using PROD = tensor::CumulativeProduct<tensor::PopBack<typename SPEC::SHAPE>>;
1104
+ constexpr TI TOTAL_ROWS = get<0>(PROD{});
1105
+ using LAYOUT = matrix::layouts::Fixed<typename SPEC::TI, get<N_DIM-2>(typename SPEC::STRIDE{}), get<N_DIM-1>(typename SPEC::STRIDE{})>;
1106
+ const Matrix<matrix::Specification<typename SPEC::T, typename SPEC::TI, TOTAL_ROWS, get<N_DIM-1>(typename SPEC::SHAPE{}), true, LAYOUT, true>> view{{data(t)}};
1107
+ return view;
1108
+ }
1109
+ }
1110
+ }
1111
+ template<typename DEVICE, typename SPEC>
1112
+ RL_TOOLS_FUNCTION_PLACEMENT auto matrix_view(DEVICE& device, Tensor<SPEC>& t)
1113
+ {
1114
+ // broadcasting over the first N-1 dimensions => M x N x K => (M*N) x K
1115
+ using TI = typename SPEC::TI;
1116
+ constexpr TI N_DIM = length(typename SPEC::SHAPE{});
1117
+ if constexpr (N_DIM == 1){
1118
+ return _matrix_view_one_dim(device, t);
1119
+ }
1120
+ else{
1121
+ if constexpr (N_DIM == 2){
1122
+ using LAYOUT = matrix::layouts::Fixed<typename SPEC::TI, SPEC::STRIDE::template GET<0>, SPEC::STRIDE::template GET<1>>;
1123
+ const Matrix<matrix::Specification<typename SPEC::T, typename SPEC::TI, SPEC::SHAPE::template GET<0>, SPEC::SHAPE::template GET<1>, true, LAYOUT, false>> view{{data(t)}};
1124
+ return view;
1125
+ }
1126
+ else{
1127
+ static_assert(tensor::generalized_row_major<typename SPEC::SHAPE, typename SPEC::STRIDE>());
1128
+ static_assert(tensor::dense_row_major_layout<SPEC, true>(), "Stride must be row major for creating a matrix view");
1129
+ using PROD = tensor::CumulativeProduct<tensor::PopBack<typename SPEC::SHAPE>>;
1130
+ constexpr TI TOTAL_ROWS = get<0>(PROD{});
1131
+ using LAYOUT = matrix::layouts::Fixed<typename SPEC::TI, get<N_DIM-2>(typename SPEC::STRIDE{}), get<N_DIM-1>(typename SPEC::STRIDE{})>;
1132
+ const Matrix<matrix::Specification<typename SPEC::T, typename SPEC::TI, TOTAL_ROWS, get<N_DIM-1>(typename SPEC::SHAPE{}), true, LAYOUT, false>> view{{data(t)}};
1133
+ return view;
1134
+ }
1135
+ }
1136
+ }
1137
+ namespace tensor::reshape_row_major_detail{
1138
+ template <typename ELEMENT>
1139
+ struct IsEmpty{
1140
+ static constexpr bool VALUE = length(ELEMENT{}) == 0;
1141
+ };
1142
+ template <typename ELEMENT, typename EMPTY, bool SINGLE = (length(ELEMENT{}) <= 1)>
1143
+ struct PopBackSafe;
1144
+ template <typename ELEMENT, typename EMPTY>
1145
+ struct PopBackSafe<ELEMENT, EMPTY, true>{
1146
+ using TYPE = EMPTY;
1147
+ };
1148
+ template <typename ELEMENT, typename EMPTY>
1149
+ struct PopBackSafe<ELEMENT, EMPTY, false>{
1150
+ using TYPE = tensor::PopBack<ELEMENT>;
1151
+ };
1152
+ template <typename REM_SHAPE, typename REM_STRIDE, auto BLOCK_SIZE, auto BLOCK_FIRST_SIZE, auto BLOCK_FIRST_STRIDE, bool EMPTY = IsEmpty<REM_SHAPE>::VALUE>
1153
+ struct ExpandBlock;
1154
+ template <typename REM_SHAPE, typename REM_STRIDE, auto BLOCK_SIZE, auto BLOCK_FIRST_SIZE, auto BLOCK_FIRST_STRIDE>
1155
+ struct ExpandBlock<REM_SHAPE, REM_STRIDE, BLOCK_SIZE, BLOCK_FIRST_SIZE, BLOCK_FIRST_STRIDE, true>{
1156
+ static constexpr auto SIZE = BLOCK_SIZE;
1157
+ using REMAINDER_SHAPE = REM_SHAPE;
1158
+ using REMAINDER_STRIDE = REM_STRIDE;
1159
+ };
1160
+ template <typename REM_SHAPE, typename REM_STRIDE, auto BLOCK_SIZE, auto BLOCK_FIRST_SIZE, auto BLOCK_FIRST_STRIDE>
1161
+ struct ExpandBlock<REM_SHAPE, REM_STRIDE, BLOCK_SIZE, BLOCK_FIRST_SIZE, BLOCK_FIRST_STRIDE, false>{
1162
+ static constexpr auto PREV_SIZE = get_last(REM_SHAPE{});
1163
+ static constexpr auto PREV_STRIDE = get_last(REM_STRIDE{});
1164
+ static constexpr bool CONTIG = (PREV_STRIDE == BLOCK_FIRST_STRIDE * BLOCK_FIRST_SIZE) || (PREV_SIZE == 1);
1165
+ using NEXT_REM_SHAPE = typename PopBackSafe<REM_SHAPE, tensor::Shape<typename REM_SHAPE::TI>>::TYPE;
1166
+ using NEXT_REM_STRIDE = typename PopBackSafe<REM_STRIDE, tensor::Stride<typename REM_STRIDE::TI>>::TYPE;
1167
+ using NEXT = ExpandBlock<NEXT_REM_SHAPE, NEXT_REM_STRIDE, BLOCK_SIZE * PREV_SIZE, PREV_SIZE, PREV_STRIDE>;
1168
+ using REMAINDER_SHAPE = utils::typing::conditional_t<CONTIG, typename NEXT::REMAINDER_SHAPE, REM_SHAPE>;
1169
+ using REMAINDER_STRIDE = utils::typing::conditional_t<CONTIG, typename NEXT::REMAINDER_STRIDE, REM_STRIDE>;
1170
+ static constexpr auto SIZE = CONTIG ? NEXT::SIZE : BLOCK_SIZE;
1171
+ };
1172
+ template <typename SHAPE, typename STRIDE, bool SINGLE = (length(SHAPE{}) == 1)>
1173
+ struct RightmostBlock;
1174
+ template <typename SHAPE, typename STRIDE>
1175
+ struct RightmostBlock<SHAPE, STRIDE, true>{
1176
+ static constexpr auto BLOCK_SIZE = get_last(SHAPE{});
1177
+ static constexpr auto BLOCK_INNER_STRIDE = get_last(STRIDE{});
1178
+ using REMAINDER_SHAPE = tensor::Shape<typename SHAPE::TI>;
1179
+ using REMAINDER_STRIDE = tensor::Stride<typename STRIDE::TI>;
1180
+ };
1181
+ template <typename SHAPE, typename STRIDE>
1182
+ struct RightmostBlock<SHAPE, STRIDE, false>{
1183
+ static constexpr auto LAST_DIM = get_last(SHAPE{});
1184
+ static constexpr auto LAST_STRIDE = get_last(STRIDE{});
1185
+ using REM_SHAPE = typename PopBackSafe<SHAPE, tensor::Shape<typename SHAPE::TI>>::TYPE;
1186
+ using REM_STRIDE = typename PopBackSafe<STRIDE, tensor::Stride<typename STRIDE::TI>>::TYPE;
1187
+ using EXPAND = ExpandBlock<REM_SHAPE, REM_STRIDE, LAST_DIM, LAST_DIM, LAST_STRIDE>;
1188
+ static constexpr auto BLOCK_SIZE = EXPAND::SIZE;
1189
+ static constexpr auto BLOCK_INNER_STRIDE = LAST_STRIDE;
1190
+ using REMAINDER_SHAPE = typename EXPAND::REMAINDER_SHAPE;
1191
+ using REMAINDER_STRIDE = typename EXPAND::REMAINDER_STRIDE;
1192
+ };
1193
+ template <typename SHAPE, auto BLOCK_SIZE, auto BLOCK_STRIDE, auto CURRENT_PRODUCT, bool EMPTY = IsEmpty<SHAPE>::VALUE>
1194
+ struct ConsumeBlockImpl;
1195
+ template <typename SHAPE, auto BLOCK_SIZE, auto BLOCK_STRIDE, auto CURRENT_PRODUCT>
1196
+ struct ConsumeBlockImpl<SHAPE, BLOCK_SIZE, BLOCK_STRIDE, CURRENT_PRODUCT, true>{
1197
+ static_assert(CURRENT_PRODUCT == BLOCK_SIZE, "Tensor reshape: incompatible shape");
1198
+ using REMAINDER_SHAPE = SHAPE;
1199
+ using STRIDE_SUFFIX = tensor::Stride<typename SHAPE::TI>;
1200
+ };
1201
+ template <typename SHAPE, auto BLOCK_SIZE, auto BLOCK_STRIDE, auto CURRENT_PRODUCT, bool STOP>
1202
+ struct ConsumeBlockStep;
1203
+ template <typename SHAPE, auto BLOCK_SIZE, auto BLOCK_STRIDE, auto CURRENT_PRODUCT>
1204
+ struct ConsumeBlockStep<SHAPE, BLOCK_SIZE, BLOCK_STRIDE, CURRENT_PRODUCT, true>{
1205
+ using REMAINDER_SHAPE = SHAPE;
1206
+ using STRIDE_SUFFIX = tensor::Stride<typename SHAPE::TI>;
1207
+ };
1208
+ template <typename SHAPE, auto BLOCK_SIZE, auto BLOCK_STRIDE, auto CURRENT_PRODUCT>
1209
+ struct ConsumeBlockStep<SHAPE, BLOCK_SIZE, BLOCK_STRIDE, CURRENT_PRODUCT, false>{
1210
+ using TI = typename SHAPE::TI;
1211
+ static constexpr TI LAST_DIM = get_last(SHAPE{});
1212
+ static constexpr TI NEW_PRODUCT = CURRENT_PRODUCT * LAST_DIM;
1213
+ static_assert(NEW_PRODUCT <= BLOCK_SIZE, "Tensor reshape: incompatible shape");
1214
+ using POP_SHAPE = typename PopBackSafe<SHAPE, tensor::Shape<TI>>::TYPE;
1215
+ using NEXT = ConsumeBlockImpl<POP_SHAPE, BLOCK_SIZE, BLOCK_STRIDE, NEW_PRODUCT>;
1216
+ using STRIDE_CURRENT = tensor::Stride<TI, BLOCK_STRIDE * CURRENT_PRODUCT>;
1217
+ using STRIDE_SUFFIX = tensor::shape_math::Concat<typename NEXT::STRIDE_SUFFIX, STRIDE_CURRENT>;
1218
+ using REMAINDER_SHAPE = typename NEXT::REMAINDER_SHAPE;
1219
+ };
1220
+ template <typename SHAPE, auto BLOCK_SIZE, auto BLOCK_STRIDE, auto CURRENT_PRODUCT>
1221
+ struct ConsumeBlockImpl<SHAPE, BLOCK_SIZE, BLOCK_STRIDE, CURRENT_PRODUCT, false>{
1222
+ using TI = typename SHAPE::TI;
1223
+ static constexpr TI LAST_DIM = get_last(SHAPE{});
1224
+ static constexpr bool STOP = (CURRENT_PRODUCT == BLOCK_SIZE) && (LAST_DIM != 1);
1225
+ using STEP = ConsumeBlockStep<SHAPE, BLOCK_SIZE, BLOCK_STRIDE, CURRENT_PRODUCT, STOP>;
1226
+ using REMAINDER_SHAPE = typename STEP::REMAINDER_SHAPE;
1227
+ using STRIDE_SUFFIX = typename STEP::STRIDE_SUFFIX;
1228
+ };
1229
+ template <typename SHAPE, auto BLOCK_SIZE, auto BLOCK_STRIDE>
1230
+ struct ConsumeBlock{
1231
+ using RESULT = ConsumeBlockImpl<SHAPE, BLOCK_SIZE, BLOCK_STRIDE, 1>;
1232
+ using REMAINDER_SHAPE = typename RESULT::REMAINDER_SHAPE;
1233
+ using STRIDE_SUFFIX = typename RESULT::STRIDE_SUFFIX;
1234
+ };
1235
+ template <typename OLD_SHAPE, typename OLD_STRIDE, typename NEW_SHAPE, bool OLD_EMPTY = IsEmpty<OLD_SHAPE>::VALUE>
1236
+ struct ReshapeStride;
1237
+ template <typename OLD_SHAPE, typename OLD_STRIDE, typename NEW_SHAPE>
1238
+ struct ReshapeStride<OLD_SHAPE, OLD_STRIDE, NEW_SHAPE, true>{
1239
+ static_assert(IsEmpty<NEW_SHAPE>::VALUE, "Tensor reshape: incompatible shape");
1240
+ using TYPE = tensor::Stride<typename OLD_SHAPE::TI>;
1241
+ };
1242
+ template <typename OLD_SHAPE, typename OLD_STRIDE, typename NEW_SHAPE>
1243
+ struct ReshapeStride<OLD_SHAPE, OLD_STRIDE, NEW_SHAPE, false>{
1244
+ using BLOCK = RightmostBlock<OLD_SHAPE, OLD_STRIDE>;
1245
+ using CONSUME = ConsumeBlock<NEW_SHAPE, BLOCK::BLOCK_SIZE, BLOCK::BLOCK_INNER_STRIDE>;
1246
+ using PREFIX = ReshapeStride<typename BLOCK::REMAINDER_SHAPE, typename BLOCK::REMAINDER_STRIDE, typename CONSUME::REMAINDER_SHAPE>;
1247
+ using TYPE = tensor::shape_math::Concat<typename PREFIX::TYPE, typename CONSUME::STRIDE_SUFFIX>;
1248
+ };
1249
+ template <typename SHAPE, typename STRIDE>
1250
+ RL_TOOLS_FUNCTION_PLACEMENT bool constexpr uniform_row_major_layout(){
1251
+ // stricter than _dense_row_major_layout_shape<..., true>: trailing size-1 dimensions can disguise a larger row pitch (e.g. shape [N, 1], stride [10, 1]), which the relaxed check accepts but RowMajorStride<NEW_SHAPE, LAST_STRIDE> cannot represent
1252
+ if(length(STRIDE{}) != length(SHAPE{})){
1253
+ return false;
1254
+ }
1255
+ constexpr auto rank = tensor::shape_math::rank<SHAPE>();
1256
+ constexpr auto shape = tensor::shape_math::element_to_array<SHAPE>();
1257
+ constexpr auto stride = tensor::shape_math::element_to_array<STRIDE>();
1258
+ for(typename tensor::shape_math::SizeType i = 0; i + 1 < rank; ++i){
1259
+ if(stride.data[i] != stride.data[i + 1] * shape.data[i + 1]){
1260
+ return false;
1261
+ }
1262
+ }
1263
+ return true;
1264
+ }
1265
+ template <typename OLD_SHAPE, typename OLD_STRIDE, typename NEW_SHAPE, bool DENSE = uniform_row_major_layout<OLD_SHAPE, OLD_STRIDE>()>
1266
+ struct ReshapeStrideShortcut;
1267
+ template <typename OLD_SHAPE, typename OLD_STRIDE, typename NEW_SHAPE>
1268
+ struct ReshapeStrideShortcut<OLD_SHAPE, OLD_STRIDE, NEW_SHAPE, true>{
1269
+ static constexpr auto LAST_STRIDE = get<length(OLD_STRIDE{}) - 1>(OLD_STRIDE{});
1270
+ using TYPE = tensor::RowMajorStride<NEW_SHAPE, LAST_STRIDE>;
1271
+ };
1272
+ template <typename OLD_SHAPE, typename OLD_STRIDE, typename NEW_SHAPE>
1273
+ struct ReshapeStrideShortcut<OLD_SHAPE, OLD_STRIDE, NEW_SHAPE, false>{
1274
+ using TYPE = typename ReshapeStride<OLD_SHAPE, OLD_STRIDE, NEW_SHAPE>::TYPE;
1275
+ };
1276
+ }
1277
+ template<typename DEVICE, typename SPEC, typename RESHAPE>
1278
+ RL_TOOLS_FUNCTION_PLACEMENT auto reshape_row_major(DEVICE& device, Tensor<SPEC>& t, const RESHAPE&){
1279
+ static_assert(tensor::generalized_row_major<typename SPEC::SHAPE, typename SPEC::STRIDE>());
1280
+ using TI = typename DEVICE::index_t;
1281
+ using T = typename SPEC::T;
1282
+ constexpr TI N_ELEMENTS = product(typename SPEC::SHAPE{});
1283
+ constexpr TI N_NEW_ELEMENTS = product(RESHAPE{});
1284
+ static_assert(N_ELEMENTS == N_NEW_ELEMENTS, "Tensor reshape: Number of elements must be the same");
1285
+ using NEW_STRIDE = typename tensor::reshape_row_major_detail::ReshapeStrideShortcut<typename SPEC::SHAPE, typename SPEC::STRIDE, RESHAPE>::TYPE;
1286
+ using NEW_SPEC = tensor::Specification<T, TI, RESHAPE, true, NEW_STRIDE>;
1287
+ return Tensor<NEW_SPEC>{data(t)};
1288
+ }
1289
+ template<typename DEVICE, typename SPEC, typename RESHAPE>
1290
+ RL_TOOLS_FUNCTION_PLACEMENT auto reshape_row_major(DEVICE& device, const Tensor<SPEC>& t, const RESHAPE&){
1291
+
1292
+ static_assert(tensor::generalized_row_major<typename SPEC::SHAPE, typename SPEC::STRIDE>());
1293
+ using TI = typename DEVICE::index_t;
1294
+ using T = typename SPEC::T;
1295
+ constexpr TI N_ELEMENTS = product(typename SPEC::SHAPE{});
1296
+ constexpr TI N_NEW_ELEMENTS = product(RESHAPE{});
1297
+ static_assert(N_ELEMENTS == N_NEW_ELEMENTS, "Tensor reshape: Number of elements must be the same");
1298
+ using NEW_STRIDE = typename tensor::reshape_row_major_detail::ReshapeStrideShortcut<typename SPEC::SHAPE, typename SPEC::STRIDE, RESHAPE>::TYPE;
1299
+ using NEW_SPEC = tensor::Specification<T, TI, RESHAPE, true, NEW_STRIDE>;
1300
+ return Tensor<NEW_SPEC>{data(t)};
1301
+ }
1302
+ template <typename DEVICE, typename MATRIX_SPEC>
1303
+ RL_TOOLS_FUNCTION_PLACEMENT auto to_tensor(DEVICE& device, Matrix<MATRIX_SPEC>& m){
1304
+ using T = typename MATRIX_SPEC::T;
1305
+ using TI = typename MATRIX_SPEC::TI;
1306
+ using SHAPE = tensor::Shape<TI, MATRIX_SPEC::ROWS, MATRIX_SPEC::COLS>;
1307
+ constexpr TI ROW_PITCH = MATRIX_SPEC::LAYOUT::template ROW_PITCH<MATRIX_SPEC::ROWS, MATRIX_SPEC::COLS>;
1308
+ constexpr TI COL_PITCH = MATRIX_SPEC::LAYOUT::template COL_PITCH<MATRIX_SPEC::ROWS, MATRIX_SPEC::COLS>;
1309
+ using STRIDE = tensor::Stride<TI, ROW_PITCH, COL_PITCH>;
1310
+ using SPEC = tensor::Specification<T, TI, SHAPE, true, STRIDE, false>;
1311
+ return Tensor<SPEC>{m._data};
1312
+ }
1313
+ template <typename DEVICE, typename MATRIX_SPEC>
1314
+ RL_TOOLS_FUNCTION_PLACEMENT auto to_tensor(DEVICE& device, const Matrix<MATRIX_SPEC>& m){
1315
+ using T = typename MATRIX_SPEC::T;
1316
+ using TI = typename MATRIX_SPEC::TI;
1317
+ using SHAPE = tensor::Shape<TI, MATRIX_SPEC::ROWS, MATRIX_SPEC::COLS>;
1318
+ constexpr TI ROW_PITCH = MATRIX_SPEC::LAYOUT::template ROW_PITCH<MATRIX_SPEC::ROWS, MATRIX_SPEC::COLS>;
1319
+ constexpr TI COL_PITCH = MATRIX_SPEC::LAYOUT::template COL_PITCH<MATRIX_SPEC::ROWS, MATRIX_SPEC::COLS>;
1320
+ using STRIDE = tensor::Stride<TI, ROW_PITCH, COL_PITCH>;
1321
+ using SPEC = tensor::Specification<T, TI, SHAPE, true, STRIDE, true>;
1322
+ return Tensor<SPEC>{m._data};
1323
+ }
1324
+ template <typename DEVICE, typename SPEC>
1325
+ RL_TOOLS_FUNCTION_PLACEMENT auto to_tensor(DEVICE& device, const Tensor<SPEC>& t){
1326
+ return t;
1327
+ }
1328
+ template <typename DEVICE, typename SPEC>
1329
+ RL_TOOLS_FUNCTION_PLACEMENT auto to_tensor(DEVICE& device, Tensor<SPEC>& t){
1330
+ return t;
1331
+ }
1332
+ template <typename DEVICE, typename SPEC>
1333
+ RL_TOOLS_FUNCTION_PLACEMENT auto squeeze(DEVICE& device, const Tensor<SPEC>& m){
1334
+ using TI = typename SPEC::TI;
1335
+ using T = typename SPEC::T;
1336
+ constexpr TI N_DIM = length(typename SPEC::SHAPE{});
1337
+ static_assert(N_DIM > 1, "Cannot squeeze a tensor with less than 2 dimensions");
1338
+ static_assert(get<0>(typename SPEC::SHAPE{}) == 1, "Cannot squeeze a tensor with a dimension size greater than 1");
1339
+ using NEW_SHAPE = tensor::PopFront<typename SPEC::SHAPE>;
1340
+ using NEW_STRIDE = tensor::PopFront<typename SPEC::STRIDE>;
1341
+ using NEW_SPEC = tensor::Specification<T, TI, NEW_SHAPE, true, NEW_STRIDE>;
1342
+ return Tensor<NEW_SPEC>{data(m)};
1343
+ }
1344
+ template <typename DEVICE, typename SPEC>
1345
+ RL_TOOLS_FUNCTION_PLACEMENT auto unsqueeze(DEVICE& device, const Tensor<SPEC>& m){
1346
+ using TI = typename SPEC::TI;
1347
+ using T = typename SPEC::T;
1348
+ using NEW_SHAPE = tensor::Insert<typename SPEC::SHAPE, 1, 0>;
1349
+ using NEW_STRIDE = tensor::Insert<typename SPEC::STRIDE, get<0>(typename SPEC::STRIDE{}) * get<0>(typename SPEC::SHAPE{}), 0>;
1350
+ using NEW_SPEC = tensor::Specification<T, TI, NEW_SHAPE, true, NEW_STRIDE>;
1351
+ return Tensor<NEW_SPEC>{data(m)};
1352
+ }
1353
+ }
1354
+ RL_TOOLS_NAMESPACE_WRAPPER_END
1355
+
1356
+ #endif