Commit a513455
authored
Add Cyclic Group Representation (CGR) class (#182)
* Add BaseMCRTensor
Add a new base class to support future implementation of variations of
MCR proposals.
* Fix bug in BaseMCRTensor:__torch_function__()
There is a bug when args is a collection of collections instead of a
plain tuple. In this case, the old args parsing was unable to search for
block_size in nested structures containing BaseMCRTensor.
For instance, let `a` and `b` be BaseMCRTensor variables. Calling
`torch.stack((a, b))` results in error, as the `args` received in
`__torch_function__()` is a nested tuple.
* Add CGRTensor
Add a new VSA class named Cyclic Group Representation (CGR). This class
is similar to MCR, but differs in bundling.
* Add CGRTensor to functional embeddings
Allow its usage in level and circular embeddings as done with MCRTensor.
* Fix CGR bundle
Ensure both inputs are in the same shape.
* Add CGR into tests
The CGR should behave almost the same as MCR, but diverges in bundling.
Implement a custom bundling test for it.
* Use Tensor.dim() in CGRTensor
Shorter syntax and more readable.
* Remove asserts in CGR/MCR classes
No need to check block size in CGR/MCR functions as the
__torch_function__() in BaseMCRTensor already checks it.
* Improve exception in BaseMCRTensor if multiple block_sizes
- Raise ValueError instead of RuntimeError
* Add CGRTensor to docs
Include CGRTensor in the README and in the built docs.
* Add BaseMCRTensor to docs
* Fix typo in README.md
* Improve documentation for MCRTensor and CGRTensor
Replicate function signatures in inherited classes (MCRTensor and
CGRTensor) from their parent class (BaseMCRTensor) to let sphinx
print the documentation of each parent function.1 parent 6b7478d commit a513455
File tree
17 files changed
+736
-393
lines changed- docs
- torchhd
- tensors
- tests
- basis_hv
17 files changed
+736
-393
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| 96 | + | |
94 | 97 | | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| |||
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
364 | | - | |
| 367 | + | |
365 | 368 | | |
366 | 369 | | |
367 | 370 | | |
| |||
588 | 591 | | |
589 | 592 | | |
590 | 593 | | |
591 | | - | |
| 594 | + | |
592 | 595 | | |
593 | 596 | | |
594 | 597 | | |
| |||
0 commit comments