fix elementwise_mod float point kernel. test=develop (#21183)

revert-21172-masked_select_api
Kaipeng Deng 6 years ago committed by GitHub
parent 835119c777
commit 98b59cb82c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,7 +29,9 @@ struct ModFunctor {
template <typename T>
struct ModFunctorFP {
inline HOSTDEVICE T operator()(T a, T b) const { return std::fmod(a, b); }
inline HOSTDEVICE T operator()(T a, T b) const {
return fmod(b + fmod(a, b), b);
}
};
template <typename DeviceContext, typename T>

@ -71,7 +71,7 @@ class TestElementwiseModOpFloat(TestElementwiseModOp):
def init_input_output(self):
self.x = np.random.uniform(-1000, 1000, [10, 10]).astype(self.dtype)
self.y = np.random.uniform(-100, 100, [10, 10]).astype(self.dtype)
self.out = np.fmod(self.x, self.y)
self.out = np.fmod(self.y + np.fmod(self.x, self.y), self.y)
def test_check_output(self):
self.check_output(atol=2e-5)

Loading…
Cancel
Save