Skip to content

fix: forward-declare copy atoms to make copy.hpp and prefetch.hpp self-contained - #3603

Open
Sunjnn wants to merge 1 commit into
NVIDIA:mainfrom
Sunjnn:fix/copy_atom_self_include
Open

Sunjnn wants to merge 1 commit into
NVIDIA:mainfrom
Sunjnn:fix/copy_atom_self_include

Conversation

@Sunjnn

@Sunjnn Sunjnn commented Sep 9, 2026

Copy link
Copy Markdown

Problem

cute/algorithm/copy.hpp and cute/algorithm/prefetch.hpp both include cute/atom/copy_atom.hpp to pull in Copy_Atom, TiledCopy, and ThrCopy. However, copy_atom.hpp includes
these algorithm headers back through a cycle:

copy_atom.hpp -> mma_atom.hpp -> ... -> partitioner.hpp -> tensor.hpp -> (back here)

Because of this cycle, a translation unit whose first cute include is copy_atom.hpp parses the overloads in copy.hpp/prefetch.hpp while their own #include
<cute/atom/copy_atom.hpp> is a no-op (the include guard is already active). The dispatch types are therefore not yet declared, and the overloads fail to parse.

Fix

Add forward declarations of the atom class templates at the top of each header, so the overloads that dispatch on them remain valid regardless of include order. The full
definitions still arrive from copy_atom.hpp before anything can instantiate them.

  • include/cute/algorithm/copy.hpp — forward-declare Copy_Atom, TiledCopy, ThrCopy
  • include/cute/algorithm/prefetch.hpp — forward-declare Copy_Atom

Impact

  • Header-only, no behavioral or ABI change.
  • Makes both headers self-contained — they can now be the first cute header a translation unit includes.

This branch has not been deployed

No deployments
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 this pull request may close these issues.

1 participant