[caffe2] compute r_correction only for radam to avoid sqrt(negative) (#39393)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39393
Computing r_correction should be done only for radam . Otherwise can generate floating-point exceptions.
Test Plan:
buck test caffe2/caffe2/python/operator_test:adam_test -- test_sparse_adam
with --caffe2_operator_throw_if_fp_exceptions=1 gflags option
Differential Revision: D21834296
fbshipit-source-id: a9e6a93451423e76a99f6591d21cb65d4374b008