Returns the active autocast dtype on the calling thread.
Reads the thread-local AMP state established by the innermost live
AutocastGuard. Returns std::nullopt when no guard is
active — callers can use this to skip the AMP dispatch path entirely.
Returns
std::optional<Dtype>The autocast target dtype if AMP is active on this thread, or std::nullopt otherwise.
Notes
All AMP state is thread_local; different Python threads (or OpenMP
workers) can each maintain independent autocast contexts without
synchronisation.