MCPcopy Create free account
hub / github.com/MegEngine/MegCC / GiReduceMaxNanFloat32

Function GiReduceMaxNanFloat32

immigration/include/gi_float.h:1326–1357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1324#define Min(a, b) (a) < (b) ? (a) : (b)
1325
1326GI_FORCEINLINE
1327float GiReduceMaxNanFloat32(GI_FLOAT32_t Vector) {
1328#if defined(GI_NEON64_INTRINSICS)
1329 return vmaxvq_f32(Vector);
1330#elif defined(GI_NEON32_INTRINSICS)
1331 float32x2_t VectorLow = vget_low_f32(Vector);
1332 float32x2_t VectorHigh = vget_high_f32(Vector);
1333 VectorLow = vpmax_f32(VectorLow, VectorHigh);
1334 VectorLow = vpmax_f32(VectorLow, VectorHigh);
1335 return vget_lane_f32(VectorLow, 0);
1336#elif defined(GI_SSE2_INTRINSICS)
1337 Vector = GiMaxNanFloat32(
1338 Vector, _mm_shuffle_ps(Vector, Vector, _MM_SHUFFLE(2, 3, 2, 3)));
1339 Vector = GiMaxNanFloat32(
1340 Vector, _mm_shuffle_ps(Vector, Vector, _MM_SHUFFLE(1, 1, 1, 1)));
1341 return GiExtractLane0Float32(Vector);
1342#elif defined(GI_RVV_INTRINSICS)
1343 //! vfredmax_vs_f32m1_f32m1 can not handle NAN case, imp with naive
1344 GI_FLOAT32_FIXLEN_t v = GiFloat32Type2FixLenType(Vector);
1345 float ret = v[0];
1346 for (size_t i = 1; i < GI_SIMD_LEN_BYTE / sizeof(float); i++) {
1347 ret = MAX_NAN(ret, v[i]);
1348 }
1349 return ret;
1350#else
1351 float ret = Vector[0];
1352 for (size_t i = 1; i < GI_SIMD_LEN_BYTE / sizeof(float); i++) {
1353 ret = MAX_NAN(ret, Vector[i]);
1354 }
1355 return ret;
1356#endif
1357}
1358
1359GI_FORCEINLINE
1360float GiReduceMinNanFloat32(GI_FLOAT32_t Vector) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected