mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 21:49:24 +08:00
reland "python functionalization: add helpers, functionalize_sync and mirror_autograd_meta (#107917)" (#109518)
Reland - the previous PR was reverted by internal with this error: ``` File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/torch/fb/trainer/data_modules/tests/__test_dataloader__/test_dataloader#link-tree/torch/__init__.py", line 29, in <module> from ._utils_internal import _functionalize_sync as _sync ImportError: cannot import name '_functionalize_sync' from 'torch._utils_internal' ``` I couldn't figure out why internal was unhappy with the import. One potential reason is that I see a build rule for *another* `_utils_internal.py` in the fb folder here ([link](https://www.internalfb.com/code/fbsource/[30ed85cd88409af98b7490be137aaa5dfd7afd01]/fbcode/caffe2/TARGETS?lines=444)) Rather than burn more time investigating, I confirmed internally that the error goes away if I move the util from `torch/_utils_internal.py` to `torch/_utils.py`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/109518 Approved by: https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
677a1010e6
commit
25e81f19f3
@ -600,9 +600,9 @@ class MetaConverter:
|
||||
dynamic_dims=dynamic_dims,
|
||||
constraint_dims=constraint_dims,
|
||||
)
|
||||
return torch._to_functional_tensor(
|
||||
fake_t, mirror_autograd_meta=True
|
||||
)
|
||||
out = torch._to_functional_tensor(fake_t)
|
||||
torch._mirror_autograd_meta_to(fake_t, out)
|
||||
return out
|
||||
else:
|
||||
# torch.func.functionalize
|
||||
reapply_views = torch._C._functionalization_reapply_views_tls()
|
||||
|
Reference in New Issue
Block a user