Skip to content

Commit

Permalink
copy is_non_strict_exporting over to resolve backward compatibility…
Browse files Browse the repository at this point in the history
… issue

Summary:
# context
* An ImportError was reported
```
ImportError: cannot import name 'register_custom_op' from 'torchrec.modules.utils'
```
* it's due to previously introduced function at D56443608
* test failed: https://www.internalfb.com/intern/test/562950051370255/
```
Mitigation: ImportError("cannot import name 'is_non_strict_exporting' from '<torch_package_1>.torchrec.sparse.jagged_tensor' (<torch_package_1>.torchrec/sparse/jagged_tensor.py)")
```

Reviewed By: IvanKobzarev, drdarshan

Differential Revision: D56578871

fbshipit-source-id: 3f447cac2946ac8b270848c0067bf990f3e31707
  • Loading branch information
TroyGarden authored and facebook-github-bot committed Apr 30, 2024
1 parent 3c785ea commit 516c813
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions torchrec/modules/embedding_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,25 @@
pooling_type_to_str,
)
from torchrec.modules.utils import register_custom_op
from torchrec.sparse.jagged_tensor import (
is_non_strict_exporting,
JaggedTensor,
KeyedJaggedTensor,
KeyedTensor,
)
from torchrec.sparse.jagged_tensor import JaggedTensor, KeyedJaggedTensor, KeyedTensor


try:
if torch.jit.is_scripting():
raise Exception()

from torch.compiler import (
is_compiling as is_compiler_compiling,
is_dynamo_compiling as is_torchdynamo_compiling,
)

def is_non_strict_exporting() -> bool:
return not is_torchdynamo_compiling() and is_compiler_compiling()

except Exception:

def is_non_strict_exporting() -> bool:
return False


@torch.fx.wrap
Expand Down

0 comments on commit 516c813

Please sign in to comment.