本文簡要介紹python語言中 torch.fx.Proxy 的用法。
- 用法:- class torch.fx.Proxy(node, tracer=None)
- Proxy對象是- Node包裝器,在符號跟蹤期間流經程序,並記錄它們接觸到不斷增長的 FX Graph 的所有操作(- torch函數調用、方法調用、運算符)。- 如果您正在執行圖形轉換,您可以將自己的 - Proxy方法包裝在原始- Node周圍,以便您可以使用重載的運算符向- Graph添加其他內容。- Proxy對象無法迭代。換句話說,如果在循環中使用- Proxy或作為- *args/- **kwargs函數參數,符號跟蹤器將引發錯誤。- 解決這個問題的主要方法有兩種: 1. 將無法追蹤的邏輯分解為頂級函數並在其上使用 - fx.wrap。 2. 如果控製流是靜態的(即循環行程計數基於某個超參數),代碼可以保持在其原始位置並重構為:- for i in range(self.some_hyperparameter): indexed_item = proxied_value[i]- 有關代理內部的更詳細說明,請查看 - torch/fx/OVERVIEW.md中的 “Proxy” 部分- 注意 - 保證此 API 的向後兼容性。 
相關用法
- Python PyTorch PackageImporter.id用法及代碼示例
- Python PyTorch PoissonNLLLoss用法及代碼示例
- Python PyTorch PixelShuffle用法及代碼示例
- Python PyTorch Pipe用法及代碼示例
- Python PyTorch ParagraphAggregator用法及代碼示例
- Python PyTorch PooledEmbeddingsAllToAll用法及代碼示例
- Python PyTorch PackageExporter.register_extern_hook用法及代碼示例
- Python PyTorch Poisson用法及代碼示例
- Python PyTorch Perceptron用法及代碼示例
- Python PyTorch ParallelReadConcat用法及代碼示例
- Python PyTorch ParameterList用法及代碼示例
- Python PyTorch PairwiseDistance用法及代碼示例
- Python PyTorch ParquetDataFrameLoader用法及代碼示例
- Python PyTorch PackageExporter.register_intern_hook用法及代碼示例
- Python PyTorch PixelUnshuffle用法及代碼示例
- Python PyTorch ParameterDict用法及代碼示例
- Python PyTorch PitchShift用法及代碼示例
- Python PyTorch Pareto用法及代碼示例
- Python PyTorch PackageExporter.close用法及代碼示例
- Python PyTorch PooledEmbeddingsReduceScatter用法及代碼示例
- Python PyTorch PackageExporter.register_mock_hook用法及代碼示例
- Python PyTorch PReLU用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.fx.Proxy。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
