[XPU] Use fused_input_norm kernel in FusedInputNorm (#52945)
Signed-off-by: Zhu, Zufang <zufang.zhu@intel.com> Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
@@ -578,6 +578,37 @@ def _xpu_mxfp4_quantize_fake(
|
||||
return x_q, x_s
|
||||
|
||||
|
||||
def _xpu_fused_input_norm_impl(
|
||||
x: torch.Tensor,
|
||||
weight: torch.Tensor | None,
|
||||
bias: torch.Tensor | None,
|
||||
visual_dtype: torch.dtype,
|
||||
) -> torch.Tensor:
|
||||
patches, size = x.shape
|
||||
out = torch.empty(
|
||||
(patches, size),
|
||||
dtype=visual_dtype,
|
||||
device=x.device,
|
||||
)
|
||||
torch.ops._xpu_C.fused_input_norm(out, x.contiguous(), weight, bias)
|
||||
return out
|
||||
|
||||
|
||||
def _xpu_fused_input_norm_fake(
|
||||
x: torch.Tensor,
|
||||
weight: torch.Tensor | None,
|
||||
bias: torch.Tensor | None,
|
||||
visual_dtype: torch.dtype,
|
||||
) -> torch.Tensor:
|
||||
patches, size = x.shape
|
||||
out = torch.empty(
|
||||
(patches, size),
|
||||
dtype=visual_dtype,
|
||||
device=x.device,
|
||||
)
|
||||
return out
|
||||
|
||||
|
||||
@triton.jit
|
||||
def _softplus(x):
|
||||
return tl.where(x <= 20.0, tl.math.log(tl.math.exp(x) + 1.0), x)
|
||||
@@ -1281,6 +1312,12 @@ class xpu_ops:
|
||||
],
|
||||
)
|
||||
|
||||
direct_register_custom_op(
|
||||
op_name="xpu_fused_input_norm",
|
||||
op_func=_xpu_fused_input_norm_impl,
|
||||
fake_impl=_xpu_fused_input_norm_fake,
|
||||
)
|
||||
|
||||
_OPS_REGISTERED = True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user