Skip to content

Commit 62ef2dc

Browse files
committed
wrap a compatible empty
1 parent 1f277ac commit 62ef2dc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sonicmoe/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ def __call__(self, *args, **kwargs):
1111

1212
paddle.library.CustomOpDef.__call__ = __call__
1313

14+
def torch_compat_empty(*args, **kwargs):
15+
if "device" in kwargs and kwargs["device"] == "cuda":
16+
del kwargs["device"]
17+
return paddle.empty(*args, **kwargs)
18+
19+
paddle.compat.proxy._extend_torch_proxy_overrides(
20+
{
21+
"torch.empty": paddle.compat.proxy.RawOverriddenAttribute(torch_compat_empty),
22+
}
23+
)
24+
1425
from .count_cumsum import count_cumsum
1526
from .enums import KernelBackendMoE
1627
from .functional import enable_quack_gemm, moe_TC_softmax_topk_layer

0 commit comments

Comments
 (0)