8000 Merge pull request #121 from howjmay/vfms_f32 · plctlab/numpy@909037d · GitHub
[go: up one dir, main page]

Skip to content

Commit 909037d

Browse files
authored
Merge pull request numpy#121 from howjmay/vfms_f32
feat: Add vfms_f32
2 parents 2c174d1 + e218e91 commit 909037d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

neon2rvv.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,9 @@ FORCE_INLINE float32x2_t vfma_f32(float32x2_t __a, float32x2_t __b, float32x2_t
580580

581581
// FORCE_INLINE float32x4_t vfmaq_f32(float32x4_t __a, float32x4_t __b, float32x4_t __c);
582582

583-
// FORCE_INLINE float32x2_t vfms_f32(float32x2_t __a, float32x2_t __b, float32x2_t __c);
583+
FORCE_INLINE float32x2_t vfms_f32(float32x2_t __a, float32x2_t __b, float32x2_t __c) {
584+
return __riscv_vfnmsac_vv_f32m1(__a, __b, __c, 2);
585+
}
584586

585587
// FORCE_INLINE float32x4_t vfmsq_f32(float32x4_t __a, float32x4_t __b, float32x4_t __c);
586588

tests/impl.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,21 @@ result_t test_vfma_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
13601360

13611361
result_t test_vfmaq_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
13621362

1363-
result_t test_vfms_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
1363+
result_t test_vfms_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
1364+
const float *_a = (float *)impl.test_cases_float_pointer1;
1365+
const float *_b = (float *)impl.test_cases_float_pointer2;
1366+
const float *_c = (float *)impl.test_cases_float_pointer3;
1367+
float _d[2];
1368+
for (int i = 0; i < 2; i++) {
1369+
_d[i] = _a[i] - _b[i] * _c[i];
1370+
}
1371+
1372+
float32x2_t a = vld1_f32(_a);
1373+
float32x2_t b = vld1_f32(_b);
1374+
float32x2_t c = vld1_f32(_c);
1375+
float32x2_t d = vfms_f32(a, b, c);
1376+
return validate_float_error(d, _d[0], _d[1], 0.001f);
1377+
}
13641378

13651379
result_t test_vfmsq_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
13661380

0 commit comments

Comments
 (0)
0