NVIDIA / Fuser

A Fusion Code Generator for NVIDIA GPUs (commonly known as "nvFuser")
Other
271 stars 53 forks source link

Return a bool indicating if all nodes are visited #3452

Closed naoyam closed 1 day ago

naoyam commented 1 day ago

Just a mechanical change. This makes it a little cumbersome when require_all_to_visited is not used, but sometimes we also need to check if all nodes were visited.

naoyam commented 1 day ago

!build

naoyam commented 17 hours ago

Is BFS(require_all_to_visited=true).getShortestExprPath().first equivalent to the following?

auto pair = BFS(require_all_to_visited=false).getShortestExprPath();
NVF_ERROR(pair.second);
return pair.first;

We are not removing this require_all_to_visited flag because:

  • It is almost always true, and it would be annoying to add the NVF_ERROR everywhere we use BFS, and
  • It is common for a developer to forget this NVF_ERROR, and if this happens, we missed an opportunity to catch a bug.

Yes. I also considered having two separate versions, with require_all_to_visited being true or false so that the former version wouldn't need to do .first, but I wasn't sure which one would be better.