Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

[Bug] Match Cast Missing After Legalization #437

Open
zxybazh opened this issue Feb 15, 2023 · 2 comments
Open

[Bug] Match Cast Missing After Legalization #437

zxybazh opened this issue Feb 15, 2023 · 2 comments

Comments

@zxybazh
Copy link
Contributor

zxybazh commented Feb 15, 2023

When we were trying to get Expand operator supported, we tried to legalize broadcast_to op and found that the operator would fail well formed check after legalization. The cause is match cast went missing during legalization.

The reproducible script is here: https://gist.github.com/zxybazh/5b09bad2cf13ea7d15329a86b03a6abf

CC @MasterJH5574 @tqchen

@MasterJH5574
Copy link
Collaborator

LegalizeOps does a step of RemoveAllUnused here.

updated_func = remove_all_unused(updated_func)

It looks to me that the RemoveAllUnused regards the MatchCast as an unused binding, and thereby removes it. While in fact, the MatchCast is a binding with side-effect (where the side-effect is “defining x_0 and x_1).

As a workaround, you can probably try removing the step of RemoveAllUnused. In the long term, I think RemoveAllUnused should be updated to skip the bindings with side-effects, or we introducing a better DCE pass.

@tqchen
Copy link
Contributor

tqchen commented Feb 15, 2023

This should be a bug of remove unused not considering dep through symbolic variables and we should fix it. As a quick fix, we can avoid removing match cast for now. Then apply deeper analysis later

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants