tinygrad
tinygrad copied to clipboard
replace Tensor.eq with __eq__
currently to compare tensors we use the eq function inside Tensor but ideally should use __eq__
to support (t1 == t2)
keep an eye out as when I attempted this, it made the Tensor class un-hashable and broke use cases where Tensor was used in sets
still seems hashable, to me. Don't know about sets though.
If you define __eq__
without defining __hash__
the object becomes unhashable. Sets and dictionaries rely on an immutable hash for an object. Not sure if it's worth the extra lines. Torch also uses .eq
and .eq_
methods: https://pytorch.org/docs/stable/generated/torch.eq.html#torch.eq