Skip to content

Commit

Permalink
Allow docs to be built even when _C extension isn't compiled (fairint…
Browse files Browse the repository at this point in the history
  • Loading branch information
lw authored and xFormers Bot committed Nov 7, 2023
1 parent bc5ff01 commit b4c853d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xformers/ops/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import torch
from torch.torch_version import TorchVersion

from .._C import box_process_group, unbox_process_group


def get_operator(library: str, name: str):
def no_such_operator(*args, **kwargs):
Expand Down Expand Up @@ -122,6 +120,8 @@ def callee(*args, **kwargs):
ba = sign.bind(*args, **kwargs)
for name, value in ba.arguments.items():
if sign.parameters[name].annotation is torch.distributed.ProcessGroup:
from .._C import unbox_process_group

ba.arguments[name] = unbox_process_group(value)
return fn(*ba.args, **ba.kwargs)

Expand All @@ -135,6 +135,8 @@ def caller(*args, **kwargs):
ba = sign.bind(*args, **kwargs)
for name, value in ba.arguments.items():
if sign.parameters[name].annotation is torch.distributed.ProcessGroup:
from .._C import box_process_group

ba.arguments[name] = box_process_group(value)
return dispatcher_impl(*ba.args, **ba.kwargs)

Expand Down

0 comments on commit b4c853d

Please sign in to comment.