-- Fix namespace qualification for cast functions in amp_utils.h -- -- The code was using unqualified `sparse::cast_ad_func` and `cast_ad_func` which -- don't exist. They should use the full namespace qualifier like the non-trace_backward -- paths do: `paddle::experimental::sparse::cast` and `paddle::experimental::cast`. -- -- This fixes compilation errors: -- error: use of undeclared identifier 'sparse' -- error: no member named 'cast_ad_func' in namespace 'paddle::experimental::sparse' -- error: use of undeclared identifier 'cast_ad_func' --- paddle/fluid/imperative/amp_utils.h.orig 2026-09-09 02:40:49 UTC +++ paddle/fluid/imperative/amp_utils.h @@ -227,14 +227,15 @@ static inline paddle::Tensor Cast(const paddle::Tensor const bool trace_backward = true) { if (input.is_sparse_coo_tensor() || input.is_sparse_csr_tensor()) { if (trace_backward) { - return sparse::cast_ad_func(input, DataType::UNDEFINED, dst_dtype); + return paddle::experimental::sparse::cast( + input, DataType::UNDEFINED, dst_dtype); } else { return paddle::experimental::sparse::cast( input, DataType::UNDEFINED, dst_dtype); } } else { if (trace_backward) { - return cast_ad_func(input, dst_dtype); + return paddle::experimental::cast(input, dst_dtype); } else { return paddle::experimental::cast(input, dst_dtype); }