Braindecode 1.8.1.dev168512945__tar.gz → 1.8.1.dev168570878__tar.gz

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 (210) hide show
  1. {braindecode-1.8.1.dev168512945/braindecode.egg-info → braindecode-1.8.1.dev168570878}/PKG-INFO +1 -1
  2. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/functional/__init__.py +0 -2
  3. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/functional/functions.py +1 -5
  4. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/atcnet.py +14 -4
  5. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/attn_sleep.py +13 -9
  6. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegdino.py +4 -11
  7. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/popt.py +8 -2
  8. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/signal_jepa.py +8 -6
  9. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/tcformer.py +4 -11
  10. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/tmsanet.py +9 -9
  11. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/attention.py +86 -8
  12. braindecode-1.8.1.dev168570878/braindecode/version.py +1 -0
  13. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878/braindecode.egg-info}/PKG-INFO +1 -1
  14. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode.egg-info/SOURCES.txt +0 -1
  15. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/api.rst +0 -1
  16. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/whats_new.rst +0 -3
  17. braindecode-1.8.1.dev168512945/braindecode/functional/attention.py +0 -152
  18. braindecode-1.8.1.dev168512945/braindecode/version.py +0 -1
  19. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/LICENSE.txt +0 -0
  20. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/MANIFEST.in +0 -0
  21. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/NOTICE.txt +0 -0
  22. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/README.rst +0 -0
  23. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/__init__.py +0 -0
  24. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/augmentation/__init__.py +0 -0
  25. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/augmentation/base.py +0 -0
  26. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/augmentation/functional.py +0 -0
  27. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/augmentation/transforms.py +0 -0
  28. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/classifier.py +0 -0
  29. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/__init__.py +0 -0
  30. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/_notebook_viewer.py +0 -0
  31. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/base.py +0 -0
  32. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bbci.py +0 -0
  33. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bcicomp.py +0 -0
  34. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bids/__init__.py +0 -0
  35. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bids/datasets.py +0 -0
  36. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bids/hub.py +0 -0
  37. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bids/hub_format.py +0 -0
  38. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bids/hub_io.py +0 -0
  39. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bids/hub_validation.py +0 -0
  40. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/bids/iterable.py +0 -0
  41. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/chb_mit.py +0 -0
  42. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/collate.py +0 -0
  43. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/mne.py +0 -0
  44. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/moabb.py +0 -0
  45. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/nmt.py +0 -0
  46. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/registry.py +0 -0
  47. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/siena.py +0 -0
  48. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
  49. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/sleep_physionet.py +0 -0
  50. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/tuh.py +0 -0
  51. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/utils.py +0 -0
  52. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datasets/xy.py +0 -0
  53. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datautil/__init__.py +0 -0
  54. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datautil/channel_utils.py +0 -0
  55. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datautil/hub_formats.py +0 -0
  56. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datautil/serialization.py +0 -0
  57. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/datautil/util.py +0 -0
  58. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/eegneuralnet.py +0 -0
  59. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/functional/_real_dft.py +0 -0
  60. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/functional/initialization.py +0 -0
  61. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/__init__.py +0 -0
  62. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/attentionbasenet.py +0 -0
  63. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/axon.py +0 -0
  64. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/barista.py +0 -0
  65. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/base.py +0 -0
  66. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/bendr.py +0 -0
  67. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/biot.py +0 -0
  68. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/brainbert.py +0 -0
  69. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/brainmodule.py +0 -0
  70. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/brainomni.py +0 -0
  71. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/brant.py +0 -0
  72. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/cbramod.py +0 -0
  73. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/codebrain.py +0 -0
  74. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/config.py +0 -0
  75. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/contrawr.py +0 -0
  76. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/csbrain.py +0 -0
  77. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/ctnet.py +0 -0
  78. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/dance.py +0 -0
  79. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/deep4.py +0 -0
  80. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/deepsleepnet.py +0 -0
  81. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/dgcnn.py +0 -0
  82. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/diver1.py +0 -0
  83. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/duin.py +0 -0
  84. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eeg_clip.py +0 -0
  85. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegconformer.py +0 -0
  86. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eeginception_erp.py +0 -0
  87. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eeginception_mi.py +0 -0
  88. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegitnet.py +0 -0
  89. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegminer.py +0 -0
  90. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegnet.py +0 -0
  91. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegnex.py +0 -0
  92. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegpt.py +0 -0
  93. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegsimpleconv.py +0 -0
  94. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegsym.py +0 -0
  95. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/eegtcnet.py +0 -0
  96. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/emg2qwerty.py +0 -0
  97. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/epint.py +0 -0
  98. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/fbcnet.py +0 -0
  99. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/fblightconvnet.py +0 -0
  100. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/fbmsnet.py +0 -0
  101. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/gcnsnet.py +0 -0
  102. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/guetschel2026.py +0 -0
  103. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/hybrid.py +0 -0
  104. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/ifnet.py +0 -0
  105. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/labram.py +0 -0
  106. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/luna.py +0 -0
  107. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/mapa.py +0 -0
  108. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/medformer.py +0 -0
  109. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/meta_neuromotor.py +0 -0
  110. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/mirepnet.py +0 -0
  111. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/mscformer.py +0 -0
  112. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/msvtnet.py +0 -0
  113. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/mvpformer.py +0 -0
  114. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/neuropose.py +0 -0
  115. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/neurorvq.py +0 -0
  116. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/neurorvq_tokenizer.py +0 -0
  117. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/patchedtransformer.py +0 -0
  118. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/reve.py +0 -0
  119. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sccnet.py +0 -0
  120. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/seizure_transformer.py +0 -0
  121. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sensingdynamics.py +0 -0
  122. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/shallow_fbcsp.py +0 -0
  123. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sinc_shallow.py +0 -0
  124. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
  125. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
  126. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sleepfm.py +0 -0
  127. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sparcnet.py +0 -0
  128. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/sstdpn.py +0 -0
  129. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/steegformer.py +0 -0
  130. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/summary.csv +0 -0
  131. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/syncnet.py +0 -0
  132. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/tcn.py +0 -0
  133. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/tfm_tokenizer.py +0 -0
  134. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/tidnet.py +0 -0
  135. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/tsinception.py +0 -0
  136. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/usleep.py +0 -0
  137. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/util.py +0 -0
  138. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/vemg2pose.py +0 -0
  139. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/models/zuna.py +0 -0
  140. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/__init__.py +0 -0
  141. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/activation.py +0 -0
  142. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/blocks.py +0 -0
  143. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/channels.py +0 -0
  144. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/convolution.py +0 -0
  145. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/dance_modules.py +0 -0
  146. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/filter.py +0 -0
  147. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/layers.py +0 -0
  148. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/linear.py +0 -0
  149. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/linear_attention.py +0 -0
  150. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/parametrization.py +0 -0
  151. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/quantization.py +0 -0
  152. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/stats.py +0 -0
  153. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/util.py +0 -0
  154. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/modules/wrapper.py +0 -0
  155. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/preprocessing/__init__.py +0 -0
  156. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
  157. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/preprocessing/mne_preprocess.py +0 -0
  158. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/preprocessing/preprocess.py +0 -0
  159. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/preprocessing/util.py +0 -0
  160. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/preprocessing/windowers.py +0 -0
  161. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/regressor.py +0 -0
  162. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/samplers/__init__.py +0 -0
  163. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/samplers/base.py +0 -0
  164. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/samplers/ssl.py +0 -0
  165. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/training/__init__.py +0 -0
  166. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/training/callbacks.py +0 -0
  167. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/training/losses.py +0 -0
  168. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/training/scoring.py +0 -0
  169. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/util.py +0 -0
  170. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/__init__.py +0 -0
  171. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/activations.py +0 -0
  172. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/attribution.py +0 -0
  173. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/confusion_matrices.py +0 -0
  174. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/frequency.py +0 -0
  175. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/metrics.py +0 -0
  176. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/sanity.py +0 -0
  177. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode/visualization/topology.py +0 -0
  178. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode.egg-info/dependency_links.txt +0 -0
  179. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode.egg-info/requires.txt +0 -0
  180. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/braindecode.egg-info/top_level.txt +0 -0
  181. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/Makefile +0 -0
  182. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/_templates/autosummary/class.rst +0 -0
  183. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
  184. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/_templates/autosummary/function.rst +0 -0
  185. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
  186. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/agent_docs.rst +0 -0
  187. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/cite.rst +0 -0
  188. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/conf.py +0 -0
  189. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/help.rst +0 -0
  190. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/index.rst +0 -0
  191. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/install/install.rst +0 -0
  192. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/install/install_pip.rst +0 -0
  193. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/install/install_source.rst +0 -0
  194. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/attention.rst +0 -0
  195. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/channel.rst +0 -0
  196. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/convolution.rst +0 -0
  197. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/filterbank.rst +0 -0
  198. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/gnn.rst +0 -0
  199. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/interpretable.rst +0 -0
  200. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/lbm.rst +0 -0
  201. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/recurrent.rst +0 -0
  202. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/categorization/spd.rst +0 -0
  203. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/models.rst +0 -0
  204. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/models_categorization.rst +0 -0
  205. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/models_table.rst +0 -0
  206. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/models/models_visualization.rst +0 -0
  207. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/sg_execution_times.rst +0 -0
  208. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/docs/user_guide/channel_strategies.rst +0 -0
  209. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/pyproject.toml +0 -0
  210. {braindecode-1.8.1.dev168512945 → braindecode-1.8.1.dev168570878}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 1.8.1.dev168512945
3
+ Version: 1.8.1.dev168570878
4
4
  Summary: Deep learning software to decode EEG, ECG or MEG signals
5
5
  Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Alexandre Gramfort <agramfort@meta.com>
6
6
  Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
@@ -1,4 +1,3 @@
1
- from .attention import scaled_dot_product_attention
2
1
  from .functions import (
3
2
  _get_gaussian_kernel1d,
4
3
  apply_rotary,
@@ -46,7 +45,6 @@ __all__ = [
46
45
  "rotate_half",
47
46
  "rotate_pairs",
48
47
  "safe_log",
49
- "scaled_dot_product_attention",
50
48
  "sinusoidal_positional_encoding",
51
49
  "spectral_input",
52
50
  "square",
@@ -588,7 +588,6 @@ def sinusoidal_positional_encoding(
588
588
  dim: int,
589
589
  device: torch.device | None = None,
590
590
  dtype: torch.dtype = torch.float32,
591
- base: float = 10000.0,
592
591
  ) -> torch.Tensor:
593
592
  r"""Fixed sine/cosine positional-encoding table of shape ``(n_positions, dim)``.
594
593
 
@@ -610,9 +609,6 @@ def sinusoidal_positional_encoding(
610
609
  Device of the table (default: CPU), for tables built inside ``forward``.
611
610
  dtype : torch.dtype
612
611
  Floating dtype the table is computed in.
613
- base : float, default=10000.0
614
- Longest wavelength, the ``10000`` of Vaswani et al.; SignalJEPA uses the
615
- largest number of time samples it encodes.
616
612
 
617
613
  Returns
618
614
  -------
@@ -624,7 +620,7 @@ def sinusoidal_positional_encoding(
624
620
  position = torch.arange(n_positions, device=device).unsqueeze(1).to(dtype)
625
621
  div_term = torch.exp(
626
622
  torch.arange(0, dim_even, 2, device=device).to(dtype)
627
- * (-math.log(base) / dim_even)
623
+ * (-math.log(10000.0) / dim_even)
628
624
  )
629
625
  pe = torch.zeros(n_positions, dim_even, device=device, dtype=dtype)
630
626
  pe[:, 0::2] = torch.sin(position * div_term)
@@ -1,6 +1,7 @@
1
1
  # Authors: Cedric Rommel <cedric.rommel@inria.fr>
2
2
  #
3
3
  # License: BSD (3-clause)
4
+ import math
4
5
  from typing import Optional
5
6
 
6
7
  import torch
@@ -9,7 +10,6 @@ from mne.utils import warn
9
10
  from torch import nn
10
11
  from torch.nn.utils.parametrize import is_parametrized, register_parametrization
11
12
 
12
- from braindecode.functional import scaled_dot_product_attention
13
13
  from braindecode.models.base import EEGModuleMixin
14
14
  from braindecode.modules import (
15
15
  CausalConv1d,
@@ -934,10 +934,20 @@ class _MHA(nn.Module):
934
934
  K_ = torch.cat(K.split(self.head_dim, -1), 0) # (B', S, D')
935
935
  V_ = torch.cat(V.split(self.head_dim, -1), 0) # (B', S, D')
936
936
 
937
- # Multihead output (batch_size, seq_len, dim): softmax(Q K^T / sqrt(d)) V
938
- # per head, heads merged back along the feature axis.
937
+ # Attention weights of size (num_heads * batch_size, n, m):
938
+ # measures how similar each pair of Q and K is.
939
+ W = torch.softmax(
940
+ Q_.bmm(K_.transpose(-2, -1)) / math.sqrt(self.head_dim),
941
+ -1, # (B', D', S)
942
+ ) # (B', N, M)
943
+
944
+ # Multihead output (batch_size, seq_len, dim):
945
+ # weighted sum of V where a value gets more weight if its corresponding
946
+ # key has larger dot product with the query.
939
947
  H = torch.cat(
940
- scaled_dot_product_attention(Q_, K_, V_, exact=True).split(batch_size, 0),
948
+ (W.bmm(V_)).split( # (B', S, S) # (B', S, D')
949
+ batch_size, 0
950
+ ), # [(B, S, D')] * num_heads
941
951
  -1,
942
952
  ) # (B, S, D)
943
953
 
@@ -27,14 +27,15 @@
27
27
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
28
  # SOFTWARE.
29
29
 
30
+ import math
30
31
  import warnings
31
32
  from copy import deepcopy
32
33
  from numbers import Integral
33
34
 
34
35
  import torch
36
+ import torch.nn.functional as F
35
37
  from torch import nn
36
38
 
37
- from braindecode.functional import scaled_dot_product_attention
38
39
  from braindecode.models.base import EEGModuleMixin
39
40
  from braindecode.modules import CausalConv1d
40
41
 
@@ -410,6 +411,14 @@ class _MRCNN(nn.Module):
410
411
  ##########################################################################################
411
412
 
412
413
 
414
+ def _attention(query: torch.Tensor, key: torch.Tensor) -> torch.Tensor:
415
+ """Scaled dot product attention weights."""
416
+ # d_k - dimension of the query and key vectors
417
+ d_k = query.size(-1)
418
+ scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(d_k)
419
+ return F.softmax(scores, dim=-1) # attention weights
420
+
421
+
413
422
  class _MultiHeadedAttention(nn.Module):
414
423
  def __init__(self, h, d_model, after_reduced_cnn_size, dropout=0.1):
415
424
  """Take in model size and number of heads."""
@@ -455,14 +464,9 @@ class _MultiHeadedAttention(nn.Module):
455
464
  .transpose(1, 2)
456
465
  )
457
466
 
458
- # exact: the reference op order, same outputs as its hand-written attention
459
- x = scaled_dot_product_attention(
460
- query,
461
- key,
462
- value,
463
- dropout_p=self.dropout.p if self.training else 0.0,
464
- exact=True,
465
- )
467
+ # apply dropout to the *weights*, then the weighted sum
468
+ attn = self.dropout(_attention(query, key))
469
+ x = torch.matmul(attn, value)
466
470
 
467
471
  # merge heads and project
468
472
  x = x.transpose(1, 2).contiguous().view(nbatches, -1, self.h * self.d_per_head)
@@ -10,7 +10,7 @@ from typing import Dict, Optional, Sequence, Union
10
10
  import torch
11
11
  from torch import nn
12
12
 
13
- from braindecode.functional import scaled_dot_product_attention, spectral_input
13
+ from braindecode.functional import spectral_input
14
14
  from braindecode.models.base import EEGModuleMixin
15
15
  from braindecode.models.util import warn_if_sfreq_differs
16
16
  from braindecode.modules import DropPath, PatchTokenizer
@@ -500,16 +500,9 @@ class _Attention(nn.Module):
500
500
  .permute(2, 0, 3, 1, 4)
501
501
  .unbind(0)
502
502
  )
503
- # exact with q pre-scaled: the reference op order (q * scale) @ k^T
504
- out = scaled_dot_product_attention(
505
- query * self.scale,
506
- key,
507
- value,
508
- dropout_p=self.attn_drop.p if self.training else 0.0,
509
- scale=1.0,
510
- exact=True,
511
- )
512
- out = out.transpose(1, 2).flatten(2)
503
+ attn = (query * self.scale @ key.transpose(-2, -1)).softmax(dim=-1)
504
+ attn = self.attn_drop(attn)
505
+ out = (attn @ value).transpose(1, 2).flatten(2)
513
506
  return self.proj_drop(self.proj(out))
514
507
 
515
508
 
@@ -12,6 +12,7 @@
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
+ import math
15
16
  import warnings
16
17
  from collections import OrderedDict
17
18
 
@@ -19,7 +20,6 @@ import numpy as np
19
20
  import torch
20
21
  import torch.nn as nn
21
22
 
22
- from braindecode.functional import sinusoidal_positional_encoding
23
23
  from braindecode.models.base import EEGModuleMixin
24
24
  from braindecode.models.util import extract_channel_locations_from_chs_info
25
25
 
@@ -355,7 +355,13 @@ class _PopTSpatialPositionalEncoding(nn.Module):
355
355
  "axis and the sequence id)."
356
356
  )
357
357
  pe_dim = hidden_dim // 4
358
- pe = sinusoidal_positional_encoding(max_len, pe_dim)
358
+ pe = torch.zeros(max_len, pe_dim)
359
+ position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
360
+ div_term = torch.exp(
361
+ torch.arange(0, pe_dim, 2).float() * (-math.log(10000.0) / pe_dim)
362
+ )
363
+ pe[:, 0::2] = torch.sin(position * div_term)
364
+ pe[:, 1::2] = torch.cos(position * div_term)
359
365
  self.register_buffer("pe", pe.unsqueeze(0), persistent=False)
360
366
 
361
367
  def forward(
@@ -13,7 +13,7 @@ import torch
13
13
  from einops.layers.torch import Rearrange
14
14
  from torch import nn
15
15
 
16
- from braindecode.functional import init_weights_, sinusoidal_positional_encoding
16
+ from braindecode.functional import init_weights_
17
17
  from braindecode.models.base import EEGModuleMixin
18
18
  from braindecode.modules.attention import (
19
19
  _hpu_lazy,
@@ -1682,9 +1682,6 @@ def _pos_encode_time(
1682
1682
  ):
1683
1683
  """1-dimensional positional encoding.
1684
1684
 
1685
- :func:`~braindecode.functional.sinusoidal_positional_encoding` with the
1686
- largest number of time samples as the longest wavelength.
1687
-
1688
1685
  Parameters
1689
1686
  ----------
1690
1687
  n_times: int
@@ -1701,9 +1698,14 @@ def _pos_encode_time(
1701
1698
  pos_encoding: (n_times, n_dim)
1702
1699
  """
1703
1700
  assert n_dim % 2 == 0
1704
- return sinusoidal_positional_encoding(
1705
- n_times, n_dim, device=device, base=float(max_n_times)
1701
+ position = torch.arange(n_times, device=device).unsqueeze(1)
1702
+ div_term = torch.exp(
1703
+ torch.arange(0, n_dim, 2, device=device) * (-math.log(max_n_times) / n_dim)
1706
1704
  )
1705
+ pos_encoding = torch.empty((n_times, n_dim), dtype=torch.float32, device=device)
1706
+ pos_encoding[:, 0::2] = torch.sin(position * div_term)
1707
+ pos_encoding[:, 1::2] = torch.cos(position * div_term)
1708
+ return pos_encoding
1707
1709
 
1708
1710
 
1709
1711
  def _pos_encode_contineous(
@@ -16,7 +16,6 @@ from braindecode.functional import (
16
16
  init_weights_,
17
17
  rotary_angles,
18
18
  rotary_frequencies,
19
- scaled_dot_product_attention,
20
19
  )
21
20
  from braindecode.models.base import EEGModuleMixin
22
21
  from braindecode.modules import CausalConv1d, Conv1dWithConstraint, DropPath
@@ -368,16 +367,10 @@ class _GroupedQueryAttention(nn.Module):
368
367
  value = value.repeat_interleave(groups_per_kv, dim=1)
369
368
  query = apply_rotary(query, cos[:seq_len], sin[:seq_len])
370
369
  key = apply_rotary(key, cos[:seq_len], sin[:seq_len])
371
- # exact: the reference op order (q @ k^T) * scale
372
- context = scaled_dot_product_attention(
373
- query,
374
- key,
375
- value,
376
- dropout_p=self.drop.p if self.training else 0.0,
377
- scale=self.scale,
378
- exact=True,
379
- )
380
- context = context.transpose(1, 2).flatten(2)
370
+ key_t = key.transpose(-2, -1)
371
+ attention = ((query @ key_t) * self.scale).softmax(dim=-1)
372
+ attention = self.drop(attention)
373
+ context = (attention @ value).transpose(1, 2).flatten(2)
381
374
  return self.out_proj(context)
382
375
 
383
376
 
@@ -8,11 +8,13 @@
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
+ import math
12
+
11
13
  import torch
12
14
  from einops.layers.torch import Rearrange
13
15
  from torch import Tensor, nn
16
+ from torch.nn import functional as F
14
17
 
15
- from braindecode.functional import scaled_dot_product_attention
16
18
  from braindecode.models.base import EEGModuleMixin
17
19
  from braindecode.modules import FeedForwardBlock
18
20
 
@@ -203,14 +205,12 @@ class _TMSAAttention(nn.Module):
203
205
  k_local = self.split_heads(self.w_k_local(local))
204
206
  k_global = self.split_heads(self.w_k_global(x))
205
207
  v = self.split_heads(self.w_v(x))
206
- # exact: the reference op order and its dropout RNG order
207
- dropout_p = self.att_drop.p if self.training else 0.0
208
- x_local = scaled_dot_product_attention(
209
- q, k_local, v, dropout_p=dropout_p, exact=True
210
- )
211
- x_global = scaled_dot_product_attention(
212
- q, k_global, v, dropout_p=dropout_p, exact=True
213
- )
208
+ # Explicit softmax attention keeps the reference's dropout RNG order.
209
+ scale = math.sqrt(self.head_dim)
210
+ attn_local = F.softmax(q @ k_local.transpose(-2, -1) / scale, dim=-1)
211
+ x_local = self.att_drop(attn_local) @ v
212
+ attn_global = F.softmax(q @ k_global.transpose(-2, -1) / scale, dim=-1)
213
+ x_global = self.att_drop(attn_global) @ v
214
214
  return self.w_o(self.merge_heads(x_local + x_global))
215
215
 
216
216
 
@@ -16,19 +16,12 @@ import math
16
16
  from typing import Optional
17
17
 
18
18
  import torch
19
+ import torch.nn.functional as F
19
20
  from einops import rearrange
20
21
  from einops.layers.torch import Rearrange
21
22
  from torch import Tensor, nn
22
23
 
23
24
  from braindecode.functional import _get_gaussian_kernel1d
24
- from braindecode.functional.attention import ( # noqa: F401 (re-exported)
25
- _hpu_eager_fused_sdpa,
26
- _hpu_lazy,
27
- _sdpa_math_dropout,
28
- )
29
- from braindecode.functional.attention import (
30
- scaled_dot_product_attention as _scaled_dot_product_attention,
31
- )
32
25
 
33
26
 
34
27
  class SqueezeAndExcitation(nn.Module):
@@ -841,6 +834,91 @@ class CATLite(nn.Module):
841
834
  return channel_score * x
842
835
 
843
836
 
837
+ @torch.jit.unused
838
+ def _hpu_eager_fused_sdpa(
839
+ query: Tensor,
840
+ key: Tensor,
841
+ value: Tensor,
842
+ scale: Optional[float] = None,
843
+ fused_in_lazy: bool = False,
844
+ ) -> Optional[Tensor]:
845
+ # Lazy mode: None, the graph compiler already fuses torch's SDPA there
846
+ # (unless the caller measured the fused kernel faster for its shapes).
847
+ from habana_frameworks.torch.utils.internal import is_lazy
848
+
849
+ if is_lazy() and not fused_in_lazy:
850
+ return None
851
+ from habana_frameworks.torch.hpex.kernels import FusedSDPA
852
+
853
+ # Strided q/k/v views (heads split off a projection) give wrong outputs and
854
+ # gradients at some shapes; contiguous copies give the right result.
855
+ query, key, value = query.contiguous(), key.contiguous(), value.contiguous()
856
+ return FusedSDPA.apply(query, key, value, None, 0.0, False, scale, "None", False)
857
+
858
+
859
+ @torch.jit.unused
860
+ def _hpu_lazy() -> bool:
861
+ from habana_frameworks.torch.utils.internal import is_lazy
862
+
863
+ return is_lazy()
864
+
865
+
866
+ def _sdpa_math_dropout(
867
+ query: Tensor, key: Tensor, value: Tensor, dropout_p: float
868
+ ) -> Tensor:
869
+ # torch's math path for SDPA with dropout, op for op, without the pass of
870
+ # ``_safe_softmax`` that zeroes fully masked rows (none without a mask):
871
+ # same values, same dropout draws.
872
+ scale = math.sqrt(1.0 / math.sqrt(query.size(-1)))
873
+ attn = torch.matmul(query * scale, key.transpose(-2, -1) * scale)
874
+ attn = F.dropout(attn.softmax(-1), dropout_p, True)
875
+ return torch.matmul(attn, value)
876
+
877
+
878
+ def _scaled_dot_product_attention(
879
+ query: Tensor,
880
+ key: Tensor,
881
+ value: Tensor,
882
+ attn_mask: Optional[Tensor] = None,
883
+ dropout_p: float = 0.0,
884
+ fused_in_lazy: bool = False,
885
+ ) -> Tensor:
886
+ """``F.scaled_dot_product_attention``; Gaudi's fused kernel on HPU.
887
+
888
+ In HPU eager mode, torch's SDPA runs op by op (the full
889
+ ``(batch, heads, seq, seq)`` scores in device memory), 2-3.5x slower than
890
+ the bridge's fused kernel on long sequences. The fused kernel is used
891
+ without a mask or dropout (its dropout would draw other masks). In lazy
892
+ mode only with ``fused_in_lazy=True``: the graph compiler fuses torch's
893
+ SDPA too, faster on long sequences, slower on short ones.
894
+ """
895
+ if (
896
+ not torch.jit.is_scripting()
897
+ and query.device.type == "hpu"
898
+ and attn_mask is None
899
+ and dropout_p == 0.0
900
+ and (query.dtype == torch.float32 or query.dtype == torch.bfloat16)
901
+ ):
902
+ out = _hpu_eager_fused_sdpa(query, key, value, fused_in_lazy=fused_in_lazy)
903
+ if out is not None:
904
+ return out
905
+ if (
906
+ not torch.jit.is_scripting()
907
+ and dropout_p > 0.0
908
+ and attn_mask is None
909
+ and (query.dtype == torch.float32 or query.dtype == torch.float64)
910
+ and (
911
+ query.device.type == "cpu"
912
+ or (query.device.type == "hpu" and not _hpu_lazy())
913
+ )
914
+ ):
915
+ # CPU and HPU eager run SDPA with dropout through the math path.
916
+ return _sdpa_math_dropout(query, key, value, dropout_p)
917
+ return F.scaled_dot_product_attention(
918
+ query, key, value, attn_mask=attn_mask, dropout_p=dropout_p
919
+ )
920
+
921
+
844
922
  class MultiHeadAttention(nn.Module):
845
923
  """Multi-head self-attention block.
846
924
 
@@ -0,0 +1 @@
1
+ __version__ = "1.8.1.dev168570878"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 1.8.1.dev168512945
3
+ Version: 1.8.1.dev168570878
4
4
  Summary: Deep learning software to decode EEG, ECG or MEG signals
5
5
  Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Alexandre Gramfort <agramfort@meta.com>
6
6
  Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
@@ -50,7 +50,6 @@ braindecode/datautil/serialization.py
50
50
  braindecode/datautil/util.py
51
51
  braindecode/functional/__init__.py
52
52
  braindecode/functional/_real_dft.py
53
- braindecode/functional/attention.py
54
53
  braindecode/functional/functions.py
55
54
  braindecode/functional/initialization.py
56
55
  braindecode/models/__init__.py
@@ -485,7 +485,6 @@ The functional module contains various functions that can be used like functiona
485
485
  rotate_half
486
486
  rotate_pairs
487
487
  safe_log
488
- scaled_dot_product_attention
489
488
  sinusoidal_positional_encoding
490
489
  spectral_input
491
490
  square
@@ -28,9 +28,6 @@ Current 1.8.1 (2026-08-31)
28
28
  Enhancements
29
29
  ============
30
30
 
31
- - CI: ``test_core_dependencies_are_imported`` parsed the whole package once per installed distribution (215 s, the last test to finish); it parses once. The test job stops after 60 minutes instead of 6 hours when a worker hangs (:gh:`1471` by `Bruno Aristimunha`_).
32
- - :func:`braindecode.functional.sinusoidal_positional_encoding` takes a ``base`` (longest wavelength); PopulationTransformer and SignalJEPA build their tables with it, unchanged (:gh:`1458` by `Bruno Aristimunha`_).
33
- - Add :func:`braindecode.functional.scaled_dot_product_attention` (the shared SDPA helper, now public, with ``scale`` and an ``exact`` op-order mode); ATCNet, AttnSleep, EEGDINO, TCFormer and TMSA-Net compute their attention through it with outputs, losses and gradients unchanged bit for bit (:gh:`1457` by `Bruno Aristimunha`_).
34
31
  - Add :func:`braindecode.functional.rotary_frequencies`, :func:`~braindecode.functional.rotary_angles`, :func:`~braindecode.functional.apply_rotary` and :func:`~braindecode.functional.rotate_half`; BaRISTA, BrainOmni, DIVER-1, EpiNT, LUNA and TCFormer build and apply their rotary embeddings with them (parameters and outputs unchanged), and EEGPT loses a rotary code path it never used (:gh:`1456` by `Bruno Aristimunha`_).
35
32
  - Add a test that lists every private copy of a standard block (attention, transformer block, MLP, positional encoding, norm, patch embedding, residual) in :mod:`braindecode.models`, so a new copy fails CI unless it is listed with a reason; the new-model checklist asks for the shared blocks (:gh:`1455` by `Bruno Aristimunha`_).
36
33
  - Add a test that lists every private copy of a standard block (attention, transformer block, MLP, positional encoding, norm, patch embedding, residual) in :mod:`braindecode.models`, so a new copy fails CI unless it is listed with a reason; the new-model checklist asks for the shared blocks (:gh:`1455` by `Bruno Aristimunha`_).
@@ -1,152 +0,0 @@
1
- """Scaled dot-product attention with the device-specific paths in one place."""
2
-
3
- # Authors: Bruno Aristimunha <b.aristimunha@gmail.com>
4
- #
5
- # License: BSD (3-clause)
6
-
7
- import math
8
- from typing import Optional
9
-
10
- import torch
11
- import torch.nn.functional as F
12
- from torch import Tensor
13
-
14
-
15
- @torch.jit.unused
16
- def _hpu_eager_fused_sdpa(
17
- query: Tensor,
18
- key: Tensor,
19
- value: Tensor,
20
- scale: Optional[float] = None,
21
- fused_in_lazy: bool = False,
22
- ) -> Optional[Tensor]:
23
- # Lazy mode: None, the graph compiler already fuses torch's SDPA there
24
- # (unless the caller measured the fused kernel faster for its shapes).
25
- from habana_frameworks.torch.utils.internal import is_lazy
26
-
27
- if is_lazy() and not fused_in_lazy:
28
- return None
29
- from habana_frameworks.torch.hpex.kernels import FusedSDPA
30
-
31
- # Strided q/k/v views (heads split off a projection) give wrong outputs and
32
- # gradients at some shapes; contiguous copies give the right result.
33
- query, key, value = query.contiguous(), key.contiguous(), value.contiguous()
34
- return FusedSDPA.apply(query, key, value, None, 0.0, False, scale, "None", False)
35
-
36
-
37
- @torch.jit.unused
38
- def _hpu_lazy() -> bool:
39
- from habana_frameworks.torch.utils.internal import is_lazy
40
-
41
- return is_lazy()
42
-
43
-
44
- def _sdpa_math_dropout(
45
- query: Tensor,
46
- key: Tensor,
47
- value: Tensor,
48
- dropout_p: float,
49
- scale: Optional[float] = None,
50
- ) -> Tensor:
51
- # torch's math path for SDPA with dropout, op for op, without the pass of
52
- # ``_safe_softmax`` that zeroes fully masked rows (none without a mask):
53
- # same values, same dropout draws.
54
- if scale is None:
55
- scale = 1.0 / math.sqrt(query.size(-1))
56
- half = math.sqrt(scale)
57
- attn = torch.matmul(query * half, key.transpose(-2, -1) * half)
58
- attn = F.dropout(attn.softmax(-1), dropout_p, True)
59
- return torch.matmul(attn, value)
60
-
61
-
62
- def scaled_dot_product_attention(
63
- query: Tensor,
64
- key: Tensor,
65
- value: Tensor,
66
- attn_mask: Optional[Tensor] = None,
67
- dropout_p: float = 0.0,
68
- scale: Optional[float] = None,
69
- fused_in_lazy: bool = False,
70
- exact: bool = False,
71
- ) -> Tensor:
72
- """``F.scaled_dot_product_attention``; Gaudi's fused kernel on HPU.
73
-
74
- Parameters
75
- ----------
76
- query, key, value : torch.Tensor
77
- Shape ``(..., seq, head_dim)``; ``key``/``value`` may have another
78
- sequence length.
79
- attn_mask : torch.Tensor, optional
80
- Boolean (``True`` takes part) or additive mask, as in torch.
81
- dropout_p : float, default=0.0
82
- Dropout on the attention weights; pass ``0.0`` in eval mode.
83
- scale : float, optional
84
- Score scale; ``None`` is ``1 / sqrt(head_dim)``.
85
- fused_in_lazy : bool, default=False
86
- Use Gaudi's fused kernel in HPU lazy mode too.
87
- exact : bool, default=False
88
- Run the textbook op order instead of torch's kernels:
89
- ``softmax((q @ k^T) / sqrt(d)) @ v``, or ``softmax((q @ k^T) * scale) @ v``
90
- when ``scale`` is given, with dropout on the weights. Bit-identical to
91
- a hand-written attention; torch's kernels round differently (its math
92
- path scales ``q`` and ``k`` by ``sqrt(scale)`` each before the matmul,
93
- its fused CPU kernel runs a blocked softmax), about 1e-6 apart.
94
-
95
- Returns
96
- -------
97
- torch.Tensor
98
- Shape ``(..., seq, head_dim)``.
99
-
100
- In HPU eager mode, torch's SDPA runs op by op (the full
101
- ``(batch, heads, seq, seq)`` scores in device memory), 2-3.5x slower than
102
- the bridge's fused kernel on long sequences. The fused kernel is used
103
- without a mask or dropout (its dropout would draw other masks). In lazy
104
- mode only with ``fused_in_lazy=True``: the graph compiler fuses torch's
105
- SDPA too, faster on long sequences, slower on short ones.
106
- """
107
- if exact:
108
- scores = torch.matmul(query, key.transpose(-2, -1))
109
- if scale is None:
110
- scores = scores / math.sqrt(query.size(-1))
111
- else:
112
- scores = scores * scale
113
- if attn_mask is not None:
114
- if attn_mask.dtype == torch.bool:
115
- scores = scores.masked_fill(~attn_mask, float("-inf"))
116
- else:
117
- scores = scores + attn_mask
118
- weights = scores.softmax(dim=-1)
119
- if dropout_p > 0.0:
120
- weights = F.dropout(weights, dropout_p, True)
121
- return torch.matmul(weights, value)
122
- if (
123
- not torch.jit.is_scripting()
124
- and query.device.type == "hpu"
125
- and attn_mask is None
126
- and dropout_p == 0.0
127
- and (query.dtype == torch.float32 or query.dtype == torch.bfloat16)
128
- ):
129
- out = _hpu_eager_fused_sdpa(
130
- query, key, value, scale=scale, fused_in_lazy=fused_in_lazy
131
- )
132
- if out is not None:
133
- return out
134
- if (
135
- not torch.jit.is_scripting()
136
- and dropout_p > 0.0
137
- and attn_mask is None
138
- and (query.dtype == torch.float32 or query.dtype == torch.float64)
139
- and (
140
- query.device.type == "cpu"
141
- or (query.device.type == "hpu" and not _hpu_lazy())
142
- )
143
- ):
144
- # CPU and HPU eager run SDPA with dropout through the math path.
145
- return _sdpa_math_dropout(query, key, value, dropout_p, scale)
146
- if scale is None: # torch 2.0's signature has no ``scale``
147
- return F.scaled_dot_product_attention(
148
- query, key, value, attn_mask=attn_mask, dropout_p=dropout_p
149
- )
150
- return F.scaled_dot_product_attention(
151
- query, key, value, attn_mask=attn_mask, dropout_p=dropout_p, scale=scale
152
- )
@@ -1 +0,0 @@
1
- __version__ = "1.8.1.dev168512945"