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

[Tracking Issue] Add exact_match argument for binary search block generation in LowerSparseIter pass #74

Open
yzh119 opened this issue Nov 29, 2022 · 0 comments
Assignees

Comments

@yzh119
Copy link
Member

yzh119 commented Nov 29, 2022

Pitch

Currently, we only support two modes lower_bound/upper_bound for binary search. In some cases, we need to identify whether the given coordinate matches with any of the values in an indices list, and neither lower_bound nor upper_bound is enough in this case.

Solution

We should add an exact_match argument in the binary search block generation function. When exact_match is set to true, the generated binary search block will write a INVALID (a macro represents an invalid value) to output lookup array.

We also need to propagate the invalid property: if mid[vi] is INVALID, then A[mid[vi]] will be invalid memory access.
The correct way to process such a case is to invalidate the whole expression:

# for expressions, replace it with a given padding value
INVALID if mid[vi] is INVALID else A[mid[vi]]
# for statements, replace it with NOP
if mid[vi] is INVALID:
    T.evaluate(0)
else:
    A[mid[vi]] = ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant