IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
654B

  1. from icosagon.fastconv import _sparse_diag_cat
  2. import torch
  3. def test_sparse_diag_cat_01():
  4. matrices = [ torch.rand(5, 10).round() for _ in range(7) ]
  5. ground_truth = torch.zeros(35, 70)
  6. ground_truth[0:5, 0:10] = matrices[0]
  7. ground_truth[5:10, 10:20] = matrices[1]
  8. ground_truth[10:15, 20:30] = matrices[2]
  9. ground_truth[15:20, 30:40] = matrices[3]
  10. ground_truth[20:25, 40:50] = matrices[4]
  11. ground_truth[25:30, 50:60] = matrices[5]
  12. ground_truth[30:35, 60:70] = matrices[6]
  13. res = _sparse_diag_cat([ m.to_sparse() for m in matrices ])
  14. res = res.to_dense()
  15. assert torch.all(res == ground_truth)