1 // Copyright 2022 Google LLC 2 // 3 // This source code is licensed under the BSD-style license found in the 4 // LICENSE file in the root directory of this source tree. 5 6 #include <assert.h> 7 #include <stddef.h> 8 #include <math.h> 9 10 #include <xnnpack/math-stubs.h> 11 12 xnn_math_u32_sqrt__scalar_cvti32_sqrt_lrint(size_t n,const uint32_t * input,uint32_t * output)13void xnn_math_u32_sqrt__scalar_cvti32_sqrt_lrint( 14 size_t n, 15 const uint32_t* input, 16 uint32_t* output) 17 { 18 assert(n % sizeof(uint32_t) == 0); 19 20 for (; n != 0; n -= sizeof(uint32_t)) { 21 const uint32_t vx = *input++; 22 23 const int32_t vm = (int32_t) (vx ^ UINT32_C(0x80000000)); 24 double vf = (double) vm + 0x1.0p+31; 25 vf = sqrt(vf); 26 const uint32_t vy = (uint32_t) (int32_t) lrint(vf); 27 28 *output++ = vy; 29 } 30 } 31