HazyResearch / structured-nets

Structured matrices for compressing neural networks
Apache License 2.0
67 stars 21 forks source link

Tests from `toeplitz_cpu.py` fail #8

Open tahle opened 2 years ago

tahle commented 2 years ago

If I run toeplitz_cpu.py I get

[[ -8. -10.  -2.   8.]
 [  8.  -4.   6.  32.]]
[[-16. -20.  -4.  16.]
 [ 16.  -8.  12.  64.]]
[[8.8817842e-16 6.0000000e+00 1.6000000e+01 2.6000000e+01]
 [0.0000000e+00 1.2000000e+01 3.8000000e+01 6.6000000e+01]]
[[ 0.  6. 16. 26.]
 [ 0. 12. 38. 66.]]

The latter two matrices are equal, but the two first are off by a factor two. These should be the same, since they are the outputs of

  print(toeplitz_mult(v, v, u))
  print(toeplitz_mult_slow(v, v, u))
tahle commented 2 years ago

This might be related to the division by 2 in the line

return krylov_out/2 if cycle else krylov_out