Change Dynamo's custom ops warning message to be less spammy (#128456)
Summary:
This is a short-term fix (for 2.4). In the longer term we should
fix https://github.com/pytorch/pytorch/issues/128430
The problem is that warnings.warn that are inside Dynamo print
all the time. Python warnings are supposed to print once, unless their
cache is reset: Dynamo ends up resetting that cache everytime it runs.
As a workaround we provide our own warn_once cache that is keyed on the
warning msg. I am not worried about this increasing memory usage because
that's effectively what python's warnings.warn cache does.
X-link: https://github.com/pytorch/pytorch/pull/128456
Approved by: https://github.com/anijain2305
Reviewed By: clee2000
Differential Revision: D58501328
Pulled By: zou3519
fbshipit-source-id: 99dcfddfae27de2f1de6e9685aa990a738531199