Marat Dukhan | 77ca630 | 2019-12-06 12:48:15 -0800 | [diff] [blame] | 1 | // Auto-generated file. Do not edit! |
| 2 | // Template: src/f32-vbinary/vop-scalar.c.in |
| 3 | // Generator: tools/xngen |
| 4 | // |
| 5 | // Copyright 2019 Google LLC |
| 6 | // |
| 7 | // This source code is licensed under the BSD-style license found in the |
| 8 | // LICENSE file in the root directory of this source tree. |
| 9 | |
| 10 | #include <assert.h> |
| 11 | |
| 12 | #include <xnnpack/common.h> |
| 13 | #include <xnnpack/math.h> |
| 14 | #include <xnnpack/vbinary.h> |
| 15 | |
| 16 | |
Marat Dukhan | 91cd2b7 | 2020-04-09 23:57:31 -0700 | [diff] [blame] | 17 | void xnn_f32_vdiv_minmax_ukernel__scalar_x4( |
Marat Dukhan | 77ca630 | 2019-12-06 12:48:15 -0800 | [diff] [blame] | 18 | size_t n, |
| 19 | const float* a, |
| 20 | const float* b, |
| 21 | float* y, |
Marat Dukhan | f196d01 | 2020-04-15 11:50:03 -0700 | [diff] [blame] | 22 | const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) |
Marat Dukhan | 77ca630 | 2019-12-06 12:48:15 -0800 | [diff] [blame] | 23 | { |
| 24 | assert(n != 0); |
| 25 | assert(n % sizeof(float) == 0); |
Frank Barchard | 0822dde | 2020-07-04 12:47:24 -0700 | [diff] [blame] | 26 | assert(a != NULL); |
| 27 | assert(b != NULL); |
| 28 | assert(y != NULL); |
Marat Dukhan | 77ca630 | 2019-12-06 12:48:15 -0800 | [diff] [blame] | 29 | |
| 30 | const float vy_min = params->scalar.min; |
| 31 | const float vy_max = params->scalar.max; |
| 32 | |
| 33 | for (; n >= 4 * sizeof(float); n -= 4 * sizeof(float)) { |
| 34 | const float va0 = a[0]; |
| 35 | const float va1 = a[1]; |
| 36 | const float va2 = a[2]; |
| 37 | const float va3 = a[3]; |
| 38 | a += 4; |
| 39 | |
| 40 | const float vb0 = b[0]; |
| 41 | const float vb1 = b[1]; |
| 42 | const float vb2 = b[2]; |
| 43 | const float vb3 = b[3]; |
| 44 | b += 4; |
| 45 | |
| 46 | float vy0 = va0 / vb0; |
| 47 | float vy1 = va1 / vb1; |
| 48 | float vy2 = va2 / vb2; |
| 49 | float vy3 = va3 / vb3; |
| 50 | |
Marat Dukhan | 13bafb0 | 2020-06-05 00:43:11 -0700 | [diff] [blame] | 51 | |
Marat Dukhan | 77ca630 | 2019-12-06 12:48:15 -0800 | [diff] [blame] | 52 | vy0 = math_max_f32(vy0, vy_min); |
| 53 | vy1 = math_max_f32(vy1, vy_min); |
| 54 | vy2 = math_max_f32(vy2, vy_min); |
| 55 | vy3 = math_max_f32(vy3, vy_min); |
| 56 | |
| 57 | vy0 = math_min_f32(vy0, vy_max); |
| 58 | vy1 = math_min_f32(vy1, vy_max); |
| 59 | vy2 = math_min_f32(vy2, vy_max); |
| 60 | vy3 = math_min_f32(vy3, vy_max); |
| 61 | |
| 62 | y[0] = vy0; |
| 63 | y[1] = vy1; |
| 64 | y[2] = vy2; |
| 65 | y[3] = vy3; |
| 66 | y += 4; |
| 67 | } |
| 68 | if XNN_UNLIKELY(n != 0) { |
| 69 | do { |
| 70 | const float va = *a++; |
| 71 | const float vb = *b++; |
| 72 | float vy = va / vb; |
| 73 | vy = math_max_f32(vy, vy_min); |
| 74 | vy = math_min_f32(vy, vy_max); |
| 75 | *y++ = vy; |
| 76 | n -= sizeof(float); |
| 77 | } while (n != 0); |
| 78 | } |
| 79 | } |