loopy
loopy copied to clipboard
LoopyKeyBuilder: hash for BasicSet differs for objects that compare equal
import islpy as isl
a=isl.BasicSet("[im_w, im_h, nimgs, nfeats] -> { : im_w >= 7 and im_h >= 7 and nimgs >= 0 and nfeats > 0 }")
b=isl.BasicSet("[nfeats, nimgs, im_h, im_w] -> { : nfeats > 0 and nimgs >= 0 and im_h >= 7 and im_w >= 7 }")
from loopy.tools import LoopyKeyBuilder
assert a == b
assert LoopyKeyBuilder()(a) == LoopyKeyBuilder()(b)
$ python set.py
Traceback (most recent call last):
File "/Users/mdiener/Work/e12test/loopy/set.py", line 12, in <module>
assert LoopyKeyBuilder()(a) == LoopyKeyBuilder()(b)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
The same issue exists with hash(), as well as Set(including Set.get_hash).
cc: #576, #828, https://github.com/inducer/islpy/issues/89
@inducer, is the goal to address this issue with https://github.com/inducer/namedisl/ ? So far, I haven't found a good way to resolve this issue within isl/islpy. In particular, get_hash (for isl.Set) also returns different values for Sets that are equal.
Thanks for finding and reporting this. It's a little surprising to me that isl considers those two sets equal; I'm not sure I can think of a hash function that would figure that out. Perhaps isl uses align_params before comparing? Maybe try plain_is_equal? At any rate, yes, from my perspective, the plan is to have namedisl present a (more?) consistent view of hashing and equality than we currently have. (While also, hopefully, offering a nicer interface than current isl---but that's all mostly vaporware for now.)