benchmark
5c5a3164 - Replace hasattr with getattr in pytorch/benchmark/torchbenchmark/models/torchrec_dlrm/data/dlrm_dataloader.py

Commit
2 years ago
Replace hasattr with getattr in pytorch/benchmark/torchbenchmark/models/torchrec_dlrm/data/dlrm_dataloader.py Summary: The pattern ``` X.Y if hasattr(X, "Y") else Z ``` can be replaced with ``` getattr(X, "Y", Z) ``` The [getattr](https://www.w3schools.com/python/ref_func_getattr.asp) function gives more succinct code than the [hasattr](https://www.w3schools.com/python/ref_func_hasattr.asp) function. Please use it when appropriate. **This diff is very low risk. Green tests indicate that you can safely Accept & Ship.** Reviewed By: xuzhao9 Differential Revision: D44886824 fbshipit-source-id: 2a85aafb487e81f72e999d284889406f9ff5a16b
Author
Parents
Loading