Enhace DispatchStub to be thread safe from a TSAN point of view. (#32148)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32148
TSAN would complain about multiple threads reading and writing to the
`cpu_dispatch_ptr` without any sort of synchronization. Although, this is a
valid issue from a TSAN point of view, there wasn't a correctness issue since
both threads would compute the same value.
In order to fix this, I've used std::atomic for cpu_dispatch_ptr with relaxed
ordering guarantees.
ghstack-source-id: 96989435
Test Plan: Verify the TSAN tests pass.
Differential Revision: D19386082
fbshipit-source-id: 1ff0893e02529eddd06b2855d9565edf1bbf1196