Cast a to dst_dtype, preserving shape and (when grad mode is enabled) wiring an AstypeBackward node that casts the gradient back during backward.
Parameters
aTensorImplPtrdst_dtypeDtypeastype kernel, not in a raw reinterpret).Returns
TensorImplPtrNew tensor with dtype dst_dtype and the same shape as a. If a.dtype() == dst_dtype the function returns a itself so the existing grad_fn chain is preserved — earlier versions allocated a fresh TensorImpl here which silently broke autograd routing under AMP.
Notes
Used internally by the AMP-aware kernels (Linear / Conv / Matmul /
BatchNorm) to cast inputs to the effective compute dtype while keeping
the backward chain intact. Argmin / argmax reductions also call this
to materialise their integer outputs; those callers do not enable
gradients, so the autograd wiring path is skipped and the cost stays
identical to a raw backend astype.