braindecode 1.8.1.dev172377786__tar.gz → 1.8.1.dev172419947__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 (208) hide show
  1. {braindecode-1.8.1.dev172377786/braindecode.egg-info → braindecode-1.8.1.dev172419947}/PKG-INFO +1 -1
  2. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/functional/_real_dft.py +55 -0
  3. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/functional/functions.py +13 -5
  4. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/barista.py +2 -2
  5. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eeginception_mi.py +7 -3
  6. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegnex.py +1 -1
  7. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegpt.py +3 -1
  8. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/labram.py +19 -9
  9. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/luna.py +3 -1
  10. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/patchedtransformer.py +3 -7
  11. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/reve.py +15 -4
  12. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/attention.py +2 -2
  13. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/dance_modules.py +16 -3
  14. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/layers.py +41 -2
  15. braindecode-1.8.1.dev172419947/braindecode/version.py +1 -0
  16. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947/braindecode.egg-info}/PKG-INFO +1 -1
  17. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/whats_new.rst +12 -0
  18. braindecode-1.8.1.dev172377786/braindecode/version.py +0 -1
  19. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/LICENSE.txt +0 -0
  20. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/MANIFEST.in +0 -0
  21. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/NOTICE.txt +0 -0
  22. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/README.rst +0 -0
  23. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/__init__.py +0 -0
  24. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/augmentation/__init__.py +0 -0
  25. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/augmentation/base.py +0 -0
  26. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/augmentation/functional.py +0 -0
  27. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/augmentation/transforms.py +0 -0
  28. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/classifier.py +0 -0
  29. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/__init__.py +0 -0
  30. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/_notebook_viewer.py +0 -0
  31. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/base.py +0 -0
  32. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bbci.py +0 -0
  33. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bcicomp.py +0 -0
  34. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/__init__.py +0 -0
  35. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/datasets.py +0 -0
  36. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/format.py +0 -0
  37. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/hub.py +0 -0
  38. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/hub_format.py +0 -0
  39. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/hub_io.py +0 -0
  40. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/hub_validation.py +0 -0
  41. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/bids/iterable.py +0 -0
  42. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/chb_mit.py +0 -0
  43. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/collate.py +0 -0
  44. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/mne.py +0 -0
  45. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/moabb.py +0 -0
  46. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/nmt.py +0 -0
  47. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/registry.py +0 -0
  48. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/siena.py +0 -0
  49. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
  50. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/sleep_physionet.py +0 -0
  51. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/tuh.py +0 -0
  52. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/utils.py +0 -0
  53. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datasets/xy.py +0 -0
  54. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datautil/__init__.py +0 -0
  55. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datautil/channel_utils.py +0 -0
  56. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datautil/hub_formats.py +0 -0
  57. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datautil/serialization.py +0 -0
  58. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/datautil/util.py +0 -0
  59. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/eegneuralnet.py +0 -0
  60. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/functional/__init__.py +0 -0
  61. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/functional/initialization.py +0 -0
  62. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/__init__.py +0 -0
  63. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/atcnet.py +0 -0
  64. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/attentionbasenet.py +0 -0
  65. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/attn_sleep.py +0 -0
  66. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/axon.py +0 -0
  67. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/base.py +0 -0
  68. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/bendr.py +0 -0
  69. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/biot.py +0 -0
  70. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/brainbert.py +0 -0
  71. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/brainmodule.py +0 -0
  72. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/brainomni.py +0 -0
  73. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/brant.py +0 -0
  74. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/cbramod.py +0 -0
  75. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/codebrain.py +0 -0
  76. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/config.py +0 -0
  77. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/contrawr.py +0 -0
  78. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/csbrain.py +0 -0
  79. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/ctnet.py +0 -0
  80. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/dance.py +0 -0
  81. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/deep4.py +0 -0
  82. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/deepsleepnet.py +0 -0
  83. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/dgcnn.py +0 -0
  84. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/diver1.py +0 -0
  85. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eeg_clip.py +0 -0
  86. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegconformer.py +0 -0
  87. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegdino.py +0 -0
  88. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eeginception_erp.py +0 -0
  89. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegitnet.py +0 -0
  90. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegminer.py +0 -0
  91. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegnet.py +0 -0
  92. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegsimpleconv.py +0 -0
  93. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegsym.py +0 -0
  94. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/eegtcnet.py +0 -0
  95. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/emg2qwerty.py +0 -0
  96. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/fbcnet.py +0 -0
  97. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/fblightconvnet.py +0 -0
  98. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/fbmsnet.py +0 -0
  99. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/guetschel2026.py +0 -0
  100. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/hybrid.py +0 -0
  101. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/ifnet.py +0 -0
  102. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/mapa.py +0 -0
  103. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/medformer.py +0 -0
  104. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/meta_neuromotor.py +0 -0
  105. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/mirepnet.py +0 -0
  106. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/mscformer.py +0 -0
  107. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/msvtnet.py +0 -0
  108. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/mvpformer.py +0 -0
  109. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/neuropose.py +0 -0
  110. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/neurorvq.py +0 -0
  111. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/neurorvq_tokenizer.py +0 -0
  112. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/popt.py +0 -0
  113. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sccnet.py +0 -0
  114. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/seizure_transformer.py +0 -0
  115. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sensingdynamics.py +0 -0
  116. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/shallow_fbcsp.py +0 -0
  117. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/signal_jepa.py +0 -0
  118. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sinc_shallow.py +0 -0
  119. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
  120. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
  121. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sleepfm.py +0 -0
  122. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sparcnet.py +0 -0
  123. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/sstdpn.py +0 -0
  124. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/steegformer.py +0 -0
  125. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/summary.csv +0 -0
  126. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/syncnet.py +0 -0
  127. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/tcformer.py +0 -0
  128. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/tcn.py +0 -0
  129. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/tfm_tokenizer.py +0 -0
  130. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/tidnet.py +0 -0
  131. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/tmsanet.py +0 -0
  132. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/tsinception.py +0 -0
  133. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/usleep.py +0 -0
  134. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/util.py +0 -0
  135. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/vemg2pose.py +0 -0
  136. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/models/zuna.py +0 -0
  137. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/__init__.py +0 -0
  138. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/activation.py +0 -0
  139. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/blocks.py +0 -0
  140. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/channels.py +0 -0
  141. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/convolution.py +0 -0
  142. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/filter.py +0 -0
  143. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/linear.py +0 -0
  144. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/linear_attention.py +0 -0
  145. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/parametrization.py +0 -0
  146. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/popt_modules.py +0 -0
  147. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/quantization.py +0 -0
  148. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/stats.py +0 -0
  149. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/util.py +0 -0
  150. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/modules/wrapper.py +0 -0
  151. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/preprocessing/__init__.py +0 -0
  152. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
  153. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/preprocessing/mne_preprocess.py +0 -0
  154. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/preprocessing/preprocess.py +0 -0
  155. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/preprocessing/util.py +0 -0
  156. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/preprocessing/windowers.py +0 -0
  157. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/regressor.py +0 -0
  158. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/samplers/__init__.py +0 -0
  159. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/samplers/base.py +0 -0
  160. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/samplers/ssl.py +0 -0
  161. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/training/__init__.py +0 -0
  162. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/training/callbacks.py +0 -0
  163. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/training/losses.py +0 -0
  164. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/training/scoring.py +0 -0
  165. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/util.py +0 -0
  166. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/__init__.py +0 -0
  167. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/activations.py +0 -0
  168. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/attribution.py +0 -0
  169. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/confusion_matrices.py +0 -0
  170. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/frequency.py +0 -0
  171. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/metrics.py +0 -0
  172. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/sanity.py +0 -0
  173. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode/visualization/topology.py +0 -0
  174. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode.egg-info/SOURCES.txt +0 -0
  175. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode.egg-info/dependency_links.txt +0 -0
  176. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode.egg-info/requires.txt +0 -0
  177. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/braindecode.egg-info/top_level.txt +0 -0
  178. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/Makefile +0 -0
  179. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/_templates/autosummary/class.rst +0 -0
  180. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
  181. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/_templates/autosummary/function.rst +0 -0
  182. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
  183. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/agent_docs.rst +0 -0
  184. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/api.rst +0 -0
  185. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/cite.rst +0 -0
  186. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/conf.py +0 -0
  187. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/help.rst +0 -0
  188. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/index.rst +0 -0
  189. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/install/install.rst +0 -0
  190. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/install/install_pip.rst +0 -0
  191. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/install/install_source.rst +0 -0
  192. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/attention.rst +0 -0
  193. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/channel.rst +0 -0
  194. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/convolution.rst +0 -0
  195. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/filterbank.rst +0 -0
  196. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/gnn.rst +0 -0
  197. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/interpretable.rst +0 -0
  198. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/lbm.rst +0 -0
  199. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/recurrent.rst +0 -0
  200. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/categorization/spd.rst +0 -0
  201. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/models.rst +0 -0
  202. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/models_categorization.rst +0 -0
  203. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/models_table.rst +0 -0
  204. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/models/models_visualization.rst +0 -0
  205. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/sg_execution_times.rst +0 -0
  206. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/docs/user_guide/channel_strategies.rst +0 -0
  207. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/pyproject.toml +0 -0
  208. {braindecode-1.8.1.dev172377786 → braindecode-1.8.1.dev172419947}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 1.8.1.dev172377786
3
+ Version: 1.8.1.dev172419947
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>
@@ -12,8 +12,10 @@ never downcast, so callers wrap the numerically sensitive parts with
12
12
  #
13
13
  # License: BSD (3-clause)
14
14
  import functools
15
+ from typing import Optional
15
16
 
16
17
  import torch
18
+ from torch import nn
17
19
 
18
20
 
19
21
  def needs_real_dft(x: torch.Tensor) -> bool:
@@ -136,3 +138,56 @@ def hilbert_freq_real(x: torch.Tensor, forward_fourier: bool) -> torch.Tensor:
136
138
  return torch.stack((out_real, out_imag), dim=-1)
137
139
 
138
140
  return compute(x)
141
+
142
+
143
+ @torch.jit.unused
144
+ def fft_conv1d_real(
145
+ x: torch.Tensor, weight: torch.Tensor, bias: Optional[torch.Tensor]
146
+ ) -> torch.Tensor:
147
+ """Real-valued equivalent of :func:`braindecode.functional.fft_conv1d`.
148
+
149
+ Overlap-save: the input is cut into blocks of ``n`` samples (the power of
150
+ two ``>= 2 * kernel_size``) that advance by ``n - kernel_size + 1`` outputs,
151
+ each block's DFT is a matmul against the cosine/sine basis, and per
152
+ frequency the complex product with the kernels, summed over the input
153
+ channels, is one real matmul.
154
+ """
155
+
156
+ @fp32_island
157
+ def compute(x, weight):
158
+ n_times, kernel_size = x.shape[-1], weight.shape[-1]
159
+ n = 1 << (2 * kernel_size - 1).bit_length()
160
+ hop = n - kernel_size + 1
161
+ n_blocks = -(-n_times // hop)
162
+ n_freqs = n // 2 + 1
163
+ # "same" alignment: torch pads the extra zero of an even kernel on the right
164
+ left = (kernel_size - 1) // 2
165
+ x = nn.functional.pad(x, (left, (n_blocks + 1) * hop - n_times - left))
166
+ hops = x.unflatten(-1, (n_blocks + 1, hop))
167
+ # block i = hop i + the first kernel_size - 1 samples of hop i + 1
168
+ blocks = torch.cat([hops[:, :, :-1], hops[:, :, 1:, : kernel_size - 1]], -1)
169
+ cosine, sine = real_dft_basis(n, device=x.device, dtype=x.dtype)
170
+ basis = torch.cat([cosine, -sine]).transpose(0, 1) # -> [Re | Im] of rfft
171
+ x_f = blocks @ basis # (batch, in, blocks, 2 * n_freqs)
172
+ w_f = nn.functional.pad(weight.to(x), (0, n - kernel_size)) @ basis
173
+ w_re, w_im = w_f[..., :n_freqs], w_f[..., n_freqs:]
174
+ # conv1d is a cross-correlation: x_f * conj(w_f), summed over the input
175
+ # channels. Per frequency [Re x, Im x] @ [[Re w, -Im w], [Im w, Re w]].
176
+ w_f = torch.cat([torch.cat([w_re, -w_im]), torch.cat([w_im, w_re])], 1)
177
+ x_f = x_f.unflatten(-1, (2, n_freqs)).permute(4, 0, 2, 3, 1).flatten(1, 2)
178
+ y_f = torch.bmm(x_f.flatten(2), w_f.permute(2, 1, 0)) # (freq, ., 2 * out)
179
+ y_f = y_f.unflatten(1, (x.shape[0], n_blocks)).unflatten(-1, (2, -1))
180
+ y_f = y_f.permute(1, 4, 2, 3, 0).flatten(
181
+ -2
182
+ ) # (batch, out, blocks, 2 * n_freqs)
183
+ # inverse DFT of the first `hop` samples, the ones without wrap-around
184
+ scale = torch.full((n_freqs, 1), 2.0 / n, dtype=x.dtype, device=x.device)
185
+ scale[0] = 1.0 / n
186
+ scale[-1] = 1.0 / n # Nyquist (n is even)
187
+ inverse = torch.cat([scale * cosine[:, :hop], -scale * sine[:, :hop]])
188
+ return (y_f @ inverse).flatten(-2)[..., :n_times]
189
+
190
+ y = compute(x, weight)
191
+ if bias is not None:
192
+ y = y + bias.to(y).unsqueeze(-1)
193
+ return y.to(x)
@@ -62,9 +62,10 @@ def fft_conv1d(
62
62
 
63
63
  Equal to the direct convolution up to float rounding: the FFT is long
64
64
  enough for a linear (not circular) convolution. Its cost barely grows with
65
- the kernel size, so it is faster than the direct one for long kernels on
66
- CPU (see :func:`prefer_fft_conv`). float16/bfloat16 inputs are computed in
67
- float32 (:func:`spectral_input`) and cast back.
65
+ the kernel size, so it is faster than the direct one for long kernels
66
+ (see :func:`prefer_fft_conv`). float16/bfloat16 inputs are computed in
67
+ float32 (:func:`spectral_input`) and cast back. On Intel Gaudi (HPU, no
68
+ complex dtype) the DFTs are real matmuls over overlapping blocks.
68
69
 
69
70
  Parameters
70
71
  ----------
@@ -82,6 +83,8 @@ def fft_conv1d(
82
83
  ``x``. For an even ``kernel_size`` it is aligned like torch's
83
84
  ``padding="same"`` (the extra zero padded on the right).
84
85
  """
86
+ if _real_dft.needs_real_dft(x):
87
+ return _real_dft.fft_conv1d_real(x, weight, bias)
85
88
  n_times, kernel_size = x.shape[-1], weight.shape[-1]
86
89
  # >= n_times + kernel_size - 1 (no circular wrap-around), even and
87
90
  # 5-smooth: the fast cases of a real FFT
@@ -115,8 +118,11 @@ def prefer_fft_conv(x: torch.Tensor, kernel_size: int) -> bool:
115
118
  and from ``batch_size * kernel_size >= 600`` if also
116
119
  ``in_channels * kernel_size >= 120``: with one or two input channels a
117
120
  float32 direct convolution stays cheaper up to k = 85 / 31 (13 long
118
- temporal convolutions of the model zoo, 22 channels x batch 32). GPUs and
119
- HPUs (no complex dtype) keep the direct convolution.
121
+ temporal convolutions of the model zoo, 22 channels x batch 32). On Intel
122
+ Gaudi (HPU) a direct convolution costs about ``batch_size * n_times *
123
+ kernel_size`` and the FFT about a fixed few milliseconds in eager mode: the
124
+ FFT wins from 8 input channels and ``batch_size * n_times * kernel_size >=
125
+ 8e6``. GPUs keep the direct convolution.
120
126
 
121
127
  Parameters
122
128
  ----------
@@ -125,6 +131,8 @@ def prefer_fft_conv(x: torch.Tensor, kernel_size: int) -> bool:
125
131
  kernel_size : int
126
132
  Kernel length in samples.
127
133
  """
134
+ if x.device.type == "hpu":
135
+ return x.shape[1] >= 8 and x.shape[0] * x.shape[-1] * kernel_size >= 8e6
128
136
  return x.device.type == "cpu" and (
129
137
  x.element_size() == 2
130
138
  or (x.shape[0] * kernel_size >= 600 and x.shape[1] * kernel_size >= 120)
@@ -7,13 +7,13 @@ from __future__ import annotations
7
7
  from typing import Optional
8
8
 
9
9
  import torch
10
- import torch.nn.functional as F
11
10
  from einops.layers.torch import Rearrange
12
11
  from torch import nn
13
12
 
14
13
  from braindecode.models.base import EEGModuleMixin
15
14
  from braindecode.models.util import extract_channel_locations_from_chs_info
16
15
  from braindecode.modules import GatedLinearUnit, PatchTokenizer
16
+ from braindecode.modules.attention import _scaled_dot_product_attention
17
17
 
18
18
 
19
19
  class BaRISTA(EEGModuleMixin, nn.Module, license="other"):
@@ -689,7 +689,7 @@ class _RotarySelfAttention(nn.Module):
689
689
 
690
690
  # Dropout falls on the attention output rather than on the weights,
691
691
  # through dropout_p, because the reference disables the latter outright.
692
- attention = F.scaled_dot_product_attention(query, key, value)
692
+ attention = _scaled_dot_product_attention(query, key, value)
693
693
  attention = self.dropout(attention)
694
694
  attention = self.merge_heads(attention)
695
695
  return self.o_proj(attention)
@@ -60,7 +60,7 @@ class EEGInceptionMI(EEGModuleMixin, nn.Module):
60
60
  (:func:`~braindecode.functional.fft_conv1d`: same parameters, equal up
61
61
  to float rounding) instead of a direct convolution. ``None`` (default)
62
62
  decides per input with :func:`~braindecode.functional.prefer_fft_conv`
63
- (FFT on CPU where it was faster in benchmarks, direct on GPU and HPU).
63
+ (FFT on CPU and HPU where it was faster in benchmarks, direct on GPU).
64
64
 
65
65
  References
66
66
  ----------
@@ -340,8 +340,12 @@ class _InceptionModuleMI(nn.Module):
340
340
  X1 = torch.cat([conv(X1) for conv in self.conv_list], 1)
341
341
 
342
342
  # channels_last: same values, but torch's CPU max pool then vectorises
343
- # over channels instead of looping over them.
344
- X2 = self.pooling(X.contiguous(memory_format=torch.channels_last))
343
+ # over channels instead of looping over them. CPU only: on other
344
+ # devices the two layout copies cost more than they save.
345
+ X2 = X
346
+ if X.device.type == "cpu":
347
+ X2 = X.contiguous(memory_format=torch.channels_last)
348
+ X2 = self.pooling(X2)
345
349
  # An even kernel_unit pools n_times + 1 samples: drop the last one.
346
350
  X2 = self.pooling_conv(X2.contiguous())[..., : X.shape[-1]]
347
351
 
@@ -356,7 +356,7 @@ class EEGNeX(EEGModuleMixin, nn.Module):
356
356
 
357
357
 
358
358
  class _TemporalConv(nn.Conv2d):
359
- """``(1, k)`` Conv2d with "same" output length; on CPU, through
359
+ """``(1, k)`` Conv2d with "same" output length; on CPU and HPU, through
360
360
  :func:`~braindecode.functional.fft_conv1d` where
361
361
  :func:`~braindecode.functional.prefer_fft_conv` expects it to be faster."""
362
362
 
@@ -908,7 +908,9 @@ class _Attention(nn.Module):
908
908
  # Reshape to (3, batch, num_heads, seq_len, head_dim)
909
909
  qkv = qkv.reshape(qkv.shape[0], qkv.shape[1], 3, self.num_heads, -1)
910
910
  qkv = qkv.permute(2, 0, 3, 1, 4)
911
- q, k, v = qkv[0], qkv[1], qkv[2] # batch, num_heads, seq_len, head_dim
911
+ # unbind, not qkv[0..2]: the backward of three selects writes three
912
+ # zero-filled copies of the whole qkv tensor and sums them.
913
+ q, k, v = qkv.unbind(0) # batch, num_heads, seq_len, head_dim
912
914
 
913
915
  # 1. Rotary Positional Embeddings (RoPE)
914
916
  # Unlike standard absolute positional encodings, RoPE rotates the
@@ -19,6 +19,7 @@ from torch.nn.init import trunc_normal_
19
19
  from braindecode.functional import rescale_parameter
20
20
  from braindecode.models.base import EEGModuleMixin
21
21
  from braindecode.modules import MLP, DropPath
22
+ from braindecode.modules.attention import _hpu_eager_fused_sdpa
22
23
  from braindecode.modules.blocks import PatchTokenizer
23
24
 
24
25
  # -----------------------------------------------------------------------------
@@ -1429,17 +1430,24 @@ class _Attention(nn.Module):
1429
1430
  relative_position_bias.permute(2, 0, 1).contiguous().unsqueeze(0)
1430
1431
  ) # 1, nH, Wh*Ww, Wh*Ww
1431
1432
 
1432
- # Fused kernel, same math. Not on Gaudi (Labram trains ~12 % slower there)
1433
- # nor with attention dropout in training (it would draw other masks).
1434
- if (
1435
- not return_attention
1436
- and q.device.type != "hpu"
1437
- and (self.attn_drop.p == 0.0 or not self.training)
1438
- ):
1439
- x = nn.functional.scaled_dot_product_attention(
1433
+ # Fused kernel, same math. Not with attention dropout in training (it
1434
+ # would draw other masks). On Gaudi, torch's SDPA trains ~12 % slower
1435
+ # than the plain ops; the bridge's own fused kernel (eager mode, no
1436
+ # mask) is used instead.
1437
+ fused = not return_attention and (self.attn_drop.p == 0.0 or not self.training)
1438
+ out: Optional[torch.Tensor] = None
1439
+ if fused and q.device.type != "hpu":
1440
+ out = nn.functional.scaled_dot_product_attention(
1440
1441
  q, k, v, attn_mask=attn_mask, scale=self.scale
1441
1442
  )
1442
- else:
1443
+ elif (
1444
+ fused
1445
+ and attn_mask is None
1446
+ and not torch.jit.is_scripting()
1447
+ and (q.dtype == torch.float32 or q.dtype == torch.bfloat16)
1448
+ ):
1449
+ out = _hpu_eager_fused_sdpa(q, k, v, self.scale)
1450
+ if out is None:
1443
1451
  attn = (q * self.scale) @ k.transpose(-2, -1)
1444
1452
  if attn_mask is not None:
1445
1453
  attn = attn + attn_mask
@@ -1447,6 +1455,8 @@ class _Attention(nn.Module):
1447
1455
  if return_attention:
1448
1456
  return attn
1449
1457
  x = attn @ v
1458
+ else:
1459
+ x = out
1450
1460
  x = x.transpose(1, 2).reshape(B, N, -1)
1451
1461
 
1452
1462
  x = self.proj(x)
@@ -601,7 +601,9 @@ class _RotarySelfAttentionBlock(nn.Module):
601
601
  .reshape(B, N, 3, self.num_heads, C // self.num_heads)
602
602
  .permute(2, 0, 3, 1, 4)
603
603
  ) # (K, B, H, N, D)
604
- q, k, v = qkv[0], qkv[1], qkv[2]
604
+ # unbind, not qkv[0..2]: the backward of three selects writes three
605
+ # zero-filled copies of the whole qkv tensor and sums them.
606
+ q, k, v = qkv.unbind(0)
605
607
  q = self._rotate_queries_or_keys(q)
606
608
  k = self._rotate_queries_or_keys(k)
607
609
  attn = F.scaled_dot_product_attention(
@@ -12,6 +12,7 @@ import torch.nn as nn
12
12
  import torch.nn.functional as F
13
13
 
14
14
  from braindecode.models.base import EEGModuleMixin
15
+ from braindecode.modules.attention import _scaled_dot_product_attention
15
16
 
16
17
 
17
18
  class PBT(EEGModuleMixin, nn.Module):
@@ -411,13 +412,8 @@ class _MHSA(nn.Module):
411
412
  k = k.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
412
413
  v = v.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
413
414
 
414
- y = torch.nn.functional.scaled_dot_product_attention(
415
- q,
416
- k,
417
- v,
418
- attn_mask=None,
419
- dropout_p=self.drop_prob if self.training else 0.0,
420
- is_causal=False,
415
+ y = _scaled_dot_product_attention(
416
+ q, k, v, dropout_p=self.drop_prob if self.training else 0.0
421
417
  )
422
418
 
423
419
  # re-assemble heads -> (B, T, C)
@@ -15,9 +15,10 @@ import torch
15
15
  import torch.nn.functional as F
16
16
  from mne.datasets.utils import _get_path
17
17
  from torch import nn
18
- from torch.nn import RMSNorm
19
18
 
20
19
  from braindecode.models.base import EEGModuleMixin
20
+ from braindecode.modules.attention import _scaled_dot_product_attention
21
+ from braindecode.modules.layers import RMSNorm
21
22
 
22
23
  logger = logging.getLogger(__name__)
23
24
 
@@ -439,7 +440,8 @@ class REVE(EEGModuleMixin, nn.Module):
439
440
  raise ValueError(
440
441
  "No positions provided and no default positions available. Please provide channel positions."
441
442
  )
442
- pos = self.default_pos.expand(batch_size, -1, -1).to(eeg.device)
443
+ # One copy for the whole batch: the embedding below broadcasts.
444
+ pos = self.default_pos.unsqueeze(0).to(eeg.device)
443
445
 
444
446
  pos = FourierEmb4D.add_time_patch(pos, n_patches)
445
447
  # Positions stay in float32 for the Fourier features; the embedding
@@ -518,6 +520,7 @@ class GEGLU(nn.Module):
518
520
  class FeedForward(nn.Module):
519
521
  def __init__(self, dim: int, hidden_dim: int, geglu: bool):
520
522
  super().__init__()
523
+ self.geglu = geglu
521
524
  self.net = nn.Sequential(
522
525
  RMSNorm(dim, eps=1e-6),
523
526
  nn.Linear(dim, hidden_dim * 2 if geglu else hidden_dim, bias=False),
@@ -526,7 +529,15 @@ class FeedForward(nn.Module):
526
529
  )
527
530
 
528
531
  def forward(self, x: torch.Tensor) -> torch.Tensor:
529
- return self.net(x)
532
+ if not self.geglu:
533
+ return self.net(x)
534
+ # GEGLU halves as two matmuls on the weight's row halves: contiguous
535
+ # outputs instead of strided views of one output (copied on HPU).
536
+ x = self.net[0](x)
537
+ weight = self.net[1].weight
538
+ half = weight.shape[0] // 2
539
+ x, gates = F.linear(x, weight[:half]), F.linear(x, weight[half:])
540
+ return self.net[3](F.gelu(gates) * x)
530
541
 
531
542
 
532
543
  #################################################################################
@@ -554,7 +565,7 @@ class Attention(nn.Module):
554
565
  q = q.unflatten(-1, (self.heads, -1)).transpose(1, 2)
555
566
  k = k.unflatten(-1, (self.heads, -1)).transpose(1, 2)
556
567
  v = v.unflatten(-1, (self.heads, -1)).transpose(1, 2)
557
- out = F.scaled_dot_product_attention(q, k, v)
568
+ out = _scaled_dot_product_attention(q, k, v)
558
569
  return self.to_out(out.transpose(1, 2).flatten(2))
559
570
 
560
571
 
@@ -836,7 +836,7 @@ class CATLite(nn.Module):
836
836
 
837
837
  @torch.jit.unused
838
838
  def _hpu_eager_fused_sdpa(
839
- query: Tensor, key: Tensor, value: Tensor
839
+ query: Tensor, key: Tensor, value: Tensor, scale: Optional[float] = None
840
840
  ) -> Optional[Tensor]:
841
841
  # Lazy mode: None, the graph compiler already fuses torch's SDPA there.
842
842
  from habana_frameworks.torch.utils.internal import is_lazy
@@ -845,7 +845,7 @@ def _hpu_eager_fused_sdpa(
845
845
  return None
846
846
  from habana_frameworks.torch.hpex.kernels import FusedSDPA
847
847
 
848
- return FusedSDPA.apply(query, key, value, None, 0.0, False, None, "None", False)
848
+ return FusedSDPA.apply(query, key, value, None, 0.0, False, scale, "None", False)
849
849
 
850
850
 
851
851
  def _scaled_dot_product_attention(
@@ -10,11 +10,11 @@ import math
10
10
  from typing import Dict, Optional
11
11
 
12
12
  import torch
13
- import torch.nn.functional as F
14
13
  from torch import nn
15
14
 
16
15
  from braindecode.functional import sinusoidal_positional_encoding
17
16
  from braindecode.modules.activation import GatedLinearUnit
17
+ from braindecode.modules.attention import _scaled_dot_product_attention
18
18
  from braindecode.modules.layers import ChannelMerger
19
19
 
20
20
 
@@ -28,7 +28,19 @@ class _ConvBlock(nn.Module):
28
28
  self.act = None if last else activation()
29
29
 
30
30
  def forward(self, x):
31
- x = self.conv(x)
31
+ # Taps more than (T - 1) // dilation steps off-centre only ever read the
32
+ # zero padding: drop them (the same sum without its zero terms, fewer
33
+ # multiply-adds at long dilations).
34
+ d = self.conv.dilation[0]
35
+ half = self.conv.kernel_size[0] // 2
36
+ reach = (x.shape[-1] - 1) // d
37
+ if reach < half:
38
+ weight = self.conv.weight[:, :, half - reach : half + reach + 1]
39
+ x = nn.functional.conv1d(
40
+ x, weight, self.conv.bias, padding=reach * d, dilation=d
41
+ )
42
+ else:
43
+ x = self.conv(x)
32
44
  if self.act is not None:
33
45
  x = self.act(x)
34
46
  return x
@@ -177,7 +189,8 @@ class _Attention(nn.Module):
177
189
  q = q.unflatten(-1, (h, -1)).transpose(1, 2)
178
190
  k = k.unflatten(-1, (h, -1)).transpose(1, 2)
179
191
  v = v.unflatten(-1, (h, -1)).transpose(1, 2)
180
- out = F.scaled_dot_product_attention(q, k, v, scale=self.scale)
192
+ # scale = dim_head ** -0.5 = SDPA's default 1 / sqrt(q.shape[-1])
193
+ out = _scaled_dot_product_attention(q, k, v)
181
194
  # (b, h, n, d) -> (b, n, h * d)
182
195
  return self.to_out(out.transpose(1, 2).flatten(2))
183
196
 
@@ -9,10 +9,12 @@
9
9
  from __future__ import annotations
10
10
 
11
11
  import math
12
+ from typing import Optional
12
13
 
13
14
  import torch
15
+ import torch.nn.functional as F
14
16
  from einops.layers.torch import Rearrange
15
- from torch import nn
17
+ from torch import Tensor, nn
16
18
 
17
19
  from braindecode.functional import drop_path
18
20
 
@@ -331,5 +333,42 @@ class ChannelMerger(nn.Module):
331
333
  scores = torch.einsum("bcd,bod->boc", [embedding, heads])
332
334
  scores = scores + score_offset[:, None]
333
335
  weights = torch.softmax(scores, dim=2).nan_to_num() # over n_chans
334
- out = weights @ x # (B, out, n_chans) @ (B, n_chans, T) -> (B, out, T)
336
+ # (B, out, n_chans) @ (B, n_chans, T) -> (B, out, T). On HPU as
337
+ # (x^T @ weights^T)^T: Gaudi's lazy-mode graph compiler fails on
338
+ # ``weights @ x`` feeding a convolution's backward.
339
+ if x.device.type == "hpu":
340
+ out = (x.transpose(1, 2) @ weights.transpose(1, 2)).transpose(1, 2)
341
+ else:
342
+ out = weights @ x
335
343
  return out # (B, out_channels, T)
344
+
345
+
346
+ @torch.jit.unused
347
+ def _hpu_fused_rms_norm(x: Tensor, weight: Tensor, eps: Optional[float]) -> Tensor:
348
+ from habana_frameworks.torch.hpex.normalization import FusedRMSNorm
349
+
350
+ return FusedRMSNorm.apply(
351
+ x, weight, torch.finfo(x.dtype).eps if eps is None else eps
352
+ )
353
+
354
+
355
+ class RMSNorm(nn.RMSNorm):
356
+ """:class:`torch.nn.RMSNorm`; Gaudi's fused kernel on HPU.
357
+
358
+ On HPU, torch's RMSNorm runs op by op (square, mean, rsqrt, two products,
359
+ and their backward ops). With a weight over the last dimension, in float32
360
+ or bfloat16, the bridge's fused kernel runs it instead. Same parameters and
361
+ state dict; other devices are unchanged.
362
+ """
363
+
364
+ def forward(self, x: Tensor) -> Tensor:
365
+ if (
366
+ not torch.jit.is_scripting()
367
+ and x.device.type == "hpu"
368
+ and self.weight is not None
369
+ and len(self.normalized_shape) == 1
370
+ and x.dtype == self.weight.dtype
371
+ and (x.dtype == torch.float32 or x.dtype == torch.bfloat16)
372
+ ):
373
+ return _hpu_fused_rms_norm(x, self.weight, self.eps)
374
+ return F.rms_norm(x, self.normalized_shape, self.weight, self.eps)
@@ -0,0 +1 @@
1
+ __version__ = "1.8.1.dev172419947"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 1.8.1.dev172377786
3
+ Version: 1.8.1.dev172419947
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>
@@ -28,11 +28,15 @@ Current 1.8.1 (2026-08-31)
28
28
  Enhancements
29
29
  ============
30
30
 
31
+ - :class:`braindecode.models.EEGInceptionMI` takes the channels-last copy for its max pooling only on CPU: on Intel Gaudi (HPU) the layout copies made the eager train step 2.6x slower than in 1.8.1 (now back to 1.8.1's time); CPU unchanged (:gh:`1344` by `Bruno Aristimunha`_).
32
+ - :func:`braindecode.functional.fft_conv1d` runs on Intel Gaudi (HPU) as overlap-save blocks with the DFT as real matmuls instead of a host FFT, and :func:`braindecode.functional.prefer_fft_conv` picks it there from 8 input channels and ``batch_size * n_times * kernel_size >= 8e6``: Gaudi eager train step of :class:`braindecode.models.EEGInceptionMI` 1.4-2.3x faster and :class:`braindecode.models.EEGNeX` 2.1x faster on 60-s windows at 100 Hz, batch 64; CPU unchanged; Gaudi outputs and gradients change by float rounding only (:gh:`1341` by `Bruno Aristimunha`_).
31
33
  - :class:`braindecode.models.CSBrain` runs its region embedding and the region means of every encoder layer for all regions at once (a 0/1 neighbour-selection matmul and one batched matmul per kernel; one ``index_add_``) instead of one convolution and one mean per region: about half the operators per forward, CPU forward and train step 1.14-1.17x faster, Gaudi forward 1.30-1.45x and train step 1.36-1.56x faster; outputs change by float rounding only (:gh:`1335` by `Bruno Aristimunha`_).
32
34
  - :class:`braindecode.models.DIVER1` computes the amplitude spectrum of its spectral embedding on the device on accelerators without complex tensors (Intel Gaudi / HPU) instead of a host FFT round trip: Gaudi forward 1.02-1.12x and train step 1.02-1.10x faster; CPU unchanged (:gh:`1334` by `Bruno Aristimunha`_).
33
35
  - :class:`braindecode.models.DIVER1` builds and overlap-adds its STCPE sliding windows with one gather and one ``index_add`` instead of ``unfold``/``fold``: Gaudi forward 1.25-1.36x and train step 1.13-1.32x faster, CPU 0-1 % faster; outputs and released-checkpoint outputs unchanged, gradients change by float rounding only (:gh:`1333` by `Bruno Aristimunha`_).
36
+ - :class:`braindecode.models.REVE` computes the 4-D position embedding of its default channel positions once per forward and broadcasts it over the batch instead of computing it for one identical copy per example: 3 ms instead of 10-12 ms of each Gaudi train step (21 channels x 6000 samples, batch 64; step 1.01x); explicit ``pos`` inputs are unchanged (:gh:`1347` by `Bruno Aristimunha`_).
34
37
  - :class:`braindecode.models.ContraWR` computes its STFT magnitude on the device on accelerators without complex tensors (Intel Gaudi / HPU) instead of a host STFT and a host-to-device copy of the spectrogram: Gaudi forward 4.2-7.1x and train step 2.4-5.2x faster; CPU unchanged (:gh:`1332` by `Bruno Aristimunha`_).
35
38
  - :class:`braindecode.models.NeuroRVQTokenizer` sums the per-code counts and vectors of its EMA codebook update with ``index_add_`` instead of a dense one-hot matrix and GEMM: CPU train step 1.3x faster (22 channels, batch 32, 2 threads), Gaudi unchanged; outputs, gradients and token ids unchanged, the updated codebooks change by float rounding only (:gh:`1308` by `Bruno Aristimunha`_).
39
+ - :class:`braindecode.models.REVE` computes the two halves of its GEGLU feed-forward as two matrix products on the row halves of the same weight instead of slicing one product, so the activation reads contiguous tensors (HPU copied the strided halves in both passes). Same parameters and state dict; train step 1.11x faster on Gaudi eager and 1.06x on CPU (21 channels x 6000 samples, batch 64), float32 rounding differences only (:gh:`1346` by `Bruno Aristimunha`_).
36
40
  - ``braindecode.modules.EMACodebook`` sums its training EMA statistics per code with ``index_add_`` instead of a dense one-hot matrix and GEMM: :class:`braindecode.models.TFMTokenizer` CPU train step 5 % faster and :class:`braindecode.models.BrainTokenizer` 1-3 % (22 channels, batch 32, 2 threads); outputs, gradients and token ids unchanged, the EMA buffers change by float rounding only (:gh:`1306` by `Bruno Aristimunha`_).
37
41
  - The TUH datasets read the ``_date.txt`` file kept beside each EDF with :func:`json.load` instead of :func:`pandas.read_json`: 2.9 s -> 0.04 s for the 2993 TUAB date files; descriptions unchanged (:gh:`1300` by `Bruno Aristimunha`_).
38
42
  - Add :class:`braindecode.models.Guetschel2026`, the encoder shared by the 58 MAE and JEPA
@@ -45,11 +49,19 @@ Enhancements
45
49
  - :class:`braindecode.models.MetaNeuromotorHand` sums the cross-spectral bins of each frequency band with one einsum instead of a broadcast product and a sum: CPU forward and train step 3-7 % faster, Gaudi 2-10 % faster; outputs and gradients differ from before by more than float32 rounding (up to 1.6x master's own float32-vs-float64 difference, amplified by the eigendecomposition), argmax unchanged (:gh:`1330` by `Bruno Aristimunha`_).
46
50
  - :class:`braindecode.models.MetaNeuromotorHand` rotates and half-vectorizes the MPF matrices with one precomputed ``index_select`` instead of three rolls, a stack and a permute copy: CPU train step about 2 % faster, Gaudi neutral; outputs, gradients and state dict unchanged bit for bit (:gh:`1292` by `Bruno Aristimunha`_).
47
51
  - :class:`braindecode.models.MetaNeuromotorHand` solves the eigendecompositions of its matrix logarithm in chunks on all CPU threads instead of one matrix after another on one thread (torch's CPU ``eigh``): train step 2.5x faster at 24 threads (21 channels x 32,000 samples, batch 64), 11-15 % at 2 threads (batch 32), 1.5x on Gaudi (the featurizer runs on the host CPU); bit-identical outputs and gradients (:gh:`1336` by `Bruno Aristimunha`_).
52
+ - Add ``braindecode.modules.layers.RMSNorm``, a drop-in :class:`torch.nn.RMSNorm` (same parameters and state dict) that runs the Gaudi bridge's fused RMSNorm kernel on HPU instead of torch's op-by-op square, mean, rsqrt and products (float32 or bfloat16 input with a weight over the last dimension; other devices unchanged). :class:`braindecode.models.REVE` uses it: Gaudi train step 1.05x faster in eager mode and 1.03x in lazy mode (21 channels x 6000 samples, batch 64), differences within the Gaudi float32 error (:gh:`1348` by `Bruno Aristimunha`_).
48
53
  - :class:`braindecode.models.CodeBrain` skips the attention scores in eval mode on CPU at the default ``swa_window_size=1``, where the window keeps only the diagonal and the attention reduces to its value projection: CPU eval forward 1.25x faster at 19 x 6000 (batch 32); training unchanged; outputs unchanged bit for bit (:gh:`1293` by `Bruno Aristimunha`_).
49
54
  - :class:`braindecode.models.CodeBrain` takes the same one-wide-window shortcut in training on CPU: the attention weights are exactly one-hot, so the block multiplies the value projection by the diagonal of the dropout mask that :class:`torch.nn.MultiheadAttention` draws (same RNG stream) instead of computing all scores, their softmax, dropout and product: train step 1.2x faster at 21 x 6000 (batch 64, 24 threads) and 1.3x at 19 x 6000 (batch 32, 2 threads); outputs, gradients and dropout masks unchanged bit for bit (:gh:`1339` by `Bruno Aristimunha`_).
50
55
  - :class:`braindecode.models.CodeBrain` computes its bidirectional long convolution as a linear convolution at a 5-smooth FFT length instead of a circular one of length 2 * seq_len: Gaudi forward 2.1x and train step 1.4x faster (19 channels x 6000 samples, batch 32), CPU forward 1-16 % faster, CPU train step unchanged to 6 % faster; outputs and gradients differ from before by more than float32 rounding (up to 1.9x master's own float32-vs-float64 difference on the released checkpoint's logits), argmax unchanged (:gh:`1329` by `Bruno Aristimunha`_).
51
56
  - :class:`braindecode.models.MAPA` folds the (batch, array) axes before its within-array attention, so CPU attention runs as one fused 4-D :func:`torch.nn.functional.scaled_dot_product_attention` call instead of the 5-D math fallback: CPU forward 1.16x and train step 1.03x faster at 22 contacts (batch 32), 4.2 GB less peak memory in training; Gaudi unchanged; outputs and gradients change by float rounding only (relative differences below 1e-6) (:gh:`1294` by `Bruno Aristimunha`_).
52
57
  - :class:`braindecode.modules.MultiHeadAttention` (EEGConformer, CTNet, MSCFormer, MIRepNet, STEEGFormer) and :class:`braindecode.models.ZUNA` run attention through the Gaudi bridge's fused SDPA kernel in HPU eager mode, where torch's SDPA runs op by op through the full score matrix (without a mask or dropout; lazy mode, CPU and other devices unchanged): Gaudi eager train step STEEGFormer 2.2x and ZUNA 1.7x faster (21 channels x 6000 samples), forward 1.2-2x for the other models; differences within the Gaudi float32 error (:gh:`1338` by `Bruno Aristimunha`_).
58
+ - :class:`braindecode.models.PBT` runs its attention through the shared SDPA helper of :class:`braindecode.modules.MultiHeadAttention`, so in HPU eager mode attention without dropout (eval mode, ``drop_prob=0``) uses the Gaudi bridge's fused SDPA kernel instead of the op-by-op path through the full score matrix: Gaudi eager forward 2.0x faster (21 channels x 6000 samples, batch 64); training with attention dropout, lazy mode, CPU and other devices unchanged (outputs, gradients and dropout draws identical); eval outputs within the Gaudi float32 error (:gh:`1350` by `Bruno Aristimunha`_).
59
+ - :class:`braindecode.models.DANCE` skips the taps of its dilated convolutions that only ever read the zero padding (kernel offset at or beyond the input length): CPU train step 0.92x and Gaudi eager 0.97x (21 channels x 6000 samples, batch 64); outputs change by float rounding only (:gh:`1343` by `Bruno Aristimunha`_).
60
+ - :class:`braindecode.modules.ChannelMerger` (DANCE, ``BrainModule(use_merger=True)``) computes its channel mix as ``(x^T @ weights^T)^T`` on HPU, where Gaudi's lazy-mode graph compiler failed on ``weights @ x`` feeding a convolution's backward: DANCE now trains in Gaudi lazy mode (train step 622 ms vs 844 ms in eager mode, 21 channels x 6000 samples, batch 64); other devices run the same code as before (:gh:`1351` by `Bruno Aristimunha`_).
61
+ - :class:`braindecode.models.Labram` and :class:`braindecode.models.BaRISTA` run attention through the Gaudi bridge's fused SDPA kernel in HPU eager mode (without a mask or attention dropout; lazy mode, CPU and other devices unchanged): Gaudi eager train step Labram 8 % and BaRISTA 5 % faster (21 channels x 6000 samples), differences within the Gaudi float32 error (:gh:`1342` by `Bruno Aristimunha`_).
62
+ - :class:`braindecode.models.DANCE` runs its Perceiver attention through the same Gaudi fused SDPA path in HPU eager mode (torch's SDPA there computes the full score matrix op by op, which made the DANCE Gaudi eager train step 8 % slower than in 1.8.1): Gaudi eager train step 848 -> 763 ms (21 channels x 6000 samples, batch 64); CPU and Gaudi lazy mode unchanged (:gh:`1340` by `Bruno Aristimunha`_).
63
+ - :class:`braindecode.models.REVE` runs its attention through the same helper, so HPU eager mode uses the Gaudi bridge's fused SDPA kernel instead of torch's op-by-op SDPA through the full score matrix (lazy mode, CPU and other devices unchanged): Gaudi eager train step 1.42x faster (21 channels x 6000 samples, batch 64); differences within the Gaudi float32 error (:gh:`1345` by `Bruno Aristimunha`_).
64
+ - :class:`braindecode.models.EEGPT` and :class:`braindecode.models.LUNA` split their fused query/key/value projection with ``unbind`` instead of three index selects, whose backward wrote a zero-filled copy of the whole projection gradient per select and summed them: EEGPT train step 1.09x faster on CPU and 1.02-1.03x on Gaudi (21 channels x 6000 samples, batch 64); outputs and gradients unchanged bit for bit (:gh:`1352` by `Bruno Aristimunha`_).
53
65
  - :class:`braindecode.models.NeuroRVQ` and :class:`braindecode.models.NeuroRVQTokenizer` run their four temporal scales through the shared transformer blocks as one stacked batch on accelerators (CPU, and training with dropout, keep the per-scale loop): Gaudi train step 1.7-2.6x and forward 1.8-3.1x faster; CPU unchanged; outputs and token ids unchanged on CPU, within float rounding on Gaudi (:gh:`1312` by `Bruno Aristimunha`_).
54
66
  - :class:`braindecode.datasets.TUH`, :class:`braindecode.datasets.TUHAbnormal` and :class:`braindecode.datasets.TUHEvents` build the standard_1005 montage once per process instead of twice per recording for ``rename_channels`` / ``set_montage``: 2993 TUAB recordings, ``rename_channels`` + ``set_montage`` 37.5 s -> 14.5 s (2.6x), 23 s less per ``TUHAbnormal`` indexing with ``n_jobs=1``; channel names, types, positions and descriptions unchanged (:gh:`1299` by `Bruno Aristimunha`_).
55
67
  - The attention of :class:`braindecode.models.Labram` (shared by :class:`braindecode.models.NeuroRVQ` and :class:`braindecode.models.NeuroRVQTokenizer`) runs through :func:`torch.nn.functional.scaled_dot_product_attention` with the relative position bias as attn_mask off HPU (the manual path stays on HPU, with ``return_attention=True`` and with attention dropout in training): Labram CPU forward 1.2-1.3x and train step 1.06-1.14x faster, NeuroRVQ / NeuroRVQTokenizer CPU up to 6 % faster, Gaudi unchanged; outputs and gradients differ from before by more than float32 rounding (up to 2.5x master's own float32-vs-float64 difference on the released Labram checkpoint's gradients), token ids unchanged in single forward passes (:gh:`1328` by `Bruno Aristimunha`_).
@@ -1 +0,0 @@
1
- __version__ = "1.8.1.dev172377786"