Skip to content

Commit

Permalink
fix an op convertion error (#469)
Browse files Browse the repository at this point in the history
Address this
[todo](#458 (comment))
  • Loading branch information
haoyang9804 authored Dec 28, 2023
1 parent 2d7793f commit 7330b8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Empty file added recordconda
Empty file.
18 changes: 9 additions & 9 deletions src/onediff/infer_compiler/transform/builtin_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import torch
import oneflow as flow


from .manager import transform_mgr
from ..utils.log_utils import logger
from ..utils.patch_for_diffusers import diffusers_checker
Expand Down Expand Up @@ -325,14 +324,15 @@ def _(mod: None, verbose=False):
def _(mod: types.BuiltinFunctionType, verbose=False):
if hasattr(mod, "__module__"):
mod_name = None
#TODO: This solution is a compromise for now.
#TODO: Should register nn.linear later to solve it elegantly
if mod == torch._C._nn.linear:
return flow.nn.functional.linear
elif mod.__module__.startswith("torch._C._nn"):
mod_name = mod.__module__.replace(
"torch._C._nn", "oneflow._oneflow_internal._C"
)
if mod.__module__.startswith("torch._C._nn"):
# The equivalence of mod inside torch._C._nn may be
# defined in flow.nn.functional
if getattr(flow.nn.functional, mod.__name__):
mod_name = "oneflow.nn.functional"
else:
mod_name = mod.__module__.replace(
"torch._C._nn", "oneflow._oneflow_internal._C"
)
elif mod.__module__.startswith("torch"):
try:
if getattr(torch.nn.functional, mod.__name__) == mod:
Expand Down

0 comments on commit 7330b8c

Please sign in to comment.