Skip to content

Commit 0290270

Browse files
committed
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.
1 parent 124312a commit 0290270

File tree

3 files changed

+0
-6
lines changed

3 files changed

+0
-6
lines changed

torchhd/tensors/basemcr.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def bind(self, other: "BaseMCRTensor") -> "BaseMCRTensor":
255255
BaseMCRTensor([ 0, 27, 61, 21, 0, 38, 0, 13, 39, 18])
256256
257257
"""
258-
assert self.block_size == other.block_size
259258
return torch.remainder(torch.add(self, other), self.block_size)
260259

261260
def multibind(self) -> "BaseMCRTensor":

torchhd/tensors/cgr.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ def bundle(self, other: "CGRTensor") -> "CGRTensor":
6161
CGRTensor([32, 26, 39, 22, 27, 60, 2, 4, 40, 5])
6262
6363
"""
64-
assert self.block_size == other.block_size
65-
6664
# Ensure hypervectors are in the same shape, i.e., [..., 1, DIM]
6765
t1 = self
6866
if t1.dim() == 1:
@@ -83,7 +81,6 @@ def bundle(self, other: "CGRTensor") -> "CGRTensor":
8381

8482
def multibundle(self) -> "CGRTensor":
8583
"""Bundle multiple hypervectors"""
86-
8784
# The use of torch.mode() makes untying deterministic as it always
8885
# returns the lowest index among the ties. For example, if there is an
8986
# equal number amount of 0s and 1s in a bundle, 0 is returned.

torchhd/tensors/mcr.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ def bundle(self, other: "MCRTensor") -> "MCRTensor":
6262
MCRTensor([32, 26, 39, 54, 27, 60, 2, 4, 40, 5])
6363
6464
"""
65-
assert self.block_size == other.block_size
66-
6765
self_phasor = self.to_complex_unit()
6866
other_phasor = other.to_complex_unit()
6967

0 commit comments

Comments
 (0)