Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoopyKeyBuilder: hash for BasicSet differs for objects that compare equal #912

Open
matthiasdiener opened this issue Feb 6, 2025 · 2 comments · May be fixed by #913
Open

LoopyKeyBuilder: hash for BasicSet differs for objects that compare equal #912

matthiasdiener opened this issue Feb 6, 2025 · 2 comments · May be fixed by #913

Comments

@matthiasdiener
Copy link
Collaborator

matthiasdiener commented Feb 6, 2025

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, inducer/islpy#89

@matthiasdiener matthiasdiener changed the title LoopyKeyBuilder: hash for BasicSet different for objects that compare equal LoopyKeyBuilder: hash for BasicSet differs for objects that compare equal Feb 6, 2025
@matthiasdiener
Copy link
Collaborator Author

@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.

@inducer
Copy link
Owner

inducer commented Feb 6, 2025

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.)

@matthiasdiener matthiasdiener linked a pull request Feb 6, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants