disable_compat
通过从 sys.meta_path 中移除 TorchProxyMetaFinder 来禁用 PyTorch 代理。 这可以防止 torch 导入被代理到 PaddlePaddle。
返回
None
代码示例
>>> import paddle
>>> paddle.enable_compat() # Enable torch compat globally
>>> import torch # This will import paddle as torch
>>> assert torch.sin is paddle.sin
>>> paddle.disable_compat() # Disable torch compat
>>> try:
... import torch # This will raise ModuleNotFoundError
... except ModuleNotFoundError:
... print("PyTorch compat is disabled.")