if resolved_backend == "eager":
_validate_eps(eps)
_validate_projection_shapes(x, w_down, w_up, w_gate, gamma, channels)
return _gated_residual_eager(x, w_down, w_up, w_gate, gamma, channels, eps)
if x.device.type != "npu":
raise ValueError("Gated Residual backend='ascendc' requires NPU tensors")
if x.dtype not in (torch.float16, torch.bfloat16):
raise ValueError("Gated Residual backend='ascendc' supports float16 or bfloat16 inputs")
# For nonempty AscendC calls, CANN validates projection shapes, optional
# inputs, dtypes and epsilon. Keep only the checks needed before Python
# reshaping and backend dispatch above.
return _gated_residual_fused(x, w_down, w_up, w_gate, gamma, channels, eps)
__all__ = ["gated_residual"]