libtorch doesn’t officially support autocast in C++ yet.  You can try to rig it by imitating the C++ calls made by torch.cuda.amp.autocast 19 during __enter__ at the beginning of your C++ autocasted region and imitating the C++ calls made by __exit__ at the end of your C++ autocasted region.  The mapping between torch._C functions and C++ -side function calls can be seen here 13.
Right now doing the above is definitely “off menu.”  I plan to support autocast in libtorch by adding an RAII guard that does all those things in an exception-safe way.